Skip to content

Commit f2e088e

Browse files
committed
Fix GH-24438: Preserve indirect types in JIT side traces
1 parent a1eb2f8 commit f2e088e

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

‎ext/opcache/jit/zend_jit_trace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
17141714
if (i < op_array->last_var) {
17151715
ssa_var_info[i].type = MAY_BE_UNDEF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
17161716
} else {
1717-
ssa_var_info[i].type = MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
1717+
ssa_var_info[i].type = MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | MAY_BE_INDIRECT | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
17181718
}
17191719
}
17201720
if (i < parent_vars_count) {

‎ext/opcache/tests/jit/gh24438.phpt‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
GH-24438 (Tracing JIT preserves indirect arguments on side-trace entry)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable=1
7+
opcache.enable_cli=1
8+
opcache.file_update_protection=0
9+
opcache.jit_buffer_size=64M
10+
opcache.jit=tracing
11+
opcache.jit_hot_loop=1
12+
opcache.jit_hot_func=1
13+
opcache.jit_hot_return=1
14+
opcache.jit_hot_side_exit=1
15+
opcache.jit_max_polymorphic_calls=0
16+
--FILE--
17+
<?php
18+
function byVal($value) {
19+
$value = (int) $value + 1000;
20+
return $value;
21+
}
22+
23+
function byRef(&$value) {
24+
$value = (int) $value + 1;
25+
return $value;
26+
}
27+
28+
$fns = ['byVal', 'byRef'];
29+
$arr = [10, 20];
30+
for ($i = 0; $i < 120; $i++) {
31+
$f = $fns[$i % 2];
32+
$f($arr[1]);
33+
$f($arr[0]);
34+
}
35+
36+
var_dump($arr[0], $arr[1]);
37+
?>
38+
--EXPECT--
39+
int(70)
40+
int(80)

0 commit comments

Comments
 (0)