Skip to content

Commit 5380b41

Browse files
committed
JIT: Partially fix handling of exceptions thrown in interrupt handlers
1 parent fa0b84a commit 5380b41

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

ext/opcache/jit/zend_jit_disasm_x86.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ static int zend_jit_disasm_init(void)
496496
REGISTER_HELPER(zval_jit_update_constant_ex);
497497
#endif
498498
REGISTER_HELPER(zend_jit_free_trampoline_helper);
499+
REGISTER_HELPER(zend_jit_exception_in_interrupt_handler_helper);
499500
#undef REGISTER_HELPER
500501

501502
#ifndef _WIN32

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,3 +2719,20 @@ static void ZEND_FASTCALL zend_jit_free_trampoline_helper(zend_function *func)
27192719
zend_string_release_ex(func->common.function_name, 0);
27202720
zend_free_trampoline(func);
27212721
}
2722+
2723+
static void ZEND_FASTCALL zend_jit_exception_in_interrupt_handler_helper(void)
2724+
{
2725+
if (EG(exception)) {
2726+
/* We have to UNDEF result, because ZEND_HANDLE_EXCEPTION is going to free it */
2727+
const zend_op *throw_op = EG(opline_before_exception);
2728+
2729+
if (throw_op
2730+
&& throw_op->result_type & (IS_TMP_VAR|IS_VAR)
2731+
&& throw_op->opcode != ZEND_ADD_ARRAY_ELEMENT
2732+
&& throw_op->opcode != ZEND_ADD_ARRAY_UNPACK
2733+
&& throw_op->opcode != ZEND_ROPE_INIT
2734+
&& throw_op->opcode != ZEND_ROPE_ADD) {
2735+
ZVAL_UNDEF(ZEND_CALL_VAR(EG(current_execute_data), throw_op->result.var));
2736+
}
2737+
}
2738+
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,10 @@ static int zend_jit_interrupt_handler_stub(dasm_State **Dst)
17681768
| mov aword A1, FP
17691769
| EXT_CALL zend_interrupt_function, r0
17701770
|.endif
1771+
| MEM_OP2_1_ZTS cmp, aword, executor_globals, exception, 0, r0
1772+
| je >1
1773+
| EXT_CALL zend_jit_exception_in_interrupt_handler_helper, r0
1774+
|1:
17711775
| //ZEND_VM_ENTER();
17721776
| //execute_data = EG(current_execute_data);
17731777
| MEM_OP2_2_ZTS mov, FP, aword, executor_globals, current_execute_data, r0

0 commit comments

Comments
 (0)