Skip to content

Commit e527478

Browse files
committed
Fixed support for 64-bit constants
1 parent 33ddc3b commit e527478

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,16 @@ static void* dasm_labels[zend_lb_MAX];
758758
|| }
759759
|.endmacro
760760

761+
|.macro LONG_OP_WITH_32BIT_CONST, long_ins, op1_addr, lval
762+
|| if (Z_MODE(op1_addr) == IS_MEM_ZVAL) {
763+
| long_ins aword [Ra(Z_REG(op1_addr))+Z_OFFSET(op1_addr)], lval
764+
|| } else if (Z_MODE(op1_addr) == IS_REG) {
765+
| long_ins Ra(Z_REG(op1_addr)), lval
766+
|| } else {
767+
|| ZEND_UNREACHABLE();
768+
|| }
769+
|.endmacro
770+
761771
|.macro LONG_OP_WITH_CONST, long_ins, op1_addr, lval
762772
|| if (Z_MODE(op1_addr) == IS_MEM_ZVAL) {
763773
| .if X64
@@ -3643,9 +3653,9 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_
36433653
return 0;
36443654
}
36453655
if (opline->opcode == ZEND_PRE_INC || opline->opcode == ZEND_POST_INC) {
3646-
| LONG_OP_WITH_CONST add, op1_def_addr, Z_L(1)
3656+
| LONG_OP_WITH_32BIT_CONST add, op1_def_addr, Z_L(1)
36473657
} else {
3648-
| LONG_OP_WITH_CONST sub, op1_def_addr, Z_L(1)
3658+
| LONG_OP_WITH_32BIT_CONST sub, op1_def_addr, Z_L(1)
36493659
}
36503660

36513661
if (may_overflow &&
@@ -12306,6 +12316,8 @@ static zend_bool zend_needs_extra_reg_for_const(const zend_op *opline, zend_ucha
1230612316
|| zval *zv = RT_CONSTANT(opline, op);
1230712317
|| if (Z_TYPE_P(zv) == IS_DOUBLE && Z_DVAL_P(zv) != 0 && !IS_32BIT(zv)) {
1230812318
|| return 1;
12319+
|| } else if (Z_TYPE_P(zv) == IS_LONG && !IS_SIGNED_32BIT(Z_LVAL_P(zv))) {
12320+
|| return 1;
1230912321
|| }
1231012322
|| }
1231112323
|.endif
@@ -12454,8 +12466,12 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1245412466
}
1245512467
}
1245612468
if (zend_needs_extra_reg_for_const(opline, opline->op1_type, opline->op1) ||
12457-
zend_needs_extra_reg_for_const(opline, opline->op1_type, opline->op2)) {
12458-
ZEND_REGSET_INCL(regset, ZREG_R0);
12469+
zend_needs_extra_reg_for_const(opline, opline->op2_type, opline->op2)) {
12470+
if (!ZEND_REGSET_IN(regset, ZREG_R0)) {
12471+
ZEND_REGSET_INCL(regset, ZREG_R0);
12472+
} else {
12473+
ZEND_REGSET_INCL(regset, ZREG_R1);
12474+
}
1245912475
}
1246012476
}
1246112477
break;
@@ -12471,6 +12487,14 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1247112487
(ssa_op->op1_use != current_var || !last_use)) {
1247212488
ZEND_REGSET_INCL(regset, ZREG_R0);
1247312489
}
12490+
if (zend_needs_extra_reg_for_const(opline, opline->op1_type, opline->op1) ||
12491+
zend_needs_extra_reg_for_const(opline, opline->op2_type, opline->op2)) {
12492+
if (!ZEND_REGSET_IN(regset, ZREG_R0)) {
12493+
ZEND_REGSET_INCL(regset, ZREG_R0);
12494+
} else {
12495+
ZEND_REGSET_INCL(regset, ZREG_R1);
12496+
}
12497+
}
1247412498
}
1247512499
break;
1247612500
case ZEND_SL:
@@ -12502,6 +12526,14 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1250212526
(ssa_op->op1_use != current_var || !last_use)) {
1250312527
ZEND_REGSET_INCL(regset, ZREG_R0);
1250412528
}
12529+
if (sizeof(void*) == 8
12530+
&& !IS_SIGNED_32BIT(Z_LVAL_P(RT_CONSTANT(opline, opline->op2)) - 1)) {
12531+
if (!ZEND_REGSET_IN(regset, ZREG_R0)) {
12532+
ZEND_REGSET_INCL(regset, ZREG_R0);
12533+
} else {
12534+
ZEND_REGSET_INCL(regset, ZREG_R1);
12535+
}
12536+
}
1250512537
} else {
1250612538
ZEND_REGSET_INCL(regset, ZREG_R0);
1250712539
ZEND_REGSET_INCL(regset, ZREG_R1);
@@ -12540,7 +12572,7 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1254012572
}
1254112573
}
1254212574
if (zend_needs_extra_reg_for_const(opline, opline->op1_type, opline->op1) ||
12543-
zend_needs_extra_reg_for_const(opline, opline->op1_type, opline->op2)) {
12575+
zend_needs_extra_reg_for_const(opline, opline->op2_type, opline->op2)) {
1254412576
ZEND_REGSET_INCL(regset, ZREG_R0);
1254512577
}
1254612578
}
@@ -12588,23 +12620,33 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1258812620
}
1258912621
}
1259012622

12591-
#if ZTS
1259212623
/* %r0 is used to check EG(vm_interrupt) */
1259312624
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1259412625
if (ssa_op == ssa->ops
1259512626
&& (JIT_G(current_trace)->stop == ZEND_JIT_TRACE_STOP_LOOP ||
1259612627
JIT_G(current_trace)->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL)) {
12628+
#if ZTS
1259712629
ZEND_REGSET_INCL(regset, ZREG_R0);
12630+
#else
12631+
if ((sizeof(void*) == 8 && !IS_32BIT(&EG(vm_interrupt)))) {
12632+
ZEND_REGSET_INCL(regset, ZREG_R0);
12633+
}
12634+
#endif
1259812635
}
1259912636
} else {
1260012637
uint32_t b = ssa->cfg.map[ssa_op - ssa->ops];
1260112638

1260212639
if ((ssa->cfg.blocks[b].flags & ZEND_BB_LOOP_HEADER) != 0
1260312640
&& ssa->cfg.blocks[b].start == ssa_op - ssa->ops) {
12641+
#if ZTS
1260412642
ZEND_REGSET_INCL(regset, ZREG_R0);
12643+
#else
12644+
if ((sizeof(void*) == 8 && !IS_32BIT(&EG(vm_interrupt)))) {
12645+
ZEND_REGSET_INCL(regset, ZREG_R0);
12646+
}
12647+
#endif
1260512648
}
1260612649
}
12607-
#endif
1260812650

1260912651
return regset;
1261012652
}

0 commit comments

Comments
 (0)