Skip to content

Commit c93c3b4

Browse files
committed
Handle VM interrupts after DO_ICALL through side exits
1 parent 26ce32c commit c93c3b4

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,22 +2794,16 @@ static int zend_jit_check_timeout(dasm_State **Dst, const zend_op *opline, const
27942794
| jne ->interrupt_handler
27952795
#else
27962796
| MEM_OP2_1_ZTS cmp, byte, executor_globals, vm_interrupt, 0, r0
2797-
if (last_valid_opline == opline) {
2798-
if (exit_addr) {
2799-
| jne &exit_addr
2800-
} else {
2801-
| jne ->interrupt_handler
2802-
}
2797+
if (exit_addr) {
2798+
| jne &exit_addr
2799+
} else if (last_valid_opline == opline) {
2800+
| jne ->interrupt_handler
28032801
} else {
28042802
| jne >1
28052803
|.cold_code
28062804
|1:
28072805
| LOAD_IP_ADDR opline
2808-
if (exit_addr) {
2809-
| jmp &exit_addr
2810-
} else {
2811-
| jmp ->interrupt_handler
2812-
}
2806+
| jmp ->interrupt_handler
28132807
|.code
28142808
}
28152809
#endif
@@ -8231,6 +8225,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
82318225
zend_jit_addr res_addr;
82328226
uint32_t call_num_args = 0;
82338227
zend_bool unknown_num_args = 0;
8228+
const void *exit_addr = NULL;
82348229

82358230
if (RETURN_VALUE_USED(opline)) {
82368231
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
@@ -8340,8 +8335,8 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
83408335
if (!func) {
83418336
if (trace) {
83428337
uint32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM);
8343-
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
83448338

8339+
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
83458340
if (!exit_addr) {
83468341
return 0;
83478342
}
@@ -8628,8 +8623,8 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
86288623
if (!func) {
86298624
if (trace) {
86308625
uint32_t exit_point = zend_jit_trace_get_exit_point(opline, opline, NULL, ZEND_JIT_EXIT_TO_VM);
8631-
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
86328626

8627+
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
86338628
if (!exit_addr) {
86348629
return 0;
86358630
}
@@ -8762,9 +8757,20 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
87628757
|.code
87638758

87648759
// TODO: Can we avoid checking for interrupts after each call ???
8765-
if (!zend_jit_check_timeout(Dst, opline + 1, NULL)) {
8760+
if (trace && last_valid_opline != opline) {
8761+
int32_t exit_point = zend_jit_trace_get_exit_point(opline, opline + 1, NULL, ZEND_JIT_EXIT_TO_VM);
8762+
8763+
exit_addr = zend_jit_trace_get_exit_addr(exit_point);
8764+
if (!exit_addr) {
8765+
return 0;
8766+
}
8767+
} else {
8768+
exit_addr = NULL;
8769+
}
8770+
if (!zend_jit_check_timeout(Dst, opline + 1, exit_addr)) {
87668771
return 0;
87678772
}
8773+
87688774
if (opline->opcode != ZEND_DO_ICALL) {
87698775
| LOAD_IP_ADDR (opline + 1)
87708776
}

0 commit comments

Comments
 (0)