Skip to content

Commit cfb21e8

Browse files
shqkingdstogov
authored andcommitted
JIT: Fixed exit from CALL VM with GCC Global Register Variables
PHP JIT supports three configurations: HYRBID, CALL with global register variables feature(CALL+GRV for short), and CALL+noGRV. CALL+GRV mode can be built with the following commands: ``` php Zend/zend_vm_gen.php --with-vm-kind=CALL ./buildconf -f; ./configure; make ``` About 230 test cases failed for tracing JIT under CALL+GRV mode on both x86 and arm64 machines. For CALL+GRV mode, the condition to determine whether the execution of an oparray is finished, is "opline == NULL". See function execute_ex() around line "if (UNEXPECTED(!OPLINE)) {". However, such cleanup operation is missing for the JIT wrapper zend_jit_trace_counter_helper(), and the trace_halt stub function. Tests: 1. test cases: all .phpt test cases under "Zend/tests/ tests/ ext/opcache/tests/jit/". 2. both JIT/x86 and JIT/arm64: function JIT, tracing JIT and tracing JIT with "--repeat 3" 3. execution modes: NTS/ZTS, HYBRID/CALL+GRV/CALL+noGRV In my local test, these test cases passed under all JIT configrations.
1 parent 5cae6b9 commit cfb21e8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ext/opcache/jit/zend_jit_vm_helpers.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ static zend_always_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_trace_c
308308
if (UNEXPECTED(*(ZEND_OP_TRACE_INFO(opline, offset)->counter) <= 0)) {
309309
*(ZEND_OP_TRACE_INFO(opline, offset)->counter) = ZEND_JIT_COUNTER_INIT;
310310
if (UNEXPECTED(zend_jit_trace_hot_root(execute_data, opline) < 0)) {
311-
#ifndef HAVE_GCC_GLOBAL_REGS
311+
#ifdef HAVE_GCC_GLOBAL_REGS
312+
opline = NULL;
313+
return;
314+
#else
312315
return -1;
313316
#endif
314317
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,8 @@ static int zend_jit_trace_halt_stub(dasm_State **Dst)
24242424
| EXT_JMP zend_jit_halt_op->handler, r0
24252425
} else if (GCC_GLOBAL_REGS) {
24262426
| add r4, SPAD // stack alignment
2427-
| ret // PC must be zero
2427+
| xor IP, IP // PC must be zero
2428+
| ret
24282429
} else {
24292430
| mov FP, aword T2 // restore FP
24302431
| mov RX, aword T3 // restore IP

0 commit comments

Comments
 (0)