diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-07-09 12:46:46 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-07-09 12:46:46 +0300 |
commit | 67b4c3379a1c7f8a34522972c9cb3adf3776bc4a (patch) | |
tree | 4089d3d836a02d9b94d2eb6304ac3b9d3c57e21f /Zend | |
parent | 094c2aaf8371064528878f63e12b8347eefb2b71 (diff) | |
download | php-git-67b4c3379a1c7f8a34522972c9cb3adf3776bc4a.tar.gz |
Uze ZVAL_COPY_DEREF() instead of ZVAL_DEREF() and ZVAL_COPY()
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_builtin_functions.c | 3 | ||||
-rw-r--r-- | Zend/zend_execute.c | 14 | ||||
-rw-r--r-- | Zend/zend_generators.c | 15 | ||||
-rw-r--r-- | Zend/zend_object_handlers.c | 9 | ||||
-rw-r--r-- | Zend/zend_vm_def.h | 15 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 45 |
6 files changed, 32 insertions, 69 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 591c8af17f..30e6094930 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -466,8 +466,7 @@ ZEND_FUNCTION(func_get_arg) arg = ZEND_CALL_ARG(ex, requested_offset + 1); } if (EXPECTED(!Z_ISUNDEF_P(arg))) { - ZVAL_DEREF(arg); - ZVAL_COPY(return_value, arg); + ZVAL_COPY_DEREF(return_value, arg); } } /* }}} */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 097ccc10e1..5012688c6b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1450,12 +1450,8 @@ static zend_never_inline void zend_post_incdec_overloaded_property(zval *object, ZVAL_COPY_VALUE(z, value); } - if (UNEXPECTED(Z_TYPE_P(z) == IS_REFERENCE)) { - ZVAL_COPY(EX_VAR(opline->result.var), Z_REFVAL_P(z)); - } else { - ZVAL_COPY(EX_VAR(opline->result.var), z); - } - ZVAL_COPY(&z_copy, EX_VAR(opline->result.var)); + ZVAL_COPY_DEREF(&z_copy, z); + ZVAL_COPY(EX_VAR(opline->result.var), &z_copy); if (inc) { increment_function(&z_copy); } else { @@ -1499,11 +1495,7 @@ static zend_never_inline void zend_pre_incdec_overloaded_property(zval *object, } ZVAL_COPY_VALUE(z, value); } - if (UNEXPECTED(Z_TYPE_P(z) == IS_REFERENCE)) { - ZVAL_COPY(&z_copy, Z_REFVAL_P(z)); - } else { - ZVAL_COPY(&z_copy, z); - } + ZVAL_COPY_DEREF(&z_copy, z); if (inc) { increment_function(&z_copy); } else { diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 8408cc32f4..c532dfe845 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -887,8 +887,7 @@ ZEND_METHOD(Generator, current) if (EXPECTED(generator->execute_data != NULL && Z_TYPE(root->value) != IS_UNDEF)) { zval *value = &root->value; - ZVAL_DEREF(value); - ZVAL_COPY(return_value, value); + ZVAL_COPY_DEREF(return_value, value); } } /* }}} */ @@ -911,8 +910,7 @@ ZEND_METHOD(Generator, key) if (EXPECTED(generator->execute_data != NULL && Z_TYPE(root->key) != IS_UNDEF)) { zval *key = &root->key; - ZVAL_DEREF(key); - ZVAL_COPY(return_value, key); + ZVAL_COPY_DEREF(return_value, key); } } /* }}} */ @@ -967,8 +965,7 @@ ZEND_METHOD(Generator, send) if (EXPECTED(generator->execute_data)) { zval *value = &root->value; - ZVAL_DEREF(value); - ZVAL_COPY(return_value, value); + ZVAL_COPY_DEREF(return_value, value); } } /* }}} */ @@ -1001,8 +998,7 @@ ZEND_METHOD(Generator, throw) if (generator->execute_data) { zval *value = &root->value; - ZVAL_DEREF(value); - ZVAL_COPY(return_value, value); + ZVAL_COPY_DEREF(return_value, value); } } else { /* If the generator is already closed throw the exception in the @@ -1101,8 +1097,7 @@ static void zend_generator_iterator_get_key(zend_object_iterator *iterator, zval if (EXPECTED(Z_TYPE(root->key) != IS_UNDEF)) { zval *zv = &root->key; - ZVAL_DEREF(zv); - ZVAL_COPY(key, zv); + ZVAL_COPY_DEREF(key, zv); } else { ZVAL_NULL(key); } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 97a0dcd817..72c182c7b2 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -848,8 +848,7 @@ ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zva /* [] construct */ ZVAL_NULL(&tmp_offset); } else { - ZVAL_DEREF(offset); - ZVAL_COPY(&tmp_offset, offset); + ZVAL_COPY_DEREF(&tmp_offset, offset); } ZVAL_COPY(&tmp_object, object); @@ -897,8 +896,7 @@ ZEND_API void zend_std_write_dimension(zval *object, zval *offset, zval *value) if (!offset) { ZVAL_NULL(&tmp_offset); } else { - ZVAL_DEREF(offset); - ZVAL_COPY(&tmp_offset, offset); + ZVAL_COPY_DEREF(&tmp_offset, offset); } ZVAL_COPY(&tmp_object, object); zend_call_method_with_2_params(&tmp_object, ce, NULL, "offsetset", NULL, &tmp_offset, value); @@ -1084,8 +1082,7 @@ ZEND_API void zend_std_unset_dimension(zval *object, zval *offset) /* {{{ */ zval tmp_offset, tmp_object; if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1)) { - ZVAL_DEREF(offset); - ZVAL_COPY(&tmp_offset, offset); + ZVAL_COPY_DEREF(&tmp_offset, offset); ZVAL_COPY(&tmp_object, object); zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetunset", NULL, &tmp_offset); zval_ptr_dtor(&tmp_object); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 391f096243..8c08e1205c 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4016,8 +4016,7 @@ ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, CONST|TMP|VAR|CV, ANY) } } } else if (OP1_TYPE == IS_CV) { - ZVAL_DEREF(retval); - ZVAL_COPY(&generator->retval, retval); + ZVAL_COPY_DEREF(&generator->retval, retval); } else /* if (OP1_TYPE == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(retval))) { zend_refcounted *ref = Z_COUNTED_P(retval); @@ -4209,8 +4208,7 @@ ZEND_VM_HOT_HANDLER(117, ZEND_SEND_VAR, VAR|CV, NUM) arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (OP1_TYPE == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (OP1_TYPE == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -4344,8 +4342,7 @@ ZEND_VM_C_LABEL(send_var_by_ref): arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (OP1_TYPE == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (OP1_TYPE == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -4471,8 +4468,7 @@ ZEND_VM_C_LABEL(send_again): ZVAL_NEW_REF(top, arg); } } else { - ZVAL_DEREF(arg); - ZVAL_COPY(top, arg); + ZVAL_COPY_DEREF(top, arg); } ZEND_CALL_NUM_ARGS(EX(call))++; @@ -6586,8 +6582,7 @@ ZEND_VM_HOT_HANDLER(22, ZEND_QM_ASSIGN, CONST|TMP|VAR|CV, ANY) } if (OP1_TYPE == IS_CV) { - ZVAL_DEREF(value); - ZVAL_COPY(result, value); + ZVAL_COPY_DEREF(result, value); } else if (OP1_TYPE == IS_VAR) { if (UNEXPECTED(Z_ISREF_P(value))) { ZVAL_COPY_VALUE(result, Z_REFVAL_P(value)); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 53012151c6..bb8d9e8df7 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1308,8 +1308,7 @@ send_again: ZVAL_NEW_REF(top, arg); } } else { - ZVAL_DEREF(arg); - ZVAL_COPY(top, arg); + ZVAL_COPY_DEREF(top, arg); } ZEND_CALL_NUM_ARGS(EX(call))++; @@ -2899,8 +2898,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_CONST_HA } } } else if (IS_CONST == IS_CV) { - ZVAL_DEREF(retval); - ZVAL_COPY(&generator->retval, retval); + ZVAL_COPY_DEREF(&generator->retval, retval); } else /* if (IS_CONST == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(retval))) { zend_refcounted *ref = Z_COUNTED_P(retval); @@ -3652,8 +3650,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_CON } if (IS_CONST == IS_CV) { - ZVAL_DEREF(value); - ZVAL_COPY(result, value); + ZVAL_COPY_DEREF(result, value); } else if (IS_CONST == IS_VAR) { if (UNEXPECTED(Z_ISREF_P(value))) { ZVAL_COPY_VALUE(result, Z_REFVAL_P(value)); @@ -17906,8 +17903,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_TMP_HAND } } } else if (IS_TMP_VAR == IS_CV) { - ZVAL_DEREF(retval); - ZVAL_COPY(&generator->retval, retval); + ZVAL_COPY_DEREF(&generator->retval, retval); } else /* if (IS_TMP_VAR == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(retval))) { zend_refcounted *ref = Z_COUNTED_P(retval); @@ -18406,8 +18402,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_TMP } if (IS_TMP_VAR == IS_CV) { - ZVAL_DEREF(value); - ZVAL_COPY(result, value); + ZVAL_COPY_DEREF(result, value); } else if (IS_TMP_VAR == IS_VAR) { if (UNEXPECTED(Z_ISREF_P(value))) { ZVAL_COPY_VALUE(result, Z_REFVAL_P(value)); @@ -20719,8 +20714,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_VAR_HAND } } } else if (IS_VAR == IS_CV) { - ZVAL_DEREF(retval); - ZVAL_COPY(&generator->retval, retval); + ZVAL_COPY_DEREF(&generator->retval, retval); } else /* if (IS_VAR == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(retval))) { zend_refcounted *ref = Z_COUNTED_P(retval); @@ -20802,8 +20796,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_VAR_ arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (IS_VAR == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (IS_VAR == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -20977,8 +20970,7 @@ send_var_by_ref: arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (IS_VAR == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (IS_VAR == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -21026,8 +21018,7 @@ send_var_by_ref: arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (IS_VAR == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (IS_VAR == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -21773,8 +21764,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_VAR } if (IS_VAR == IS_CV) { - ZVAL_DEREF(value); - ZVAL_COPY(result, value); + ZVAL_COPY_DEREF(result, value); } else if (IS_VAR == IS_VAR) { if (UNEXPECTED(Z_ISREF_P(value))) { ZVAL_COPY_VALUE(result, Z_REFVAL_P(value)); @@ -36870,8 +36860,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_CV_HANDL } } } else if (IS_CV == IS_CV) { - ZVAL_DEREF(retval); - ZVAL_COPY(&generator->retval, retval); + ZVAL_COPY_DEREF(&generator->retval, retval); } else /* if (IS_CV == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(retval))) { zend_refcounted *ref = Z_COUNTED_P(retval); @@ -36953,8 +36942,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_VAR_SPEC_CV_H arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (IS_CV == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (IS_CV == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -37028,8 +37016,7 @@ send_var_by_ref: arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (IS_CV == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (IS_CV == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -37077,8 +37064,7 @@ send_var_by_ref: arg = ZEND_CALL_VAR(EX(call), opline->result.var); if (IS_CV == IS_CV) { - ZVAL_OPT_DEREF(varptr); - ZVAL_COPY(arg, varptr); + ZVAL_COPY_DEREF(arg, varptr); } else /* if (IS_CV == IS_VAR) */ { if (UNEXPECTED(Z_ISREF_P(varptr))) { zend_refcounted *ref = Z_COUNTED_P(varptr); @@ -37664,8 +37650,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_QM_ASSIGN_SPEC_CV_ } if (IS_CV == IS_CV) { - ZVAL_DEREF(value); - ZVAL_COPY(result, value); + ZVAL_COPY_DEREF(result, value); } else if (IS_CV == IS_VAR) { if (UNEXPECTED(Z_ISREF_P(value))) { ZVAL_COPY_VALUE(result, Z_REFVAL_P(value)); |