Skip to content

Commit 7686118

Browse files
committed
Fix type recording and side exit information for FE_FETCH_* instructions
1 parent c9881fd commit 7686118

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

ext/opcache/jit/zend_jit_vm_helpers.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,9 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
655655
if (opline->op2_type & (IS_TMP_VAR|IS_VAR|IS_CV)
656656
&& opline->opcode != ZEND_INSTANCEOF
657657
&& opline->opcode != ZEND_UNSET_STATIC_PROP
658-
&& opline->opcode != ZEND_FE_FETCH_R
659-
&& opline->opcode != ZEND_FE_FETCH_RW) {
658+
&& (opline->op2_type == IS_CV
659+
|| (opline->opcode != ZEND_FE_FETCH_R
660+
&& opline->opcode != ZEND_FE_FETCH_RW))) {
660661
zval *zv = EX_VAR(opline->op2.var);
661662
uint8_t flags = 0;
662663

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,8 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra
32773277
const zend_op *exit_opline = NULL;
32783278
uint32_t exit_point;
32793279
const void *exit_addr;
3280+
uint32_t old_info = 0;
3281+
zend_jit_trace_stack *stack = JIT_G(current_frame)->stack;
32803282

32813283
if (zend_is_smart_branch(opline)) {
32823284
zend_bool exit_if_true = 0;
@@ -3302,6 +3304,10 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra
33023304
break;
33033305
case ZEND_FE_FETCH_R:
33043306
case ZEND_FE_FETCH_RW:
3307+
if (opline->op2_type == IS_CV) {
3308+
old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->op2.var));
3309+
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op2.var), IS_UNKNOWN);
3310+
}
33053311
exit_opline = (trace->opline == opline + 1) ?
33063312
ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) :
33073313
opline + 1;
@@ -3313,6 +3319,15 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra
33133319
exit_point = zend_jit_trace_get_exit_point(opline, exit_opline, trace, 0);
33143320
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
33153321

3322+
switch (opline->opcode) {
3323+
case ZEND_FE_FETCH_R:
3324+
case ZEND_FE_FETCH_RW:
3325+
if (opline->op2_type == IS_CV) {
3326+
SET_STACK_INFO(stack, EX_VAR_TO_NUM(opline->op2.var), old_info);
3327+
}
3328+
break;
3329+
}
3330+
33163331
if (!exit_addr) {
33173332
return 0;
33183333
}

0 commit comments

Comments
 (0)