Skip to content

Commit 0f8518f

Browse files
committed
Fixed register allocation
1 parent 838d8d0 commit 0f8518f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,15 @@ static int zend_jit_try_allocate_free_reg(const zend_op_array *op_array, const z
15601560
if (ssa->ops[line].op1_def == current->ssa_var ||
15611561
ssa->ops[line].op2_def == current->ssa_var ||
15621562
ssa->ops[line].result_def == current->ssa_var) {
1563+
regset = zend_jit_get_def_scratch_regset(
1564+
ssa_opcodes ? ssa_opcodes[line] : op_array->opcodes + line,
1565+
ssa->ops + line,
1566+
op_array, ssa, current->ssa_var, line == last_use_line);
1567+
ZEND_REGSET_FOREACH(regset, reg) {
1568+
if (line < freeUntilPos[reg]) {
1569+
freeUntilPos[reg] = line;
1570+
}
1571+
} ZEND_REGSET_FOREACH_END();
15631572
line++;
15641573
}
15651574
while (line <= range->end) {

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15162,6 +15162,28 @@ static zend_bool zend_needs_extra_reg_for_const(const zend_op *opline, zend_ucha
1516215162
return 0;
1516315163
}
1516415164

15165+
static zend_regset zend_jit_get_def_scratch_regset(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, int current_var, zend_bool last_use)
15166+
{
15167+
uint32_t op1_info, op2_info;
15168+
15169+
switch (opline->opcode) {
15170+
case ZEND_FETCH_DIM_R:
15171+
op1_info = OP1_INFO();
15172+
op2_info = OP2_INFO();
15173+
if (((opline->op1_type & (IS_TMP_VAR|IS_VAR)) &&
15174+
(op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) ||
15175+
((opline->op2_type & (IS_TMP_VAR|IS_VAR)) &&
15176+
(op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)))) {
15177+
return ZEND_REGSET(ZREG_FCARG1a);
15178+
}
15179+
break;
15180+
default:
15181+
break;
15182+
}
15183+
15184+
return ZEND_REGSET_EMPTY;
15185+
}
15186+
1516515187
static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, int current_var, zend_bool last_use)
1516615188
{
1516715189
uint32_t op1_info, op2_info, res_info;

0 commit comments

Comments
 (0)