diff options
author | Dmitry Stogov <dmitry@php.net> | 2008-04-24 15:45:46 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2008-04-24 15:45:46 +0000 |
commit | 8fac72574ddf11ff1ef40be400e089cf452a6f6f (patch) | |
tree | d7e6e5806a8022f3381245d7b47b7f557b653b66 | |
parent | f4e659d2af2ba68eb6d9092560eb0247a33fb827 (diff) | |
download | php-git-8fac72574ddf11ff1ef40be400e089cf452a6f6f.tar.gz |
Optimized handlers for ZEND_RECV and ZEND_RECV_INIT opocdes
-rw-r--r-- | Zend/zend_execute.c | 9 | ||||
-rw-r--r-- | Zend/zend_vm_def.h | 45 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 45 |
3 files changed, 32 insertions, 67 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 40f6df7b57..d2aae1a45f 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -733,15 +733,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) -{ - zval *variable_ptr = *variable_ptr_ptr; - - Z_DELREF_P(variable_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) { diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 010083826f..35ed0169ce 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2549,11 +2549,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(); @@ -2562,42 +2560,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(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 9d1c30ee4b..d21dfadb8d 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -351,11 +351,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(); @@ -697,42 +695,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(); } |