]> granicus.if.org Git - php/commitdiff
Don't add num_additional_args in SEND opcodes
authorNikita Popov <nikic@php.net>
Wed, 26 Feb 2014 15:25:10 +0000 (16:25 +0100)
committerNikita Popov <nikic@php.net>
Wed, 26 Feb 2014 15:40:25 +0000 (16:40 +0100)
Now that trailing positional args are disallowed,
num_additional_args will always be zero in SEND opcodes (and
FUNC_ARG fetches).

Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 31caceecbe90224cb7b3cf4cf7db75e36ebdbf40..66accd61e970de93497dcb4add83eda3029d3eb6 100644 (file)
@@ -1686,7 +1686,7 @@ ZEND_API zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array
 
 static zend_always_inline zend_bool zend_is_by_ref_func_arg_fetch(zend_op *opline, call_slot *call TSRMLS_DC) /* {{{ */
 {
-       zend_uint arg_num = (opline->extended_value & ZEND_FETCH_ARG_MASK) + call->num_additional_args;
+       zend_uint arg_num = opline->extended_value & ZEND_FETCH_ARG_MASK;
        return ARG_SHOULD_BE_SENT_BY_REF(call->fbc, arg_num);
 }
 /* }}} */
index 713d6fadeedd05bfccd526d9a9faf30acb1027c7..ed353edbac3db45642f8f5e04149f02b518593c4 100644 (file)
@@ -3063,9 +3063,8 @@ ZEND_VM_HANDLER(65, ZEND_SEND_VAL, CONST|TMP, ANY)
 
        SAVE_OPLINE();
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
-                       zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", arg_num);
+               if (ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
+                       zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num);
                }
        }
 
@@ -3126,7 +3125,6 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
        USE_OPLINE
        zend_free_op free_op1;
        zval *varptr;
-       int arg_num;
 
        SAVE_OPLINE();
        if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
@@ -3134,8 +3132,7 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
                        ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper);
                }
        } else {
-               arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper);
                }
        }
@@ -3155,7 +3152,7 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)
 
                if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
                        !(opline->extended_value & ZEND_ARG_SEND_SILENT) :
-                       !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+                       !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        zend_error(E_STRICT, "Only variables should be passed by reference");
                }
                ALLOC_ZVAL(valptr);
@@ -3193,8 +3190,7 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY)
 
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME &&
            EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { 
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper);
                }
        }
@@ -3214,8 +3210,7 @@ ZEND_VM_HANDLER(66, ZEND_SEND_VAR, VAR|CV, ANY)
        USE_OPLINE
 
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF);
                }
        }
index 2593c26f43e9a74f99a1050f884ae2ed3136e0ca..a4e3350eaa16c47caafa4aae73c53bdaae57f7df 100644 (file)
@@ -2736,9 +2736,8 @@ static int ZEND_FASTCALL  ZEND_SEND_VAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
 
        SAVE_OPLINE();
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
-                       zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", arg_num);
+               if (ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
+                       zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num);
                }
        }
 
@@ -8094,9 +8093,8 @@ static int ZEND_FASTCALL  ZEND_SEND_VAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
 
        SAVE_OPLINE();
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
-                       zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", arg_num);
+               if (ARG_MUST_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
+                       zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.num);
                }
        }
 
@@ -13385,7 +13383,6 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
        USE_OPLINE
        zend_free_op free_op1;
        zval *varptr;
-       int arg_num;
 
        SAVE_OPLINE();
        if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
@@ -13393,8 +13390,7 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
                        return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        } else {
-               arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        }
@@ -13414,7 +13410,7 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HAND
 
                if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
                        !(opline->extended_value & ZEND_ARG_SEND_SILENT) :
-                       !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+                       !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        zend_error(E_STRICT, "Only variables should be passed by reference");
                }
                ALLOC_ZVAL(valptr);
@@ -13452,8 +13448,7 @@ static int ZEND_FASTCALL  ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
 
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME &&
            EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        return zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        }
@@ -13473,8 +13468,7 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
        USE_OPLINE
 
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        return ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        }
@@ -31000,7 +30994,6 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
        USE_OPLINE
 
        zval *varptr;
-       int arg_num;
 
        SAVE_OPLINE();
        if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */
@@ -31008,8 +31001,7 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
                        return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        } else {
-               arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        }
@@ -31029,7 +31021,7 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDL
 
                if ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
                        !(opline->extended_value & ZEND_ARG_SEND_SILENT) :
-                       !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+                       !ARG_MAY_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        zend_error(E_STRICT, "Only variables should be passed by reference");
                }
                ALLOC_ZVAL(valptr);
@@ -31067,8 +31059,7 @@ static int ZEND_FASTCALL  ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
 
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME &&
            EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        return zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        }
@@ -31087,8 +31078,7 @@ static int ZEND_FASTCALL  ZEND_SEND_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
        USE_OPLINE
 
        if (opline->extended_value == ZEND_DO_FCALL_BY_NAME) {
-               int arg_num = opline->op2.num + EX(call)->num_additional_args;
-               if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, arg_num)) {
+               if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->fbc, opline->op2.num)) {
                        return ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
                }
        }