Skip to content

Commit c7e974f

Browse files
committed
Tracing JIT: Fixed incorrect assumtion about temporary variable types clobbered by *_ROPE instructions
1 parent c9d509b commit c7e974f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5783,6 +5783,19 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
57835783
SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE);
57845784
}
57855785

5786+
if (opline->opcode == ZEND_ROPE_INIT) {
5787+
/* clear stack slots used by rope */
5788+
uint32_t var = EX_VAR_TO_NUM(opline->result.var);
5789+
uint32_t count =
5790+
((opline->extended_value * sizeof(void*)) + (sizeof(zval)-1)) / sizeof(zval);
5791+
5792+
do {
5793+
SET_STACK_TYPE(stack, var, IS_UNKNOWN, 1);
5794+
var++;
5795+
count--;
5796+
} while (count);
5797+
}
5798+
57865799
if (ssa_op) {
57875800
zend_ssa_range tmp;
57885801

ext/opcache/tests/jit/rope_001.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
JIT ROPE: 001 *_ROPE may types of temporary variables
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+
$a = "";
11+
$b = 1;
12+
var_dump(" $a $a" == " $a" . -$b);
13+
var_dump(" $a $a" == " $a" . -$b);
14+
?>
15+
--EXPECT--
16+
bool(false)
17+
bool(false)

0 commit comments

Comments
 (0)