]> granicus.if.org Git - php/commitdiff
Replace ZEND_JIT_TRACE_STOP_RETURN_HALT and ZEND_JIT_TRACE_STOP_HALT by separate...
authorDmitry Stogov <dmitry@zend.com>
Wed, 23 Sep 2020 12:44:04 +0000 (15:44 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 23 Sep 2020 12:44:04 +0000 (15:44 +0300)
ext/opcache/jit/zend_jit_internal.h
ext/opcache/jit/zend_jit_trace.c
ext/opcache/jit/zend_jit_vm_helpers.c
ext/opcache/jit/zend_jit_x86.dasc

index d17d2451d3b0a49bd8dab0a1c6542e6de47ac5b3..d44aaae0e172d6eaa91cbe52929f66d9f6e8b19e 100644 (file)
@@ -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) \
index 2b407364993d17f3c13a02afe9cd4ad8fe2cc5b4..f7f232f70821cc626a52272851a46c024e4d4a11 100644 (file)
@@ -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",
index 6cb8df08d9da1ce9eb7bf4cda169caf770aae5fb..968e9c2d3c01aa3bb98f47da687bfc3b99cdf268 100644 (file)
@@ -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;
 }
index deed2c402e8ca13f045335be21454a3be885eafc..0aab3961cb02b8e2235059758b3745543ac66233 100644 (file)
@@ -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;