Skip to content

Commit d241b34

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Don't undef result operand if there is none
2 parents fb4405d + 5a7d76b commit d241b34

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,15 @@ static size_t tsrm_tls_offset;
540540
| SET_Z_TYPE_INFO FP + r0, IS_UNDEF
541541
|.endmacro
542542

543+
|.macro UNDEF_OPLINE_RESULT_IF_USED
544+
| mov r0, EX->opline
545+
| test byte OP:r0->result_type, (IS_TMP_VAR|IS_VAR)
546+
| jz >1
547+
| mov eax, dword OP:r0->result.var
548+
| SET_Z_TYPE_INFO FP + r0, IS_UNDEF
549+
|1:
550+
|.endmacro
551+
543552
|.macro SSE_AVX_INS, sse_ins, avx_ins, op1, op2
544553
|| if (CAN_USE_AVX()) {
545554
| avx_ins op1, op2
@@ -2087,7 +2096,7 @@ static int zend_jit_undefined_function_stub(dasm_State **Dst)
20872096
static int zend_jit_negative_shift_stub(dasm_State **Dst)
20882097
{
20892098
|->negative_shift:
2090-
| UNDEF_OPLINE_RESULT
2099+
| UNDEF_OPLINE_RESULT_IF_USED
20912100
|.if X64
20922101
|.if WIN
20932102
| LOAD_ADDR CARG1, &zend_ce_arithmetic_error
@@ -2116,7 +2125,7 @@ static int zend_jit_negative_shift_stub(dasm_State **Dst)
21162125
static int zend_jit_mod_by_zero_stub(dasm_State **Dst)
21172126
{
21182127
|->mod_by_zero:
2119-
| UNDEF_OPLINE_RESULT
2128+
| UNDEF_OPLINE_RESULT_IF_USED
21202129
|.if X64
21212130
|.if WIN
21222131
| LOAD_ADDR CARG1, &zend_ce_division_by_zero_error
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
JIT ASSIGN_OP: 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+
--FILE--
9+
<?php
10+
function test1($a) {
11+
$a %= 0;
12+
}
13+
function test2($a) {
14+
$a <<= -1;
15+
}
16+
try {
17+
test1(1);
18+
} catch (DivisionByZeroError $e) {
19+
echo $e->getMessage(), "\n";
20+
}
21+
try {
22+
test2(1);
23+
} catch (ArithmeticError $e) {
24+
echo $e->getMessage(), "\n";
25+
}
26+
?>
27+
--EXPECT--
28+
Modulo by zero
29+
Bit shift by negative number

0 commit comments

Comments
 (0)