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
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4493,7 +4493,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
} else if (opline->result_type != IS_UNUSED
&& (res_info & (MAY_BE_ANY|MAY_BE_GUARD)) == (MAY_BE_DOUBLE|MAY_BE_GUARD)
&& !(res_info & MAY_BE_STRING)) {
&& !(op1_info & MAY_BE_STRING)) {
ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
}
goto done;
Expand Down
43 changes: 43 additions & 0 deletions ext/opcache/tests/jit/inc_025.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--TEST--
JIT INC: 025 (result type of ++/-- on a reference after the trace saw a float)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.protect_memory=1
opcache.jit=tracing
--EXTENSIONS--
opcache
--FILE--
<?php
function pre_inc($a) { $v = $a; $x = &$v; $out = []; for ($i = 0; $i < 4; $i++) { $out[] = ++$x; } return $out; }
function post_inc($a) { $v = $a; $x = &$v; $out = []; for ($i = 0; $i < 4; $i++) { $out[] = $x++; } return $out; }
function pre_dec($a) { $v = $a; $x = &$v; $out = []; for ($i = 0; $i < 4; $i++) { $out[] = --$x; } return $out; }
function glob_inc($a) { global $g; $g = $a; $out = []; for ($i = 0; $i < 4; $i++) { $out[] = ++$g; } return $out; }
function stat_inc($a) { static $s; $s = $a; $out = []; for ($i = 0; $i < 4; $i++) { $out[] = ++$s; } return $out; }

class P { public float|string $t = ''; }
function typed_ref_inc($a) {
$o = new P; $o->t = $a; $x = &$o->t; $out = [];
for ($i = 0; $i < 4; $i++) { $out[] = $x++; }
return $out;
}

foreach (['pre_inc', 'post_inc', 'pre_dec', 'glob_inc', 'stat_inc'] as $f) {
for ($n = 0; $n < 20; $n++) {
$f(1.5);
}
echo $f, ' ', json_encode($f(5)), "\n";
}
for ($n = 0; $n < 20; $n++) {
typed_ref_inc(1.5);
}
echo 'typed_ref_inc ', json_encode(typed_ref_inc("2.5")), "\n";
?>
--EXPECT--
pre_inc [6,7,8,9]
post_inc [5,6,7,8]
pre_dec [4,3,2,1]
glob_inc [6,7,8,9]
stat_inc [6,7,8,9]
typed_ref_inc ["2.5",3.5,4.5,5.5]
Loading