Skip to content

Commit ccef2bc

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Tracing JIT: Fixed incorrect assumption about stack slot type
2 parents 414f7fc + 69bcd93 commit ccef2bc

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

ext/opcache/jit/zend_jit_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ typedef union _zend_jit_trace_stack {
562562
(_stack)[_slot].reg = _reg; \
563563
(_stack)[_slot].flags = _flags; \
564564
} while (0)
565+
#define RESET_STACK_MEM_TYPE(_stack, _slot) do { \
566+
(_stack)[_slot].mem_type = IS_UNKNOWN; \
567+
} while (0)
565568

566569
/* trace info flags */
567570
#define ZEND_JIT_TRACE_CHECK_INTERRUPT (1<<0)

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6229,6 +6229,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62296229
} else {
62306230
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), type,
62316231
(type == IS_UNKNOWN || !ra || !ra[ssa_op->result_def]));
6232+
if (ssa->var_info[ssa_op->result_def].type & MAY_BE_INDIRECT) {
6233+
RESET_STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var));
6234+
}
62326235
if (type != IS_UNKNOWN) {
62336236
ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
62346237
if (opline->opcode == ZEND_FETCH_THIS
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
JIT FETCH_DIM_R: 014
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+
function foo() {
11+
$s =+ $y;
12+
$tokenthiss[$i=$s][] = $y = $y;
13+
$tokenthiss[$i][$i] + $y;
14+
}
15+
@foo();
16+
?>
17+
DONE
18+
--EXPECT--
19+
DONE

0 commit comments

Comments
 (0)