]> granicus.if.org Git - php/commitdiff
Optimized handlers for ZEND_RECV and ZEND_RECV_INIT opocdes
authorDmitry Stogov <dmitry@php.net>
Thu, 24 Apr 2008 15:46:28 +0000 (15:46 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 24 Apr 2008 15:46:28 +0000 (15:46 +0000)
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index ab51b99f5e7e371c5ef897d2594a93f298fbbea6..1e3654e6d22f1275c871b51ac6bd1bc3a4af59e8 100644 (file)
@@ -814,14 +814,6 @@ static inline zval* zend_assign_to_variable(zval **variable_ptr_ptr, zval *value
 }
 /* }}} */
 
-static inline void zend_receive(zval **variable_ptr_ptr, zval *value TSRMLS_DC) /* {{{ */
-{
-       Z_DELREF_PP(variable_ptr_ptr);
-       *variable_ptr_ptr = value;
-       Z_ADDREF_P(value);
-}
-/* }}} */
-
 /* Utility Functions for Extensions */
 static void zend_extension_statement_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) /* {{{ */
 {
index fc9299bb39c8258af068101a98b1e672a5ec45c1..fad07c3e73261b3ecb6cfc29b1b90439da883e6a 100644 (file)
@@ -2612,11 +2612,9 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
 
                zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param, opline->extended_value TSRMLS_CC);
                var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
-               if (PZVAL_IS_REF(*param)) {
-                       zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC);
-               } else {
-                       zend_receive(var_ptr, *param TSRMLS_CC);
-               }
+               Z_DELREF_PP(var_ptr);
+               *var_ptr = *param;
+               Z_ADDREF_PP(var_ptr);
        }
 
        ZEND_VM_NEXT_OPCODE();
@@ -2625,42 +2623,31 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
 ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
 {
        zend_op *opline = EX(opline);
-       zval *assignment_value, **var_ptr;
+       zval *assignment_value;
        zend_uint arg_num = Z_LVAL(opline->op1.u.constant);
        zend_free_op free_res;
        zval **param = zend_vm_stack_get_arg(arg_num TSRMLS_CC);
+       zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);;
 
        if (param == NULL) {
+               ALLOC_ZVAL(assignment_value);
+               *assignment_value = opline->op2.u.constant;
                if ((Z_TYPE(opline->op2.u.constant) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT || Z_TYPE(opline->op2.u.constant)==IS_CONSTANT_ARRAY) {
-                       zval *default_value;
-
-                       ALLOC_ZVAL(default_value);
-                       *default_value = opline->op2.u.constant;
-                       Z_SET_REFCOUNT_P(default_value, 1);
-                       zval_update_constant(&default_value, 0 TSRMLS_CC);
-                       Z_SET_REFCOUNT_P(default_value, 0);
-                       Z_UNSET_ISREF_P(default_value);
-                       param = &default_value;
-                       assignment_value = default_value;
+                       Z_SET_REFCOUNT_P(assignment_value, 1);
+                       zval_update_constant(&assignment_value, 0 TSRMLS_CC);
                } else {
-                       param = NULL;
-                       assignment_value = &opline->op2.u.constant;
+                       zval_copy_ctor(assignment_value);
                }
-               zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC);
-               
-               var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
-               zend_assign_to_variable(var_ptr, assignment_value, 0 TSRMLS_CC);
+               INIT_PZVAL(assignment_value);
        } else {
-               var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
                assignment_value = *param;
-               zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC);
-               if (PZVAL_IS_REF(assignment_value)) {
-                       zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC);
-               } else {
-                       zend_receive(var_ptr, assignment_value TSRMLS_CC);
-               }
+               Z_ADDREF_P(assignment_value);
        }
 
+       zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC);
+       Z_DELREF_PP(var_ptr);
+       *var_ptr = assignment_value;
+
        ZEND_VM_NEXT_OPCODE();
 }
 
index 843b9f90bcc9a70444d2559950256b9180001ba6..b7a7aa4d0ec482943f52f031348951b61b13ee9b 100644 (file)
@@ -358,11 +358,9 @@ static int ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 
                zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param, opline->extended_value TSRMLS_CC);
                var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
-               if (PZVAL_IS_REF(*param)) {
-                       zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC);
-               } else {
-                       zend_receive(var_ptr, *param TSRMLS_CC);
-               }
+               Z_DELREF_PP(var_ptr);
+               *var_ptr = *param;
+               Z_ADDREF_PP(var_ptr);
        }
 
        ZEND_VM_NEXT_OPCODE();
@@ -709,42 +707,31 @@ static int ZEND_INIT_NS_FCALL_BY_NAME_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG
 static int ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 {
        zend_op *opline = EX(opline);
-       zval *assignment_value, **var_ptr;
+       zval *assignment_value;
        zend_uint arg_num = Z_LVAL(opline->op1.u.constant);
        zend_free_op free_res;
        zval **param = zend_vm_stack_get_arg(arg_num TSRMLS_CC);
+       zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);;
 
        if (param == NULL) {
+               ALLOC_ZVAL(assignment_value);
+               *assignment_value = opline->op2.u.constant;
                if ((Z_TYPE(opline->op2.u.constant) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT || Z_TYPE(opline->op2.u.constant)==IS_CONSTANT_ARRAY) {
-                       zval *default_value;
-
-                       ALLOC_ZVAL(default_value);
-                       *default_value = opline->op2.u.constant;
-                       Z_SET_REFCOUNT_P(default_value, 1);
-                       zval_update_constant(&default_value, 0 TSRMLS_CC);
-                       Z_SET_REFCOUNT_P(default_value, 0);
-                       Z_UNSET_ISREF_P(default_value);
-                       param = &default_value;
-                       assignment_value = default_value;
+                       Z_SET_REFCOUNT_P(assignment_value, 1);
+                       zval_update_constant(&assignment_value, 0 TSRMLS_CC);
                } else {
-                       param = NULL;
-                       assignment_value = &opline->op2.u.constant;
+                       zval_copy_ctor(assignment_value);
                }
-               zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC);
-
-               var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
-               zend_assign_to_variable(var_ptr, assignment_value, 0 TSRMLS_CC);
+               INIT_PZVAL(assignment_value);
        } else {
-               var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W);
                assignment_value = *param;
-               zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC);
-               if (PZVAL_IS_REF(assignment_value)) {
-                       zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC);
-               } else {
-                       zend_receive(var_ptr, assignment_value TSRMLS_CC);
-               }
+               Z_ADDREF_P(assignment_value);
        }
 
+       zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC);
+       Z_DELREF_PP(var_ptr);
+       *var_ptr = assignment_value;
+
        ZEND_VM_NEXT_OPCODE();
 }