Skip to content

Commit 0d80bc2

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fix type store
2 parents dd62ec0 + 2862553 commit 0d80bc2

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4896,14 +4896,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
48964896
}
48974897
CHECK_OP2_TRACE_TYPE();
48984898
op1_info = OP1_INFO();
4899-
if ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_GUARD)) == MAY_BE_LONG
4900-
|| (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_GUARD)) == MAY_BE_DOUBLE) {
4901-
if (STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var)) != IS_LONG
4902-
&& STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var)) != IS_DOUBLE) {
4903-
/* type may be not set */
4904-
op1_info |= MAY_BE_NULL;
4905-
}
4906-
}
49074899
op1_def_info = OP1_DEF_INFO();
49084900
if (op1_type != IS_UNKNOWN && (op1_info & MAY_BE_GUARD)) {
49094901
if (op1_type < IS_STRING
@@ -4918,6 +4910,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
49184910
}
49194911
op1_addr = OP1_REG_ADDR();
49204912
op1_def_addr = OP1_DEF_REG_ADDR();
4913+
if (Z_MODE(op1_def_addr) != IS_REG &&
4914+
STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var)) !=
4915+
STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var))) {
4916+
/* type may be not set */
4917+
op1_info |= MAY_BE_NULL;
4918+
}
49214919
if (orig_op1_type != IS_UNKNOWN) {
49224920
if (orig_op1_type & IS_TRACE_REFERENCE) {
49234921
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Register Alloction 012: Missed type store
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($a) {
11+
$b = $a;
12+
$b =! $a = $a + $b & $b & $bb = $a = $a + $b & $a;
13+
$a = $a + $b & $b & $b = $a;
14+
}
15+
16+
for ($i = 0; $i < 3; $i++) {
17+
@foo(39087589046889428661);
18+
}
19+
?>
20+
DONE
21+
--EXPECTF--
22+
DONE

0 commit comments

Comments
 (0)