Skip to content

Commit 187319b

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fix missing register store
2 parents 2df805d + 70e0e1a commit 187319b

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,6 +3655,16 @@ static int zend_jit_update_regs(dasm_State **Dst, uint32_t var, zend_jit_addr sr
36553655
} else {
36563656
ZEND_UNREACHABLE();
36573657
}
3658+
} else if (Z_MODE(dst) == IS_REG && Z_STORE(dst)) {
3659+
dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var);
3660+
if (!zend_jit_spill_store(Dst, src, dst, info,
3661+
JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE ||
3662+
JIT_G(current_frame) == NULL ||
3663+
STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var)) == IS_UNKNOWN ||
3664+
(1 << STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var))) != (info & MAY_BE_ANY)
3665+
)) {
3666+
return 0;
3667+
}
36583668
}
36593669
return 1;
36603670
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,6 +3995,16 @@ static int zend_jit_update_regs(dasm_State **Dst, uint32_t var, zend_jit_addr sr
39953995
} else {
39963996
ZEND_UNREACHABLE();
39973997
}
3998+
} else if (Z_MODE(dst) == IS_REG && Z_STORE(dst)) {
3999+
dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var);
4000+
if (!zend_jit_spill_store(Dst, src, dst, info,
4001+
JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE ||
4002+
JIT_G(current_frame) == NULL ||
4003+
STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var)) == IS_UNKNOWN ||
4004+
(1 << STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var))) != (info & MAY_BE_ANY)
4005+
)) {
4006+
return 0;
4007+
}
39984008
}
39994009
return 1;
40004010
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Register Alloction 015: Missing 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() {
11+
for ($i=0, $y = $a + $y = $a = $y %= !$y; $i < 5; $a = $y < $y = $a, $i++) {
12+
4 >> -$y;
13+
}
14+
}
15+
foo()
16+
?>
17+
DONE
18+
--EXPECTF--
19+
Warning: Undefined variable $y in %sreg_alloc_015.php on line 3
20+
21+
Warning: Undefined variable $y in %sreg_alloc_015.php on line 3
22+
DONE

0 commit comments

Comments
 (0)