@@ -758,6 +758,16 @@ static void* dasm_labels[zend_lb_MAX];
758
758
|| }
759
759
|.endmacro
760
760
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
+
761
771
|.macro LONG_OP_WITH_CONST, long_ins, op1_addr, lval
762
772
|| if (Z_MODE(op1_addr) == IS_MEM_ZVAL) {
763
773
| .if X64
@@ -3643,9 +3653,9 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, const zend_
3643
3653
return 0;
3644
3654
}
3645
3655
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)
3647
3657
} 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)
3649
3659
}
3650
3660
3651
3661
if (may_overflow &&
@@ -12306,6 +12316,8 @@ static zend_bool zend_needs_extra_reg_for_const(const zend_op *opline, zend_ucha
12306
12316
|| zval *zv = RT_CONSTANT(opline, op);
12307
12317
|| if (Z_TYPE_P(zv) == IS_DOUBLE && Z_DVAL_P(zv) != 0 && !IS_32BIT(zv)) {
12308
12318
|| return 1;
12319
+ || } else if (Z_TYPE_P(zv) == IS_LONG && !IS_SIGNED_32BIT(Z_LVAL_P(zv))) {
12320
+ || return 1;
12309
12321
|| }
12310
12322
|| }
12311
12323
|.endif
@@ -12454,8 +12466,12 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
12454
12466
}
12455
12467
}
12456
12468
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
+ }
12459
12475
}
12460
12476
}
12461
12477
break;
@@ -12471,6 +12487,14 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
12471
12487
(ssa_op->op1_use != current_var || !last_use)) {
12472
12488
ZEND_REGSET_INCL(regset, ZREG_R0);
12473
12489
}
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
+ }
12474
12498
}
12475
12499
break;
12476
12500
case ZEND_SL:
@@ -12502,6 +12526,14 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
12502
12526
(ssa_op->op1_use != current_var || !last_use)) {
12503
12527
ZEND_REGSET_INCL(regset, ZREG_R0);
12504
12528
}
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
+ }
12505
12537
} else {
12506
12538
ZEND_REGSET_INCL(regset, ZREG_R0);
12507
12539
ZEND_REGSET_INCL(regset, ZREG_R1);
@@ -12540,7 +12572,7 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
12540
12572
}
12541
12573
}
12542
12574
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)) {
12544
12576
ZEND_REGSET_INCL(regset, ZREG_R0);
12545
12577
}
12546
12578
}
@@ -12588,23 +12620,33 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
12588
12620
}
12589
12621
}
12590
12622
12591
- #if ZTS
12592
12623
/* %r0 is used to check EG(vm_interrupt) */
12593
12624
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
12594
12625
if (ssa_op == ssa->ops
12595
12626
&& (JIT_G(current_trace)->stop == ZEND_JIT_TRACE_STOP_LOOP ||
12596
12627
JIT_G(current_trace)->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL)) {
12628
+ #if ZTS
12597
12629
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
12598
12635
}
12599
12636
} else {
12600
12637
uint32_t b = ssa->cfg.map[ssa_op - ssa->ops];
12601
12638
12602
12639
if ((ssa->cfg.blocks[b].flags & ZEND_BB_LOOP_HEADER) != 0
12603
12640
&& ssa->cfg.blocks[b].start == ssa_op - ssa->ops) {
12641
+ #if ZTS
12604
12642
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
12605
12648
}
12606
12649
}
12607
- #endif
12608
12650
12609
12651
return regset;
12610
12652
}
0 commit comments