Skip to content

Commit 203c1b8

Browse files
committed
Tracing JIT: Fixed incorrect tracing type inference
There are some cases when IS_VAR/IS_TMP_VAR variables are set to IS_UNDEF. TODO: It would be better to switch to IS_NULL in master.
1 parent a551b08 commit 203c1b8

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,12 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
14361436

14371437
if (op_type != IS_UNKNOWN) {
14381438
ssa_var_info[i].type &= zend_jit_trace_type_to_info(op_type);
1439+
if (!ssa_var_info[i].type
1440+
&& op_type == IS_UNDEF
1441+
&& i >= op_array->last_var) {
1442+
// TODO: It's better to use NULL instead of UNDEF for temporary variables
1443+
ssa_var_info[i].type |= MAY_BE_UNDEF;
1444+
}
14391445
}
14401446
}
14411447
i++;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
FE_RESET: 001 undef $$ operand
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
for ($i = 0; $i < 5; $i++) {
11+
for ($j = 0; $j < $i; $j++) {}
12+
foreach ($$i as $x) {}
13+
}
14+
?>
15+
OK
16+
--EXPECTF--
17+
Warning: Undefined variable $0 in %sfe_reset_001.php on line 4
18+
19+
Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4
20+
21+
Warning: Undefined variable $1 in %sfe_reset_001.php on line 4
22+
23+
Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4
24+
25+
Warning: Undefined variable $2 in %sfe_reset_001.php on line 4
26+
27+
Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4
28+
29+
Warning: Undefined variable $3 in %sfe_reset_001.php on line 4
30+
31+
Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4
32+
33+
Warning: Undefined variable $4 in %sfe_reset_001.php on line 4
34+
35+
Warning: foreach() argument must be of type array|object, null given in %sfe_reset_001.php on line 4
36+
OK
37+

0 commit comments

Comments
 (0)