Skip to content

Commit e7e79aa

Browse files
committed
Delay IS_ERROR checks
1 parent 4138db0 commit e7e79aa

File tree

3 files changed

+188
-393
lines changed

3 files changed

+188
-393
lines changed

Zend/zend_execute.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,11 +1950,6 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
19501950
{
19511951
if (container_op_type != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
19521952
do {
1953-
if (container_op_type == IS_VAR && UNEXPECTED(Z_ISERROR_P(container))) {
1954-
ZVAL_ERROR(result);
1955-
return;
1956-
}
1957-
19581953
if (Z_ISREF_P(container)) {
19591954
container = Z_REFVAL_P(container);
19601955
if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
@@ -1969,7 +1964,9 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
19691964
zval_ptr_dtor_nogc(container);
19701965
object_init(container);
19711966
} else {
1972-
zend_error(E_WARNING, "Attempt to modify property of non-object");
1967+
if (container_op_type != IS_VAR || EXPECTED(!Z_ISERROR_P(container))) {
1968+
zend_error(E_WARNING, "Attempt to modify property of non-object");
1969+
}
19731970
ZVAL_ERROR(result);
19741971
return;
19751972
}
@@ -2005,6 +2002,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
20052002
zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot);
20062003
if (NULL == ptr) {
20072004
if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
2005+
use_read_property:
20082006
ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result);
20092007
if (ptr != result) {
20102008
ZVAL_INDIRECT(result, ptr);
@@ -2019,12 +2017,7 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
20192017
ZVAL_INDIRECT(result, ptr);
20202018
}
20212019
} else if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
2022-
zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result);
2023-
if (ptr != result) {
2024-
ZVAL_INDIRECT(result, ptr);
2025-
} else if (UNEXPECTED(Z_ISREF_P(ptr) && Z_REFCOUNT_P(ptr) == 1)) {
2026-
ZVAL_UNREF(ptr);
2027-
}
2020+
goto use_read_property;
20282021
} else {
20292022
zend_error(E_WARNING, "This object doesn't support property references");
20302023
ZVAL_ERROR(result);

Zend/zend_vm_def.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -839,11 +839,10 @@ ZEND_VM_C_LABEL(assign_dim_op_convert_to_array):
839839
zend_check_string_offset(dim, BP_VAR_RW);
840840
zend_wrong_string_offset();
841841
}
842+
} else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
843+
ZEND_VM_C_GOTO(assign_dim_op_convert_to_array);
842844
} else {
843-
if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
844-
ZEND_VM_C_GOTO(assign_dim_op_convert_to_array);
845-
}
846-
if (UNEXPECTED(OP1_TYPE != IS_VAR || !Z_ISERROR_P(container))) {
845+
if (UNEXPECTED(OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(container)))) {
847846
zend_error(E_WARNING, "Cannot use a scalar value as an array");
848847
}
849848
ZEND_VM_C_LABEL(assign_dim_op_ret_null):
@@ -2159,13 +2158,6 @@ ZEND_VM_HANDLER(136, ZEND_ASSIGN_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, SPEC(
21592158

21602159
if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
21612160
do {
2162-
if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(object))) {
2163-
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2164-
ZVAL_NULL(EX_VAR(opline->result.var));
2165-
}
2166-
FREE_OP_DATA();
2167-
ZEND_VM_C_GOTO(exit_assign_obj);
2168-
}
21692161
if (Z_ISREF_P(object)) {
21702162
object = Z_REFVAL_P(object);
21712163
if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) {
@@ -2192,7 +2184,9 @@ ZEND_VM_HANDLER(136, ZEND_ASSIGN_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, SPEC(
21922184
}
21932185
Z_DELREF_P(object);
21942186
} else {
2195-
zend_error(E_WARNING, "Attempt to assign property of non-object");
2187+
if (OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(object))) {
2188+
zend_error(E_WARNING, "Attempt to assign property of non-object");
2189+
}
21962190
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
21972191
ZVAL_NULL(EX_VAR(opline->result.var));
21982192
}
@@ -2373,7 +2367,7 @@ ZEND_VM_C_LABEL(try_assign_dim_array):
23732367
zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0);
23742368
ZEND_VM_C_GOTO(try_assign_dim_array);
23752369
} else {
2376-
if (OP1_TYPE != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
2370+
if (OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) {
23772371
zend_error(E_WARNING, "Cannot use a scalar value as an array");
23782372
}
23792373
dim = GET_OP2_ZVAL_PTR(BP_VAR_R);

0 commit comments

Comments
 (0)