Skip to content

Commit 7690fa0

Browse files
committed
JIT: Better code for ADD/SUB/MUL and references in tracing JIT.
1 parent c19e4b9 commit 7690fa0

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

ext/opcache/jit/zend_jit_trace.c

+32-4
Original file line numberDiff line numberDiff line change
@@ -4208,9 +4208,37 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42084208
case ZEND_MUL:
42094209
// case ZEND_DIV: // TODO: check for division by zero ???
42104210
op1_info = OP1_INFO();
4211-
CHECK_OP1_TRACE_TYPE();
4211+
op1_addr = OP1_REG_ADDR();
4212+
if (opline->op1_type != IS_CONST
4213+
&& orig_op1_type != IS_UNKNOWN
4214+
&& (orig_op1_type & IS_TRACE_REFERENCE)) {
4215+
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr,
4216+
!ssa->var_info[ssa_op->op1_use].guarded_reference, 1)) {
4217+
goto jit_failure;
4218+
}
4219+
if (opline->op1_type == IS_CV
4220+
&& ssa->vars[ssa_op->op1_use].alias == NO_ALIAS) {
4221+
ssa->var_info[ssa_op->op1_use].guarded_reference = 1;
4222+
}
4223+
} else {
4224+
CHECK_OP1_TRACE_TYPE();
4225+
}
42124226
op2_info = OP2_INFO();
4213-
CHECK_OP2_TRACE_TYPE();
4227+
op2_addr = OP2_REG_ADDR();
4228+
if (opline->op2_type != IS_CONST
4229+
&& orig_op2_type != IS_UNKNOWN
4230+
&& (orig_op2_type & IS_TRACE_REFERENCE)) {
4231+
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op2_type, &op2_info, &op2_addr,
4232+
!ssa->var_info[ssa_op->op2_use].guarded_reference, 1)) {
4233+
goto jit_failure;
4234+
}
4235+
if (opline->op2_type == IS_CV
4236+
&& ssa->vars[ssa_op->op2_use].alias == NO_ALIAS) {
4237+
ssa->var_info[ssa_op->op2_use].guarded_reference = 1;
4238+
}
4239+
} else {
4240+
CHECK_OP2_TRACE_TYPE();
4241+
}
42144242
if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) {
42154243
break;
42164244
}
@@ -4245,8 +4273,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42454273
}
42464274
} else {
42474275
if (!zend_jit_math(&dasm_state, opline,
4248-
op1_info, OP1_REG_ADDR(),
4249-
op2_info, OP2_REG_ADDR(),
4276+
op1_info, op1_addr,
4277+
op2_info, op2_addr,
42504278
res_use_info, res_info, res_addr,
42514279
(op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (res_info & (MAY_BE_DOUBLE|MAY_BE_GUARD)) && zend_may_overflow(opline, ssa_op, op_array, ssa),
42524280
zend_may_throw(opline, ssa_op, op_array, ssa))) {

0 commit comments

Comments
 (0)