File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -4426,8 +4426,14 @@ static int zend_jit_math_long_long(dasm_State **Dst,
44264426 } else {
44274427 zend_reg tmp_reg;
44284428
4429- if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_R0) {
4430- tmp_reg = ZREG_R1;
4429+ if (Z_MODE(res_addr) == IS_MEM_ZVAL) {
4430+ if (Z_REG(res_addr) != ZREG_R0 && result_reg != ZREG_R0) {
4431+ tmp_reg = ZREG_R0;
4432+ } else if (Z_REG(res_addr) != ZREG_R1 && result_reg != ZREG_R1) {
4433+ tmp_reg = ZREG_R1;
4434+ } else {
4435+ tmp_reg = ZREG_R2;
4436+ }
44314437 } else if (result_reg != ZREG_R0) {
44324438 tmp_reg = ZREG_R0;
44334439 } else {
@@ -5295,8 +5301,16 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
52955301 } else {
52965302 zend_reg tmp_reg;
52975303
5298- if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_R0) {
5299- tmp_reg = ZREG_R1;
5304+ if (Z_MODE(res_addr) == IS_MEM_ZVAL) {
5305+ if (Z_REG(res_addr) != ZREG_R0 && result_reg != ZREG_R0) {
5306+ tmp_reg = ZREG_R0;
5307+ } else if (Z_REG(res_addr) != ZREG_R1 && result_reg != ZREG_R1) {
5308+ tmp_reg = ZREG_R1;
5309+ } else {
5310+ tmp_reg = ZREG_R2;
5311+ }
5312+ } else if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_R1) {
5313+ tmp_reg = ZREG_R0;
53005314 } else if (result_reg != ZREG_R0) {
53015315 tmp_reg = ZREG_R0;
53025316 } else {
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-12481: PHP crash on Windows 64-bit with JIT enabled
3+ --INI--
4+ opcache.enable=1
5+ opcache.enable_cli=1
6+ --FILE--
7+ <?php
8+ function foo (&$ var ) {
9+ $ var &= 0xFFFFFFFF ;
10+ return intval ($ var );
11+ }
12+ $ v = 0x7FFFFFFF1 ;
13+ for ($ i = 0 ; $ i < 10 ; $ i ++) {
14+ foo ($ v );
15+ }
16+ ?>
17+ DONE
18+ --EXPECTF--
19+ DONE
You can’t perform that action at this time.
0 commit comments