Skip to content

Commit 70545b7

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fixed NaN handling
2 parents bcadbec + c08ee7c commit 70545b7

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8076,8 +8076,9 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
80768076
| SET_ZVAL_TYPE_INFO res_addr, IS_FALSE, TMP1w, TMP2
80778077
} else {
80788078
| SET_ZVAL_TYPE_INFO res_addr, IS_FALSE, TMP1w, TMP2
8079-
| bvs &exit_addr
8079+
| bvs >1
80808080
| beq &exit_addr
8081+
|1:
80818082
| SET_ZVAL_TYPE_INFO res_addr, IS_TRUE, TMP1w, TMP2
80828083
}
80838084
} else if (false_label != (uint32_t)-1) { // JMPZ_EX
@@ -8116,8 +8117,9 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
81168117
| bne &exit_addr
81178118
|1:
81188119
} else {
8119-
| bvs &exit_addr
8120+
| bvs >1
81208121
| beq &exit_addr
8122+
|1:
81218123
}
81228124
} else {
81238125
ZEND_ASSERT(true_label != (uint32_t)-1 || false_label != (uint32_t)-1);

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8637,8 +8637,9 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
86378637
| SET_ZVAL_TYPE_INFO res_addr, IS_FALSE
86388638
} else {
86398639
| SET_ZVAL_TYPE_INFO res_addr, IS_FALSE
8640-
| jp &exit_addr
8640+
| jp >1
86418641
| je &exit_addr
8642+
|1:
86428643
| SET_ZVAL_TYPE_INFO res_addr, IS_TRUE
86438644
}
86448645
} else if (false_label != (uint32_t)-1) { // JMPZ_EX
@@ -8677,8 +8678,9 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
86778678
| jne &exit_addr
86788679
|1:
86798680
} else {
8680-
| jp &exit_addr
8681+
| jp >1
86818682
| je &exit_addr
8683+
|1:
86828684
}
86838685
} else {
86848686
ZEND_ASSERT(true_label != (uint32_t)-1 || false_label != (uint32_t)-1);

ext/opcache/tests/jit/nan_001.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
NaN handling: 001
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
$b = NAN;
12+
for ($i = 0; $i < 3; $i++) {
13+
if ($b) { echo "nan is true\n"; }
14+
else { echo "nan is false\n"; }
15+
}
16+
?>
17+
--EXPECT--
18+
nan is true
19+
nan is true
20+
nan is true

0 commit comments

Comments
 (0)