From: Dmitry Stogov Date: Mon, 2 Jun 2014 20:36:31 +0000 (+0400) Subject: cleanup X-Git-Tag: POST_PHPNG_MERGE~232 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0427ae08fb8dde00993277c3e7f9d98abfa159a8;p=php cleanup --- diff --git a/Zend/zend.c b/Zend/zend.c index 841fc38565..a1ffb5f0c9 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -249,14 +249,12 @@ again: TSRMLS_FETCH(); if (Z_OBJ_HANDLER_P(expr, cast_object)) { - zval val; - - ZVAL_DUP_DEREF(&val, expr); - if (Z_OBJ_HANDLER_P(expr, cast_object)(&val, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zval_ptr_dtor(&val); + Z_ADDREF_P(expr); + if (Z_OBJ_HANDLER_P(expr, cast_object)(expr, expr_copy, IS_STRING TSRMLS_CC) == SUCCESS) { + zval_ptr_dtor(expr); break; } - zval_ptr_dtor(&val); + zval_ptr_dtor(expr); } if (!Z_OBJ_HANDLER_P(expr, cast_object) && Z_OBJ_HANDLER_P(expr, get)) { zval rv; diff --git a/Zend/zend.h b/Zend/zend.h index 1e592c05c1..d9c8db19b6 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -707,15 +707,6 @@ END_EXTERN_C() } \ } while (0) -#define ZVAL_DUP_DEREF(z, v) \ - do { \ - zval *__z1 = (z); \ - zval *__z2 = (v); \ - ZVAL_DEREF(__z2); \ - ZVAL_COPY_VALUE(__z1, __z2); \ - zval_opt_copy_ctor(__z1); \ - } while (0) - #define ZVAL_UNREF(z) do { \ zval *_z = (z); \ zend_reference *ref; \ diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index cbbdd1e681..1483670379 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -927,15 +927,19 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value } /* copy: enforce read only access */ - ZVAL_DUP_DEREF(&prop_copy, prop); + ZVAL_DEREF(prop); + if (UNEXPECTED(Z_COPYABLE_P(prop))) { + ZVAL_DUP(&prop_copy, prop); + prop = &prop_copy; + } /* this is necessary to make it able to work with default array * properties, returned to user */ - if (Z_OPT_CONSTANT(prop_copy)) { - zval_update_constant(&prop_copy, 0 TSRMLS_CC); + if (Z_OPT_CONSTANT_P(prop)) { + zval_update_constant(prop, 0 TSRMLS_CC); } - zend_hash_add_new(Z_ARRVAL_P(return_value), key, &prop_copy); + zend_hash_add_new(Z_ARRVAL_P(return_value), key, prop); } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -1904,7 +1908,7 @@ ZEND_FUNCTION(get_defined_constants) if (categorize) { zend_constant *val; int module_number; - zval *modules; + zval *modules, tmp, *const_val; char **module_names; zend_module_entry *module; int i = 1; @@ -1920,8 +1924,6 @@ ZEND_FUNCTION(get_defined_constants) module_names[i] = "user"; ZEND_HASH_FOREACH_PTR(EG(zend_constants), val) { - zval const_val; - if (!val->name) { /* skip special constants */ continue; @@ -1941,9 +1943,14 @@ ZEND_FUNCTION(get_defined_constants) add_assoc_zval(return_value, module_names[module_number], &modules[module_number]); } - ZVAL_DUP_DEREF(&const_val, &val->value); + if (EXPECTED(!Z_COPYABLE(val->value))) { + const_val = &val->value; + } else { + ZVAL_DUP(&tmp, &val->value); + const_val = &tmp; + } - zend_hash_add_new(Z_ARRVAL(modules[module_number]), val->name, &const_val); + zend_hash_add_new(Z_ARRVAL(modules[module_number]), val->name, const_val); } ZEND_HASH_FOREACH_END(); efree(module_names); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index f78123124a..a8e57c950a 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -270,7 +270,11 @@ static void _default_exception_get_entry(zval *object, char *name, int name_len, value = zend_read_property(default_exception_ce, object, name, name_len, 0 TSRMLS_CC); - ZVAL_DUP_DEREF(return_value, value); + if (UNEXPECTED(Z_ISREF_P(return_value))) { + ZVAL_DUP(return_value, Z_REFVAL_P(value)); + } else { + ZVAL_COPY(return_value, value); + } } /* }}} */ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 393920237c..0c9f530b6c 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1648,15 +1648,12 @@ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 T ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { - zval op1_copy, op2_copy; - - ZVAL_DUP_DEREF(&op1_copy, op1); - ZVAL_DUP_DEREF(&op2_copy, op2); + double d1, d2; - convert_to_double(&op1_copy); - convert_to_double(&op2_copy); + d1 = zval_get_double(op1); + d2 = zval_get_double(op2); - ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(Z_DVAL(op1_copy)-Z_DVAL(op2_copy))); + ZVAL_LONG(result, ZEND_NORMALIZE_BOOL(d1 - d2)); return SUCCESS; } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 0b5dde1599..862a0a10ba 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1112,17 +1112,19 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST| zend_free_op free_op1; zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = GET_OP1_ZVAL_PTR(BP_VAR_R); - ZVAL_UNDEF(&tmp_varname); - if (OP1_TYPE != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (OP1_TYPE == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (OP2_TYPE != IS_UNUSED) { @@ -1135,7 +1137,7 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST| ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (OP1_TYPE != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } FREE_OP1(); CHECK_EXCEPTION(); @@ -1146,26 +1148,26 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST| } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((OP1_TYPE == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((OP1_TYPE == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); FREE_OP1(); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -1176,14 +1178,14 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST| switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -1200,7 +1202,7 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, UNUSED|CONST| } if (OP1_TYPE != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index a5b678c9d2..8385c6b670 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3572,17 +3572,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = opline->op1.zv; - ZVAL_UNDEF(&tmp_varname); - if (IS_CONST != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_CONST == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_CONST != IS_UNUSED) { @@ -3595,7 +3597,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_CONST != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } CHECK_EXCEPTION(); @@ -3606,26 +3608,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_CONST == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_CONST == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -3636,14 +3638,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -3660,7 +3662,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_CONST(int type } if (IS_CONST != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -5379,17 +5381,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type, zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = opline->op1.zv; - ZVAL_UNDEF(&tmp_varname); - if (IS_CONST != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_CONST == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_VAR != IS_UNUSED) { @@ -5402,7 +5406,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type, ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_CONST != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } CHECK_EXCEPTION(); @@ -5413,26 +5417,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type, } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_CONST == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_CONST == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -5443,14 +5447,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type, switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -5467,7 +5471,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_VAR(int type, } if (IS_CONST != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -6083,17 +6087,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = opline->op1.zv; - ZVAL_UNDEF(&tmp_varname); - if (IS_CONST != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_CONST == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_UNUSED != IS_UNUSED) { @@ -6106,7 +6112,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_CONST != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } CHECK_EXCEPTION(); @@ -6117,26 +6123,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_CONST == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_CONST == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -6147,14 +6153,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -6171,7 +6177,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CONST_UNUSED(int typ } if (IS_CONST != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -8743,17 +8749,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, zend_free_op free_op1; zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_TMP_VAR == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_CONST != IS_UNUSED) { @@ -8766,7 +8774,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_TMP_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -8777,26 +8785,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_TMP_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_TMP_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); zval_dtor(free_op1.var); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -8807,14 +8815,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -8831,7 +8839,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_CONST(int type, } if (IS_TMP_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -10418,17 +10426,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE zend_free_op free_op1; zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_TMP_VAR == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_VAR != IS_UNUSED) { @@ -10441,7 +10451,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_TMP_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -10452,26 +10462,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_TMP_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_TMP_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); zval_dtor(free_op1.var); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -10482,14 +10492,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -10506,7 +10516,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_VAR(int type, ZE } if (IS_TMP_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -11122,17 +11132,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, zend_free_op free_op1; zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_TMP_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_TMP_VAR == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_UNUSED != IS_UNUSED) { @@ -11145,7 +11157,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_TMP_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@ -11156,26 +11168,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_TMP_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_TMP_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); zval_dtor(free_op1.var); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -11186,14 +11198,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -11210,7 +11222,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_TMP_UNUSED(int type, } if (IS_TMP_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -14598,17 +14610,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, zend_free_op free_op1; zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_VAR == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_CONST != IS_UNUSED) { @@ -14621,7 +14635,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } zval_ptr_dtor_nogc(free_op1.var); CHECK_EXCEPTION(); @@ -14632,26 +14646,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); zval_ptr_dtor_nogc(free_op1.var); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -14662,14 +14676,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -14686,7 +14700,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_CONST(int type, } if (IS_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -18938,17 +18952,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE zend_free_op free_op1; zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_VAR == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_VAR != IS_UNUSED) { @@ -18961,7 +18977,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } zval_ptr_dtor_nogc(free_op1.var); CHECK_EXCEPTION(); @@ -18972,26 +18988,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); zval_ptr_dtor_nogc(free_op1.var); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -19002,14 +19018,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -19026,7 +19042,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_VAR(int type, ZE } if (IS_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -20822,17 +20838,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, zend_free_op free_op1; zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_VAR != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_VAR == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_UNUSED != IS_UNUSED) { @@ -20845,7 +20863,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } zval_ptr_dtor_nogc(free_op1.var); CHECK_EXCEPTION(); @@ -20856,26 +20874,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_VAR == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); zval_ptr_dtor_nogc(free_op1.var); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -20886,14 +20904,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -20910,7 +20928,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_VAR_UNUSED(int type, } if (IS_VAR != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -31532,17 +31550,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_CV == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_CONST != IS_UNUSED) { @@ -31555,7 +31575,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_CV != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } CHECK_EXCEPTION(); @@ -31566,26 +31586,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_CV == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_CV == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -31596,14 +31616,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -31620,7 +31640,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_CONST(int type, Z } if (IS_CV != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -35546,17 +35566,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_CV == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_VAR != IS_UNUSED) { @@ -35569,7 +35591,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_CV != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } CHECK_EXCEPTION(); @@ -35580,26 +35602,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_CV == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_CV == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -35610,14 +35632,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -35634,7 +35656,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_VAR(int type, ZEN } if (IS_CV != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); @@ -37312,17 +37334,19 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type, zval *varname; zval *retval; - zval tmp_varname; + zend_string *name; HashTable *target_symbol_table; SAVE_OPLINE(); varname = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC); - ZVAL_UNDEF(&tmp_varname); - if (IS_CV != IS_CONST && UNEXPECTED(Z_TYPE_P(varname) != IS_STRING)) { - ZVAL_DUP_DEREF(&tmp_varname, varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; + if (IS_CV == IS_CONST) { + name = Z_STR_P(varname); + } else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) { + name = Z_STR_P(varname); + STR_ADDREF(name); + } else { + name = zval_get_string(varname); } if (IS_UNUSED != IS_UNUSED) { @@ -37335,7 +37359,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type, ce = zend_fetch_class_by_name(Z_STR_P(opline->op2.zv), opline->op2.zv + 1, 0 TSRMLS_CC); if (UNEXPECTED(ce == NULL)) { if (IS_CV != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } CHECK_EXCEPTION(); @@ -37346,26 +37370,26 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type, } else { ce = Z_CE_P(EX_VAR(opline->op2.var)); } - retval = zend_std_get_static_property(ce, Z_STR_P(varname), 0, ((IS_CV == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); + retval = zend_std_get_static_property(ce, name, 0, ((IS_CV == IS_CONST) ? Z_CACHE_SLOT_P(varname) : -1) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC); - retval = zend_hash_find(target_symbol_table, Z_STR_P(varname)); + retval = zend_hash_find(target_symbol_table, name); if (retval == NULL) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: - retval = zend_hash_add_new(target_symbol_table, Z_STR_P(varname), &EG(uninitialized_zval)); + retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval)); break; EMPTY_SWITCH_DEFAULT_CASE() } @@ -37376,14 +37400,14 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type, switch (type) { case BP_VAR_R: case BP_VAR_UNSET: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_IS: retval = EX_VAR(opline->result.var); ZVAL_NULL(retval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", Z_STRVAL_P(varname)); + zend_error(E_NOTICE,"Undefined variable: %s", name->val); /* break missing intentionally */ case BP_VAR_W: ZVAL_NULL(retval); @@ -37400,7 +37424,7 @@ static int ZEND_FASTCALL zend_fetch_var_address_helper_SPEC_CV_UNUSED(int type, } if (IS_CV != IS_CONST) { - zval_dtor(&tmp_varname); + STR_RELEASE(name); } ZEND_ASSERT(retval != NULL); diff --git a/ext/filter/filter.c b/ext/filter/filter.c index ae554432c1..6e723638aa 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -693,7 +693,8 @@ static void php_filter_array_handler(zval *input, zval *op, zval *return_value, } } else { zval nval; - ZVAL_DUP_DEREF(&nval, tmp); + ZVAL_DEREF(tmp); + ZVAL_DUP(&nval, tmp); php_filter_call(&nval, -1, arg_elm, 0, FILTER_REQUIRE_SCALAR TSRMLS_CC); zend_hash_update(Z_ARRVAL_P(return_value), arg_key, &nval); } diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 6bc6acbb1e..0e9f19a199 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -1180,7 +1180,7 @@ PHP_FUNCTION(xml_set_object) zval_add_ref(&parser->object); #endif */ - ZVAL_DUP_DEREF(&parser->object, mythis); + ZVAL_COPY(&parser->object, mythis); RETVAL_TRUE; }