summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/opcache/jit/zend_jit_x86.dasc17
-rw-r--r--ext/opcache/tests/jit/bug80782.phpt18
2 files changed, 31 insertions, 4 deletions
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 9fdc69a146..3e9d9f7f13 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -4329,12 +4329,17 @@ static int zend_jit_math_long_long(dasm_State **Dst,
}
do {
- if ((Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op1_addr)) == 1) ||
- (Z_MODE(op2_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op2_addr)) == 1)) {
+ if ((sizeof(void*) == 8 || Z_MODE(res_addr) != IS_REG) &&
+ ((Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op1_addr)) == 1) ||
+ (Z_MODE(op2_addr) == IS_CONST_ZVAL && Z_LVAL_P(Z_ZV(op2_addr)) == 1))) {
if (opcode == ZEND_ADD) {
|.if X64
| mov64 rax, 0x43e0000000000000
- | SET_ZVAL_LVAL res_addr, rax
+ if (Z_MODE(res_addr) == IS_REG) {
+ | movd xmm(Z_REG(res_addr)-ZREG_XMM0), rax
+ } else {
+ | SET_ZVAL_LVAL res_addr, rax
+ }
|.else
| SET_ZVAL_LVAL res_addr, 0
| SET_ZVAL_W2 res_addr, 0x41e00000
@@ -4343,7 +4348,11 @@ static int zend_jit_math_long_long(dasm_State **Dst,
} else if (opcode == ZEND_SUB) {
|.if X64
| mov64 rax, 0xc3e0000000000000
- | SET_ZVAL_LVAL res_addr, rax
+ if (Z_MODE(res_addr) == IS_REG) {
+ | movd xmm(Z_REG(res_addr)-ZREG_XMM0), rax
+ } else {
+ | SET_ZVAL_LVAL res_addr, rax
+ }
|.else
| SET_ZVAL_LVAL res_addr, 0x00200000
| SET_ZVAL_W2 res_addr, 0xc1e00000
diff --git a/ext/opcache/tests/jit/bug80782.phpt b/ext/opcache/tests/jit/bug80782.phpt
new file mode 100644
index 0000000000..c05987cbe2
--- /dev/null
+++ b/ext/opcache/tests/jit/bug80782.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.jit=tracing
+opcache.jit_buffer_size=1M
+opcache.protect_memory=1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+define('LONG_MIN', PHP_INT_MIN);
+var_dump(LONG_MIN-1);
+?>
+--EXPECTF--
+float(%s)