Skip to content

Commit 70e0e1a

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fix missing register store
2 parents 6797f33 + 1cd8074 commit 70e0e1a

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
@@ -3660,6 +3660,16 @@ static int zend_jit_update_regs(dasm_State **Dst, uint32_t var, zend_jit_addr sr
36603660
} else {
36613661
ZEND_UNREACHABLE();
36623662
}
3663+
} else if (Z_MODE(dst) == IS_REG && Z_STORE(dst)) {
3664+
dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var);
3665+
if (!zend_jit_spill_store(Dst, src, dst, info,
3666+
JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE ||
3667+
JIT_G(current_frame) == NULL ||
3668+
STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var)) == IS_UNKNOWN ||
3669+
(1 << STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var))) != (info & MAY_BE_ANY)
3670+
)) {
3671+
return 0;
3672+
}
36633673
}
36643674
return 1;
36653675
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,6 +4000,16 @@ static int zend_jit_update_regs(dasm_State **Dst, uint32_t var, zend_jit_addr sr
40004000
} else {
40014001
ZEND_UNREACHABLE();
40024002
}
4003+
} else if (Z_MODE(dst) == IS_REG && Z_STORE(dst)) {
4004+
dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var);
4005+
if (!zend_jit_spill_store(Dst, src, dst, info,
4006+
JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE ||
4007+
JIT_G(current_frame) == NULL ||
4008+
STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var)) == IS_UNKNOWN ||
4009+
(1 << STACK_MEM_TYPE(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(var))) != (info & MAY_BE_ANY)
4010+
)) {
4011+
return 0;
4012+
}
40034013
}
40044014
return 1;
40054015
}
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)