Skip to content

Commit 912f040

Browse files
committed
JIT: Fixed incorrect deoptimization info
1 parent f0cf999 commit 912f040

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12832,9 +12832,15 @@ static int zend_jit_incdec_obj(dasm_State **Dst,
1283212832
&& !ZEND_TYPE_IS_SET(prop_info->type)
1283312833
&& (res_info & MAY_BE_GUARD)
1283412834
&& (res_info & MAY_BE_LONG)) {
12835-
int32_t exit_point = zend_jit_trace_get_exit_point(opline + 1, 0);
12836-
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
12835+
zend_jit_trace_stack *stack = JIT_G(current_frame)->stack;
12836+
uint32_t old_res_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var));
12837+
int32_t exit_point;
12838+
const void *exit_addr;
1283712839

12840+
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_DOUBLE, 0);
12841+
exit_point = zend_jit_trace_get_exit_point(opline + 1, 0);
12842+
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
12843+
SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_res_info);
1283812844
ssa->var_info[ssa_op->result_def].type = res_info & ~MAY_BE_GUARD;
1283912845
| b &exit_addr
1284012846
|.code

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13559,9 +13559,15 @@ static int zend_jit_incdec_obj(dasm_State **Dst,
1355913559
&& !ZEND_TYPE_IS_SET(prop_info->type)
1356013560
&& (res_info & MAY_BE_GUARD)
1356113561
&& (res_info & MAY_BE_LONG)) {
13562-
int32_t exit_point = zend_jit_trace_get_exit_point(opline + 1, 0);
13563-
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
13562+
zend_jit_trace_stack *stack = JIT_G(current_frame)->stack;
13563+
uint32_t old_res_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var));
13564+
int32_t exit_point;
13565+
const void *exit_addr;
1356413566

13567+
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_DOUBLE, 0);
13568+
exit_point = zend_jit_trace_get_exit_point(opline + 1, 0);
13569+
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
13570+
SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var), old_res_info);
1356513571
ssa->var_info[ssa_op->result_def].type = res_info & ~MAY_BE_GUARD;
1356613572
| jmp &exit_addr
1356713573
|.code
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
PRE_INC_OBJ: 004
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+
class Test {
12+
public $prop;
13+
function foo() {
14+
$this->prop = PHP_INT_MAX-5;
15+
for ($i = 0; $i - 15; $i++) {
16+
var_dump(++$this->prop);
17+
}
18+
}
19+
}
20+
$test = new Test;
21+
$test->foo();
22+
?>
23+
--EXPECTF--
24+
int(%d)
25+
int(%d)
26+
int(%d)
27+
int(%d)
28+
int(%d)
29+
float(%f)
30+
float(%f)
31+
float(%f)
32+
float(%f)
33+
float(%f)
34+
float(%f)
35+
float(%f)
36+
float(%f)
37+
float(%f)
38+
float(%f)

0 commit comments

Comments
 (0)