Skip to content

Commit f1f4403

Browse files
committed
Fixed register allocation when ADD/SUB/MUL two references in tracing JIT
The bug was introdueced by 7690fa0 and leaded to failure in `make test TESTS="-d opcache.jit=1254 --repeat 3 ext/date/tests/bug30096.phpt"`
1 parent d3a6054 commit f1f4403

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ const char* zend_reg_name[] = {
9999
#define ZREG_FCARG1x ZREG_X0
100100
#define ZREG_FCARG2x ZREG_X1
101101

102+
#define ZREG_FCARG1 ZREG_FCARG1x
103+
#define ZREG_FCARG2 ZREG_FCARG2x
104+
102105
|.type EX, zend_execute_data, FP
103106
|.type OP, zend_op
104107
|.type ZVAL, zval

ext/opcache/jit/zend_jit_trace.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4209,9 +4209,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42094209
// case ZEND_DIV: // TODO: check for division by zero ???
42104210
op1_info = OP1_INFO();
42114211
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)) {
4212+
op2_info = OP2_INFO();
4213+
op2_addr = OP2_REG_ADDR();
4214+
if (orig_op1_type != IS_UNKNOWN
4215+
&& (orig_op1_type & IS_TRACE_REFERENCE)
4216+
&& (Z_MODE(op2_addr) != IS_REG || Z_REG(op2_addr) != ZREG_FCARG1)
4217+
&& (orig_op2_type == IS_UNKNOWN || !(orig_op2_type & IS_TRACE_REFERENCE))) {
42154218
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr,
42164219
!ssa->var_info[ssa_op->op1_use].guarded_reference, 1)) {
42174220
goto jit_failure;
@@ -4223,11 +4226,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42234226
} else {
42244227
CHECK_OP1_TRACE_TYPE();
42254228
}
4226-
op2_info = OP2_INFO();
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)) {
4229+
if (orig_op2_type != IS_UNKNOWN
4230+
&& (orig_op2_type & IS_TRACE_REFERENCE)
4231+
&& (Z_MODE(op1_addr) != IS_REG || Z_REG(op1_addr) != ZREG_FCARG1)
4232+
&& (orig_op1_type == IS_UNKNOWN || !(orig_op1_type & IS_TRACE_REFERENCE))) {
42314233
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op2_type, &op2_info, &op2_addr,
42324234
!ssa->var_info[ssa_op->op2_use].guarded_reference, 1)) {
42334235
goto jit_failure;

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ const char* zend_reg_name[] = {
133133
# define ZREG_FCARG2a ZREG_RDX
134134
#endif
135135

136+
#define ZREG_FCARG1 ZREG_FCARG1a
137+
#define ZREG_FCARG2 ZREG_FCARG2a
138+
136139
|.type EX, zend_execute_data, FP
137140
|.type OP, zend_op
138141
|.type ZVAL, zval

0 commit comments

Comments
 (0)