Skip to content

Commit d7fc3ab

Browse files
committed
Fixed GH-12585: Assertion t->stack_map[t->exit_info[exit_point].stack_offset + var].type == 4
1 parent d35faec commit d7fc3ab

File tree

2 files changed

+45
-18
lines changed

2 files changed

+45
-18
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,9 +2850,11 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
28502850
}
28512851

28522852
if (ssa_op->op1_use >= 0
2853-
&& RA_HAS_IVAL(ssa_op->op1_use)
2854-
&& !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) {
2855-
if (support_opline) {
2853+
&& RA_HAS_IVAL(ssa_op->op1_use)) {
2854+
if (!support_opline) {
2855+
RA_IVAL_DEL(ssa_op->op1_use);
2856+
count--;
2857+
} else if (!zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) {
28562858
zend_jit_trace_use_var(idx, ssa_op->op1_use, ssa_op->op1_def, ssa_op->op1_use_chain,
28572859
ra,
28582860
ssa, ssa_opcodes, op_array, op_array_ssa);
@@ -2876,41 +2878,36 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
28762878
RA_IVAL_FLAGS(ssa_op->op1_use) |= ZREG_LAST_USE;
28772879
}
28782880
}
2879-
} else {
2880-
RA_IVAL_DEL(ssa_op->op1_use);
2881-
count--;
28822881
}
28832882
}
28842883
if (ssa_op->op2_use >= 0
28852884
&& ssa_op->op2_use != ssa_op->op1_use
2886-
&& RA_HAS_IVAL(ssa_op->op2_use)
2887-
&& !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op2_use)) {
2885+
&& RA_HAS_IVAL(ssa_op->op2_use)) {
28882886
/* Quick workaround to disable register allocation for unsupported operand */
28892887
// TODO: Find a general solution ???
2890-
if (support_opline && opline->opcode != ZEND_FETCH_DIM_R) {
2888+
if (!support_opline || opline->opcode == ZEND_FETCH_DIM_R) {
2889+
RA_IVAL_DEL(ssa_op->op2_use);
2890+
count--;
2891+
} else if (!zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op2_use)) {
28912892
zend_jit_trace_use_var(idx, ssa_op->op2_use, ssa_op->op2_def, ssa_op->op2_use_chain,
28922893
ra,
28932894
ssa, ssa_opcodes, op_array, op_array_ssa);
28942895
if (opline->op2_type != IS_CV) {
28952896
RA_IVAL_FLAGS(ssa_op->op2_use) |= ZREG_LAST_USE;
28962897
}
2897-
} else {
2898-
RA_IVAL_DEL(ssa_op->op2_use);
2899-
count--;
29002898
}
29012899
}
29022900
if (ssa_op->result_use >= 0
29032901
&& ssa_op->result_use != ssa_op->op1_use
29042902
&& ssa_op->result_use != ssa_op->op2_use
2905-
&& RA_HAS_IVAL(ssa_op->result_use)
2906-
&& !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->result_use)) {
2907-
if (support_opline) {
2903+
&& RA_HAS_IVAL(ssa_op->result_use)) {
2904+
if (!support_opline) {
2905+
RA_IVAL_DEL(ssa_op->result_use);
2906+
count--;
2907+
} else if (!zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->result_use)) {
29082908
zend_jit_trace_use_var(idx, ssa_op->result_use, ssa_op->result_def, ssa_op->res_use_chain,
29092909
ra,
29102910
ssa, ssa_opcodes, op_array, op_array_ssa);
2911-
} else {
2912-
RA_IVAL_DEL(ssa_op->result_use);
2913-
count--;
29142911
}
29152912
}
29162913

ext/opcache/tests/jit/gh12585.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
GH-12585: Assertion t->stack_map[t->exit_info[exit_point].stack_offset + var].type == 4
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit_hot_func=1
7+
opcache.jit_hot_loop=1
8+
opcache.jit_hot_return=1
9+
opcache.jit_hot_side_exit=1
10+
opcache.jit=1152
11+
--FILE--
12+
<?php
13+
class MyDatePeriod extends DatePeriod
14+
{
15+
public function __construct(
16+
DateTimeInterface $start,
17+
DateInterval $interval,
18+
int $recurrences,
19+
int $options = 0,
20+
public ?bool $myProperty = null,
21+
) {
22+
parent::__construct($start, $interval, $recurrences, $options);
23+
}
24+
}
25+
26+
$d = new MyDatePeriod(new DateTimeImmutable(), new DateInterval("PT5S"), 5, myProperty: true);
27+
?>
28+
DONE
29+
--EXPECT--
30+
DONE

0 commit comments

Comments
 (0)