Skip to content

Commit 2862553

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fix type store
2 parents d0a0518 + 9792f0d commit 2862553

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
@@ -4885,14 +4885,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
48854885
}
48864886
CHECK_OP2_TRACE_TYPE();
48874887
op1_info = OP1_INFO();
4888-
if ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_GUARD)) == MAY_BE_LONG
4889-
|| (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_GUARD)) == MAY_BE_DOUBLE) {
4890-
if (STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var)) != IS_LONG
4891-
&& STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var)) != IS_DOUBLE) {
4892-
/* type may be not set */
4893-
op1_info |= MAY_BE_NULL;
4894-
}
4895-
}
48964888
op1_def_info = OP1_DEF_INFO();
48974889
if (op1_type != IS_UNKNOWN && (op1_info & MAY_BE_GUARD)) {
48984890
if (op1_type < IS_STRING
@@ -4907,6 +4899,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
49074899
}
49084900
op1_addr = OP1_REG_ADDR();
49094901
op1_def_addr = OP1_DEF_REG_ADDR();
4902+
if (Z_MODE(op1_def_addr) != IS_REG &&
4903+
STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var)) !=
4904+
STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var))) {
4905+
/* type may be not set */
4906+
op1_info |= MAY_BE_NULL;
4907+
}
49104908
if (orig_op1_type != IS_UNKNOWN) {
49114909
if (orig_op1_type & IS_TRACE_REFERENCE) {
49124910
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)