Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2934,9 +2934,12 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
if (support_opline
&& opline->opcode == ZEND_ASSIGN
&& opline->op1_type == IS_CV
&& ssa_op->op1_def >= 0
&& ssa->vars[ssa_op->op1_def].alias != NO_ALIAS) {
/* avoid register allocation in case of possibility of indirect modification*/
&& ((ssa_op->op1_def >= 0
&& ssa->vars[ssa_op->op1_def].alias != NO_ALIAS)
|| (p->op1_type != IS_UNKNOWN
&& (p->op1_type & IS_TRACE_REFERENCE)))) {
/* avoid register allocation in case of possibility of indirect modification
* or assignment through a (possibly typed) reference */
support_opline = 0;
}

Expand Down
36 changes: 36 additions & 0 deletions ext/opcache/tests/jit/assign_typed_ref_reg_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
JIT ASSIGN: result must not be register-allocated when op1 is traced as a reference
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.jit_buffer_size=64M
opcache.jit_hot_loop=1
opcache.jit_hot_side_exit=1
--EXTENSIONS--
opcache
--FILE--
<?php
function test() {
for ($i = 0; $i < 100; $i++) {
+$a = +$a .= $a + $a .= +$x;
$x = &$a + $x++;
}
}
try {
test();
} catch (Throwable $e) {
echo get_class($e), ": ", $e->getMessage(), "\n";
}
?>
--EXPECTF--
Warning: Undefined variable $x in %s on line %d

Warning: Undefined variable $a in %s on line %d

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
TypeError: Unsupported operand types: string + string
Loading