From: Dmitry Stogov Date: Tue, 18 Aug 2020 18:10:34 +0000 (+0300) Subject: Fixed register allocation for CASE instruction. CASE don't destroy first operand... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2d84888066146ebaa3feaafaee35b29fa497c25;p=php Fixed register allocation for CASE instruction. CASE don't destroy first operand and it may be used later in VM or different trace. --- diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index b2541d0346..b331b89527 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -2105,6 +2105,10 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) { if (support_opline) { zend_jit_trace_use_var(idx, ssa_op->op1_use, ssa_op->op1_def, ssa_op->op1_use_chain, start, end, flags, ssa, ssa_opcodes, op_array, op_array_ssa); + if (opline->opcode == ZEND_CASE && opline->op1_type != IS_CV) { + /* The value may be used outside of the trace */ + flags[ssa_op->op1_use] |= ZREG_STORE; + } } else { start[ssa_op->op1_use] = -1; end[ssa_op->op1_use] = -1; diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index b92783c109..cdae709b31 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -10676,6 +10676,9 @@ static int zend_jit_fetch_dim_read(dasm_State **Dst, const zend_op *opline, cons if (!(res_info & AVOID_REFCOUNTING)) { | TRY_ADDREF res_info, ch, r2 } + if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) { + return 0; + } } else if (op1_info & MAY_BE_ARRAY_OF_REF) { | // ZVAL_COPY_DEREF | GET_ZVAL_TYPE_INFO Rd(ZREG_R2), val_addr