Skip to content

Commit fa5355b

Browse files
committed
Change zend_get_known_property_offset() into zend_get_known_property_info() and cleanup
1 parent 0e5d19b commit fa5355b

File tree

1 file changed

+42
-44
lines changed

1 file changed

+42
-44
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10819,56 +10819,53 @@ static int zend_jit_recv_init(dasm_State **Dst, const zend_op *opline, const zen
1081910819
return 1;
1082010820
}
1082110821

10822-
#define ZEND_WRONG_PROPERTY_OFFSET 0
10823-
10824-
static uint32_t zend_get_known_property_offset(zend_class_entry *ce, zend_string *member, zend_bool on_this, zend_string *filename, zend_property_info **prop_info)
10822+
static zend_property_info* zend_get_known_property_info(zend_class_entry *ce, zend_string *member, zend_bool on_this, zend_string *filename)
1082510823
{
10826-
zend_property_info *info;
10827-
10828-
*prop_info = NULL;
10824+
zend_property_info *info = NULL;
1082910825

1083010826
if (!ce || !(ce->ce_flags & ZEND_ACC_LINKED) || (ce->ce_flags & ZEND_ACC_TRAIT)) {
10831-
return ZEND_WRONG_PROPERTY_OFFSET;
10827+
return NULL;
1083210828
}
1083310829

10834-
if (ce->info.user.filename != filename) {
10835-
/* class declaration might be changed independently */
10836-
return ZEND_WRONG_PROPERTY_OFFSET;
10837-
}
10830+
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
10831+
if (ce->info.user.filename != filename) {
10832+
/* class declaration might be changed independently */
10833+
return NULL;
10834+
}
1083810835

10839-
if (ce->parent) {
10840-
zend_class_entry *parent = ce->parent;
10836+
if (ce->parent) {
10837+
zend_class_entry *parent = ce->parent;
1084110838

10842-
do {
10843-
if (parent->type == ZEND_INTERNAL_CLASS) {
10844-
break;
10845-
} else if (parent->info.user.filename != filename) {
10846-
/* some of parents class declarations might be changed independently */
10847-
/* TODO: this check may be not enough, because even
10848-
* in the same it's possible to conditionally define
10849-
* few classes with the same name, and "parent" may
10850-
* change from request to request.
10851-
*/
10852-
return ZEND_WRONG_PROPERTY_OFFSET;
10853-
}
10854-
parent = parent->parent;
10855-
} while (parent);
10839+
do {
10840+
if (parent->type == ZEND_INTERNAL_CLASS) {
10841+
break;
10842+
} else if (parent->info.user.filename != filename) {
10843+
/* some of parents class declarations might be changed independently */
10844+
/* TODO: this check may be not enough, because even
10845+
* in the same it's possible to conditionally define
10846+
* few classes with the same name, and "parent" may
10847+
* change from request to request.
10848+
*/
10849+
return NULL;
10850+
}
10851+
parent = parent->parent;
10852+
} while (parent);
10853+
}
1085610854
}
1085710855

1085810856
info = (zend_property_info*)zend_hash_find_ptr(&ce->properties_info, member);
1085910857
if (info == NULL ||
10860-
info->offset == ZEND_WRONG_PROPERTY_OFFSET ||
10858+
!IS_VALID_PROPERTY_OFFSET(info->offset) ||
1086110859
(info->flags & ZEND_ACC_STATIC)) {
10862-
return ZEND_WRONG_PROPERTY_OFFSET;
10860+
return NULL;
1086310861
}
1086410862

1086510863
if (!(info->flags & ZEND_ACC_PUBLIC) &&
1086610864
(!on_this || info->ce != ce)) {
10867-
return ZEND_WRONG_PROPERTY_OFFSET;
10865+
return NULL;
1086810866
}
1086910867

10870-
*prop_info = info;
10871-
return info->offset;
10868+
return info;
1087210869
}
1087310870

1087410871
static zend_bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string *member, zend_bool on_this, zend_string *filename)
@@ -10879,14 +10876,16 @@ static zend_bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string
1087910876
return 1;
1088010877
}
1088110878

10882-
if (ce->info.user.filename != filename) {
10883-
/* class declaration might be changed independently */
10884-
return 1;
10879+
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
10880+
if (ce->info.user.filename != filename) {
10881+
/* class declaration might be changed independently */
10882+
return 1;
10883+
}
1088510884
}
1088610885

1088710886
info = (zend_property_info*)zend_hash_find_ptr(&ce->properties_info, member);
1088810887
if (info == NULL ||
10889-
info->offset == ZEND_WRONG_PROPERTY_OFFSET ||
10888+
!IS_VALID_PROPERTY_OFFSET(info->offset) ||
1089010889
(info->flags & ZEND_ACC_STATIC)) {
1089110890
return 1;
1089210891
}
@@ -10902,7 +10901,6 @@ static zend_bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string
1090210901
static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, uint32_t op1_info, zend_jit_addr op1_addr, zend_bool op1_indirect, zend_class_entry *ce, zend_bool ce_is_instanceof, zend_bool use_this, int may_throw)
1090310902
{
1090410903
zval *member;
10905-
uint32_t offset;
1090610904
zend_property_info *prop_info;
1090710905
zend_bool may_be_dynamic = 1;
1090810906
zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
@@ -10914,7 +10912,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
1091410912

1091510913
member = RT_CONSTANT(opline, opline->op2);
1091610914
ZEND_ASSERT(Z_TYPE_P(member) == IS_STRING && Z_STRVAL_P(member)[0] != '\0');
10917-
offset = zend_get_known_property_offset(ce, Z_STR_P(member), opline->op1_type == IS_UNUSED, op_array->filename, &prop_info);
10915+
prop_info = zend_get_known_property_info(ce, Z_STR_P(member), opline->op1_type == IS_UNUSED, op_array->filename);
1091810916

1091910917
if (opline->op1_type == IS_UNUSED || use_this) {
1092010918
| GET_ZVAL_PTR FCARG1a, this_addr
@@ -10952,7 +10950,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
1095210950
| GET_ZVAL_PTR FCARG1a, op1_addr
1095310951
}
1095410952

10955-
if (offset == ZEND_WRONG_PROPERTY_OFFSET) {
10953+
if (!prop_info) {
1095610954
| mov r0, EX->run_time_cache
1095710955
| mov r2, aword [r0 + (opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS)]
1095810956
| cmp r2, aword [FCARG1a + offsetof(zend_object, ce)]
@@ -11004,8 +11002,8 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
1100411002
|.code
1100511003
}
1100611004
} else {
11007-
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, offset);
11008-
| mov edx, dword [FCARG1a + offset + 8]
11005+
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, prop_info->offset);
11006+
| mov edx, dword [FCARG1a + prop_info->offset + 8]
1100911007
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1101011008
int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM);
1101111009
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
@@ -11074,7 +11072,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
1107411072

1107511073
|.cold_code
1107611074

11077-
if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || offset == ZEND_WRONG_PROPERTY_OFFSET) {
11075+
if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || !prop_info) {
1107811076
|5:
1107911077
| SAVE_VALID_OPLINE opline, r0
1108011078
if (opline->opcode == ZEND_FETCH_OBJ_W) {
@@ -11120,7 +11118,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
1112011118
}
1112111119
}
1112211120

11123-
if (offset == ZEND_WRONG_PROPERTY_OFFSET
11121+
if (!prop_info
1112411122
&& may_be_dynamic
1112511123
&& opline->opcode != ZEND_FETCH_OBJ_W) {
1112611124
|8:
@@ -11155,7 +11153,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst, const zend_op *opline, const zen
1115511153
}
1115611154

1115711155
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE
11158-
&& offset != ZEND_WRONG_PROPERTY_OFFSET
11156+
&& prop_info
1115911157
&& opline->op1_type != IS_VAR
1116011158
&& opline->op1_type != IS_TMP_VAR) {
1116111159
may_throw = 0;

0 commit comments

Comments
 (0)