Skip to content

Commit ccd0348

Browse files
committed
Eliminate repeatable class guards and unnecessary IS_UNDEF property checks
1 parent 79efbb1 commit ccd0348

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11995,12 +11995,16 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1199511995
if (!prop_info && trace_ce && (trace_ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
1199611996
prop_info = zend_get_known_property_info(trace_ce, Z_STR_P(member), opline->op1_type == IS_UNUSED, op_array->filename);
1199711997
if (prop_info) {
11998+
ce = trace_ce;
11999+
ce_is_instanceof = 0;
1199812000
if (!(op1_info & MAY_BE_CLASS_GUARD)) {
1199912001
if (!zend_jit_class_guard(Dst, opline, trace_ce)) {
1200012002
return 0;
1200112003
}
1200212004
if (ssa->var_info && ssa_op->op1_use >= 0) {
1200312005
ssa->var_info[ssa_op->op1_use].type |= MAY_BE_CLASS_GUARD;
12006+
ssa->var_info[ssa_op->op1_use].ce = ce;
12007+
ssa->var_info[ssa_op->op1_use].is_instanceof = ce_is_instanceof;
1200412008
}
1200512009
}
1200612010
}
@@ -12322,6 +12326,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1232212326
zend_jit_addr res_addr = 0;
1232312327
zend_jit_addr this_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, offsetof(zend_execute_data, This));
1232412328
zend_jit_addr prop_addr;
12329+
zend_bool needs_slow_path = 0;
1232512330

1232612331
if (RETURN_VALUE_USED(opline)) {
1232712332
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
@@ -12399,12 +12404,21 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1239912404
}
1240012405
if (ssa->var_info && ssa_op->op1_use >= 0) {
1240112406
ssa->var_info[ssa_op->op1_use].type |= MAY_BE_CLASS_GUARD;
12407+
ssa->var_info[ssa_op->op1_use].ce = ce;
12408+
ssa->var_info[ssa_op->op1_use].is_instanceof = ce_is_instanceof;
12409+
}
12410+
if (ssa->var_info && ssa_op->op1_def >= 0) {
12411+
ssa->var_info[ssa_op->op1_def].type |= MAY_BE_CLASS_GUARD;
12412+
ssa->var_info[ssa_op->op1_def].ce = ce;
12413+
ssa->var_info[ssa_op->op1_def].is_instanceof = ce_is_instanceof;
1240212414
}
1240312415
}
1240412416
}
1240512417
}
1240612418

1240712419
if (!prop_info) {
12420+
needs_slow_path = 1;
12421+
1240812422
| mov r0, EX->run_time_cache
1240912423
| mov r2, aword [r0 + opline->extended_value]
1241012424
| cmp r2, aword [FCARG1a + offsetof(zend_object, ce)]
@@ -12464,17 +12478,20 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1246412478
}
1246512479
} else {
1246612480
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, prop_info->offset);
12467-
// Undefined property with magic __get()/__set()
12468-
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
12469-
int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM);
12470-
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
12481+
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set) {
12482+
// Undefined property with magic __get()/__set()
12483+
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
12484+
int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM);
12485+
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
1247112486

12472-
if (!exit_addr) {
12473-
return 0;
12487+
if (!exit_addr) {
12488+
return 0;
12489+
}
12490+
| IF_TYPE byte [FCARG1a + prop_info->offset + 8], IS_UNDEF, &exit_addr
12491+
} else {
12492+
| IF_TYPE byte [FCARG1a + prop_info->offset + 8], IS_UNDEF, >5
12493+
needs_slow_path = 1;
1247412494
}
12475-
| IF_TYPE byte [FCARG1a + prop_info->offset + 8], IS_UNDEF, &exit_addr
12476-
} else {
12477-
| IF_TYPE byte [FCARG1a + prop_info->offset + 8], IS_UNDEF, >5
1247812495
}
1247912496
if (ZEND_TYPE_IS_SET(prop_info->type)) {
1248012497
uint32_t info = val_info;
@@ -12536,7 +12553,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1253612553
}
1253712554
}
1253812555

12539-
if (!prop_info || JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE) {
12556+
if (needs_slow_path) {
1254012557
|.cold_code
1254112558
|5:
1254212559
| SET_EX_OPLINE opline, r0

0 commit comments

Comments
 (0)