Skip to content

Commit c6e941f

Browse files
committed
Fix deoptimization on result type guard of FETCH_DIM_R and FETCH_OBJ_R
1 parent 8b55b01 commit c6e941f

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8168,18 +8168,31 @@ static int zend_jit_defined(zend_jit_ctx *jit, const zend_op *opline, zend_uchar
81688168

81698169
static int zend_jit_escape_if_undef(zend_jit_ctx *jit, int var, uint32_t flags, const zend_op *opline, int8_t reg)
81708170
{
8171-
#if ZEND_DEBUG
81728171
zend_jit_addr reg_addr = ZEND_ADDR_REF_ZVAL(zend_jit_deopt_rload(jit, IR_ADDR, reg));
81738172
ir_ref if_def = zend_jit_if(jit, zend_jit_zval_type(jit, reg_addr));
81748173

81758174
zend_jit_if_false_cold(jit, if_def);
8176-
jit->control = ir_emit1(&jit->ctx, IR_TRAP, jit->control); // NIY ???
8175+
8176+
if (flags & ZEND_JIT_EXIT_RESTORE_CALL) {
8177+
if (!zend_jit_save_call_chain(jit, -1)) {
8178+
return 0;
8179+
}
8180+
}
8181+
8182+
if ((opline-1)->opcode != ZEND_FETCH_CONSTANT
8183+
&& (opline-1)->opcode != ZEND_FETCH_LIST_R
8184+
&& ((opline-1)->op1_type & (IS_VAR|IS_TMP_VAR))
8185+
&& !(flags & ZEND_JIT_EXIT_FREE_OP1)) {
8186+
zend_jit_addr val_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, (opline-1)->op1.var);
8187+
8188+
zend_jit_zval_try_addref(jit, val_addr);
8189+
}
81778190

81788191
zend_jit_load_ip_addr(jit, opline - 1);
81798192
zend_jit_ijmp(jit, zend_jit_stub_addr(jit, jit_stub_trace_escape));
81808193

81818194
zend_jit_if_true(jit, if_def);
8182-
#endif
8195+
81838196
return 1;
81848197
}
81858198

ext/opcache/jit/zend_jit_trace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,8 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
28792879
&& STACK_REG(parent_stack, i) != ZREG_NONE
28802880
#ifndef ZEND_JIT_IR
28812881
&& STACK_REG(parent_stack, i) < ZREG_NUM
2882+
#else
2883+
&& STACK_FLAGS(parent_stack, i) != ZREG_ZVAL_COPY
28822884
#endif
28832885
) {
28842886
/* We will try to reuse register from parent trace */
@@ -4056,10 +4058,10 @@ static int zend_jit_trace_deoptimization(
40564058

40574059
ZEND_ASSERT(STACK_FLAGS(parent_stack, check2) == ZREG_ZVAL_COPY);
40584060
ZEND_ASSERT(reg != ZREG_NONE);
4059-
if (zend_jit_escape_if_undef(jit, check2, flags, opline, reg)) {
4061+
if (!zend_jit_escape_if_undef(jit, check2, flags, opline, reg)) {
40604062
return 0;
40614063
}
4062-
if (!zend_jit_restore_zval(jit, check2, reg)) {
4064+
if (!zend_jit_restore_zval(jit, EX_NUM_TO_VAR(check2), reg)) {
40634065
return 0;
40644066
}
40654067
}

0 commit comments

Comments
 (0)