Move the whole "cold" path into the "cold" function.

This commit is contained in:
Dmitry Stogov 2021-06-23 14:55:58 +03:00
parent 3e164dee99
commit 973ae8d3e2
3 changed files with 26 additions and 58 deletions

View File

@ -1999,7 +1999,7 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_undefined_index(const
zend_error(E_WARNING, "Undefined array key \"%s\"", ZSTR_VAL(offset));
}
ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval)
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval)
{
/* The array may be destroyed while throwing the notice.
* Temporarily increase the refcount to detect this situation. */
@ -2009,30 +2009,36 @@ ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_offset_write(HashTab
zend_undefined_offset(lval);
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && !GC_DELREF(ht)) {
zend_array_destroy(ht);
return FAILURE;
return NULL;
}
if (EG(exception)) {
return FAILURE;
return NULL;
}
return SUCCESS;
return zend_hash_index_add_new(ht, lval, &EG(uninitialized_zval));
}
ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset)
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset)
{
zval *retval;
/* The array may be destroyed while throwing the notice.
* Temporarily increase the refcount to detect this situation. */
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) {
GC_ADDREF(ht);
}
/* Key may be released while throwing the undefined index warning. */
zend_string_addref(offset);
zend_undefined_index(offset);
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && !GC_DELREF(ht)) {
zend_array_destroy(ht);
return FAILURE;
retval = NULL;
} else if (EG(exception)) {
retval = NULL;
} else {
retval = zend_hash_add_new(ht, offset, &EG(uninitialized_zval));
}
if (EG(exception)) {
return FAILURE;
}
return SUCCESS;
zend_string_release(offset);
return retval;
}
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_undefined_method(const zend_class_entry *ce, const zend_string *method)
@ -2167,10 +2173,7 @@ num_undef:
retval = &EG(uninitialized_zval);
break;
case BP_VAR_RW:
if (UNEXPECTED(zend_undefined_offset_write(ht, hval) == FAILURE)) {
return NULL;
}
retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
retval = zend_undefined_offset_write(ht, hval);
break;
}
} else {
@ -2196,14 +2199,7 @@ str_index:
retval = &EG(uninitialized_zval);
break;
case BP_VAR_RW:
/* Key may be released while throwing the undefined index warning. */
zend_string_addref(offset_key);
if (UNEXPECTED(zend_undefined_index_write(ht, offset_key) == FAILURE)) {
zend_string_release(offset_key);
return NULL;
}
retval = zend_hash_add_new(ht, offset_key, &EG(uninitialized_zval));
zend_string_release(offset_key);
retval = zend_undefined_index_write(ht, offset_key);
break;
}
}

View File

@ -65,8 +65,8 @@ ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(zend_property_inf
ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(zend_property_info *prop, zval *zv);
ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1, zend_property_info *prop2, zval *zv);
ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval);
ZEND_API ZEND_COLD zend_result ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset);
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval);
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset);
ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg);
ZEND_API ZEND_COLD void zend_verify_arg_error(

View File

@ -255,10 +255,7 @@ static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_lon
zval *retval = _zend_hash_index_find(ht, idx);
if (!retval) {
if (UNEXPECTED(zend_undefined_offset_write(ht, idx) == FAILURE)) {
return NULL;
}
retval = zend_hash_index_add_new(ht, idx, &EG(uninitialized_zval));
retval = zend_undefined_offset_write(ht, idx);
}
return retval;
}
@ -268,13 +265,7 @@ static zval* ZEND_FASTCALL zend_jit_hash_lookup_rw(HashTable *ht, zend_string *s
zval *retval = zend_hash_find_ex(ht, str, 1);
if (!retval) {
/* Key may be released while throwing the undefined index warning. */
zend_string_addref(str);
if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
zend_string_release(str);
return NULL;
}
retval = zend_hash_add_new(ht, str, &EG(uninitialized_zval));
zend_string_release(str);
retval = zend_undefined_index_write(ht, str);
}
return retval;
}
@ -300,10 +291,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_strin
if (_zend_handle_numeric_str_ex(str->val, str->len, &idx)) {
retval = zend_hash_index_find(ht, idx);
if (!retval) {
if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
return NULL;
}
retval = zend_hash_index_add_new(ht, idx, &EG(uninitialized_zval));
retval = zend_undefined_index_write(ht, str);
}
return retval;
}
@ -312,13 +300,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_strin
retval = zend_hash_find(ht, str);
if (!retval) {
/* Key may be released while throwing the undefined index warning. */
zend_string_addref(str);
if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
zend_string_release(str);
return NULL;
}
retval = zend_hash_add_new(ht, str, &EG(uninitialized_zval));
zend_string_release(str);
retval = zend_undefined_index_write(ht, str);
}
return retval;
}
@ -619,13 +601,7 @@ str_index:
retval = zend_hash_find(ht, offset_key);
if (!retval) {
/* Key may be released while throwing the undefined index warning. */
zend_string_addref(offset_key);
if (UNEXPECTED(zend_undefined_index_write(ht, offset_key) == FAILURE)) {
zend_string_release(offset_key);
return NULL;
}
retval = zend_hash_add_new(ht, offset_key, &EG(uninitialized_zval));
zend_string_release(offset_key);
retval = zend_undefined_index_write(ht, offset_key);
}
return retval;
@ -634,11 +610,7 @@ num_index:
return retval;
num_undef:
if (UNEXPECTED(zend_undefined_offset_write(ht, hval) == FAILURE)) {
return NULL;
}
retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
return retval;
return zend_undefined_offset_write(ht, hval);
}
static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim)