From: Dmitry Stogov Date: Wed, 23 Sep 2020 12:44:04 +0000 (+0300) Subject: Replace ZEND_JIT_TRACE_STOP_RETURN_HALT and ZEND_JIT_TRACE_STOP_HALT by separate... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c4fb70f2b3dcc3b60759f94bb4186fc67c19027;p=php Replace ZEND_JIT_TRACE_STOP_RETURN_HALT and ZEND_JIT_TRACE_STOP_HALT by separate ZEND_JIT_TRACE_HALT flag. --- diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index d17d2451d3..d44aaae0e1 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -142,7 +142,6 @@ int ZEND_FASTCALL zend_jit_check_constant(const zval *key); _(RECURSIVE_CALL, "recursive call") \ _(RECURSIVE_RET, "recursive return") \ _(RETURN, "return") \ - _(RETURN_HALT, "return from interpreter") \ _(INTERPRETER, "exit to VM interpreter") \ _(LINK, "link to another trace") \ /* compilation and linking successful */ \ @@ -163,7 +162,6 @@ int ZEND_FASTCALL zend_jit_check_constant(const zval *key); _(COMPILED_LOOP, "compiled loop") \ _(TRAMPOLINE, "trampoline call") \ _(BAD_FUNC, "bad function call") \ - _(HALT, "exit from interpreter") \ _(COMPILER_ERROR, "JIT compilation error") \ /* no recoverable error (blacklist immediately) */ \ _(NO_SHM, "insufficient shared memory") \ @@ -176,6 +174,7 @@ int ZEND_FASTCALL zend_jit_check_constant(const zval *key); typedef enum _zend_jit_trace_stop { ZEND_JIT_TRACE_STOP(ZEND_JIT_TRACE_STOP_NAME) + ZEND_JIT_TRACE_HALT = 0x40 } zend_jit_trace_stop; #define ZEND_JIT_TRACE_STOP_OK(ret) \ diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 2b40736499..f7f232f708 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -5620,8 +5620,7 @@ done: } else { zend_jit_trace_return(&dasm_state, 0); } - } else if (p->stop == ZEND_JIT_TRACE_STOP_RETURN - || p->stop == ZEND_JIT_TRACE_STOP_RETURN_HALT) { + } else if (p->stop == ZEND_JIT_TRACE_STOP_RETURN) { zend_jit_trace_return(&dasm_state, 0); } else { // TODO: not implemented ??? @@ -5661,7 +5660,6 @@ done: } } } else if (p->stop == ZEND_JIT_TRACE_STOP_LINK - || p->stop == ZEND_JIT_TRACE_STOP_RETURN_HALT || p->stop == ZEND_JIT_TRACE_STOP_INTERPRETER) { if (opline && (opline->opcode == ZEND_DO_UCALL @@ -6245,14 +6243,16 @@ repeat: ZEND_OP_TRACE_INFO(opline, offset)->trace_flags & ZEND_JIT_TRACE_START_MASK, 0); JIT_G(tracing) = 0; + if (stop & ZEND_JIT_TRACE_HALT) { + ret = -1; + } + stop &= ~ZEND_JIT_TRACE_HALT; + if (UNEXPECTED(JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_BYTECODE)) { zend_jit_dump_trace(trace_buffer, NULL); } if (ZEND_JIT_TRACE_STOP_OK(stop)) { - if (stop == ZEND_JIT_TRACE_STOP_RETURN_HALT) { - ret = -1; - } if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_STOP) { if (stop == ZEND_JIT_TRACE_STOP_LINK) { uint32_t idx = trace_buffer[1].last; @@ -6277,9 +6277,6 @@ repeat: goto abort; } } else { - if (stop == ZEND_JIT_TRACE_STOP_HALT) { - ret = -1; - } abort: if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_ABORT) { fprintf(stderr, "---- TRACE %d abort (%s)\n", @@ -6534,14 +6531,16 @@ int ZEND_FASTCALL zend_jit_trace_hot_side(zend_execute_data *execute_data, uint3 stop = zend_jit_trace_execute(execute_data, EX(opline), trace_buffer, ZEND_JIT_TRACE_START_SIDE, is_megamorphic); JIT_G(tracing) = 0; + if (stop & ZEND_JIT_TRACE_HALT) { + ret = -1; + } + stop &= ~ZEND_JIT_TRACE_HALT; + if (UNEXPECTED(JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_BYTECODE)) { zend_jit_dump_trace(trace_buffer, NULL); } if (ZEND_JIT_TRACE_STOP_OK(stop)) { - if (stop == ZEND_JIT_TRACE_STOP_RETURN_HALT) { - ret = -1; - } if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_STOP) { if (stop == ZEND_JIT_TRACE_STOP_LINK) { uint32_t idx = trace_buffer[1].last; @@ -6575,9 +6574,6 @@ int ZEND_FASTCALL zend_jit_trace_hot_side(zend_execute_data *execute_data, uint3 goto abort; } } else { - if (stop == ZEND_JIT_TRACE_STOP_HALT) { - ret = -1; - } abort: if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_ABORT) { fprintf(stderr, "---- TRACE %d abort (%s)\n", diff --git a/ext/opcache/jit/zend_jit_vm_helpers.c b/ext/opcache/jit/zend_jit_vm_helpers.c index 6cb8df08d9..968e9c2d3c 100644 --- a/ext/opcache/jit/zend_jit_vm_helpers.c +++ b/ext/opcache/jit/zend_jit_vm_helpers.c @@ -579,6 +579,7 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, #endif const zend_op *orig_opline, *end_opline; zend_jit_trace_stop stop = ZEND_JIT_TRACE_STOP_ERROR; + zend_jit_trace_stop halt = 0; int level = 0; int ret_level = 0; int call_level; @@ -762,7 +763,9 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, #ifdef HAVE_GCC_GLOBAL_REGS handler(); if (UNEXPECTED(opline == zend_jit_halt_op)) { - stop = ZEND_JIT_TRACE_STOP_RETURN_HALT; + stop = ZEND_JIT_TRACE_STOP_RETURN; + opline = NULL; + halt = ZEND_JIT_TRACE_HALT; break; } if (UNEXPECTED(execute_data != prev_execute_data)) { @@ -770,7 +773,9 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, rc = handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); if (rc != 0) { if (rc < 0) { - stop = ZEND_JIT_TRACE_STOP_RETURN_HALT; + stop = ZEND_JIT_TRACE_STOP_RETURN; + opline = NULL; + halt = ZEND_JIT_TRACE_HALT; break; } else if (execute_data == EG(current_execute_data)) { /* return after interrupt handler */ @@ -1035,8 +1040,7 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, TRACE_END(ZEND_JIT_TRACE_END, stop, end_opline); #ifdef HAVE_GCC_GLOBAL_REGS - if (stop != ZEND_JIT_TRACE_STOP_HALT - && stop != ZEND_JIT_TRACE_STOP_RETURN_HALT) { + if (!halt) { EX(opline) = opline; } #endif @@ -1046,5 +1050,5 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex, opline = save_opline; #endif - return stop; + return stop | halt; } diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index deed2c402e..0aab3961cb 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -3532,7 +3532,6 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra } if (trace->op != ZEND_JIT_TRACE_END || (trace->stop != ZEND_JIT_TRACE_STOP_RETURN && - trace->stop != ZEND_JIT_TRACE_STOP_RETURN_HALT && trace->stop != ZEND_JIT_TRACE_STOP_INTERPRETER)) { const zend_op *next_opline = trace->opline;