Skip to content

Commit 3c4fb70

Browse files
committed
Replace ZEND_JIT_TRACE_STOP_RETURN_HALT and ZEND_JIT_TRACE_STOP_HALT by separate ZEND_JIT_TRACE_HALT flag.
1 parent 9623756 commit 3c4fb70

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

ext/opcache/jit/zend_jit_internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ int ZEND_FASTCALL zend_jit_check_constant(const zval *key);
142142
_(RECURSIVE_CALL, "recursive call") \
143143
_(RECURSIVE_RET, "recursive return") \
144144
_(RETURN, "return") \
145-
_(RETURN_HALT, "return from interpreter") \
146145
_(INTERPRETER, "exit to VM interpreter") \
147146
_(LINK, "link to another trace") \
148147
/* compilation and linking successful */ \
@@ -163,7 +162,6 @@ int ZEND_FASTCALL zend_jit_check_constant(const zval *key);
163162
_(COMPILED_LOOP, "compiled loop") \
164163
_(TRAMPOLINE, "trampoline call") \
165164
_(BAD_FUNC, "bad function call") \
166-
_(HALT, "exit from interpreter") \
167165
_(COMPILER_ERROR, "JIT compilation error") \
168166
/* no recoverable error (blacklist immediately) */ \
169167
_(NO_SHM, "insufficient shared memory") \
@@ -176,6 +174,7 @@ int ZEND_FASTCALL zend_jit_check_constant(const zval *key);
176174

177175
typedef enum _zend_jit_trace_stop {
178176
ZEND_JIT_TRACE_STOP(ZEND_JIT_TRACE_STOP_NAME)
177+
ZEND_JIT_TRACE_HALT = 0x40
179178
} zend_jit_trace_stop;
180179

181180
#define ZEND_JIT_TRACE_STOP_OK(ret) \

ext/opcache/jit/zend_jit_trace.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5620,8 +5620,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
56205620
} else {
56215621
zend_jit_trace_return(&dasm_state, 0);
56225622
}
5623-
} else if (p->stop == ZEND_JIT_TRACE_STOP_RETURN
5624-
|| p->stop == ZEND_JIT_TRACE_STOP_RETURN_HALT) {
5623+
} else if (p->stop == ZEND_JIT_TRACE_STOP_RETURN) {
56255624
zend_jit_trace_return(&dasm_state, 0);
56265625
} else {
56275626
// TODO: not implemented ???
@@ -5661,7 +5660,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
56615660
}
56625661
}
56635662
} else if (p->stop == ZEND_JIT_TRACE_STOP_LINK
5664-
|| p->stop == ZEND_JIT_TRACE_STOP_RETURN_HALT
56655663
|| p->stop == ZEND_JIT_TRACE_STOP_INTERPRETER) {
56665664
if (opline
56675665
&& (opline->opcode == ZEND_DO_UCALL
@@ -6245,14 +6243,16 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
62456243
ZEND_OP_TRACE_INFO(opline, offset)->trace_flags & ZEND_JIT_TRACE_START_MASK, 0);
62466244
JIT_G(tracing) = 0;
62476245

6246+
if (stop & ZEND_JIT_TRACE_HALT) {
6247+
ret = -1;
6248+
}
6249+
stop &= ~ZEND_JIT_TRACE_HALT;
6250+
62486251
if (UNEXPECTED(JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_BYTECODE)) {
62496252
zend_jit_dump_trace(trace_buffer, NULL);
62506253
}
62516254

62526255
if (ZEND_JIT_TRACE_STOP_OK(stop)) {
6253-
if (stop == ZEND_JIT_TRACE_STOP_RETURN_HALT) {
6254-
ret = -1;
6255-
}
62566256
if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_STOP) {
62576257
if (stop == ZEND_JIT_TRACE_STOP_LINK) {
62586258
uint32_t idx = trace_buffer[1].last;
@@ -6277,9 +6277,6 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
62776277
goto abort;
62786278
}
62796279
} else {
6280-
if (stop == ZEND_JIT_TRACE_STOP_HALT) {
6281-
ret = -1;
6282-
}
62836280
abort:
62846281
if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_ABORT) {
62856282
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
65346531
stop = zend_jit_trace_execute(execute_data, EX(opline), trace_buffer, ZEND_JIT_TRACE_START_SIDE, is_megamorphic);
65356532
JIT_G(tracing) = 0;
65366533

6534+
if (stop & ZEND_JIT_TRACE_HALT) {
6535+
ret = -1;
6536+
}
6537+
stop &= ~ZEND_JIT_TRACE_HALT;
6538+
65376539
if (UNEXPECTED(JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_BYTECODE)) {
65386540
zend_jit_dump_trace(trace_buffer, NULL);
65396541
}
65406542

65416543
if (ZEND_JIT_TRACE_STOP_OK(stop)) {
6542-
if (stop == ZEND_JIT_TRACE_STOP_RETURN_HALT) {
6543-
ret = -1;
6544-
}
65456544
if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_STOP) {
65466545
if (stop == ZEND_JIT_TRACE_STOP_LINK) {
65476546
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
65756574
goto abort;
65766575
}
65776576
} else {
6578-
if (stop == ZEND_JIT_TRACE_STOP_HALT) {
6579-
ret = -1;
6580-
}
65816577
abort:
65826578
if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_ABORT) {
65836579
fprintf(stderr, "---- TRACE %d abort (%s)\n",

ext/opcache/jit/zend_jit_vm_helpers.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
579579
#endif
580580
const zend_op *orig_opline, *end_opline;
581581
zend_jit_trace_stop stop = ZEND_JIT_TRACE_STOP_ERROR;
582+
zend_jit_trace_stop halt = 0;
582583
int level = 0;
583584
int ret_level = 0;
584585
int call_level;
@@ -762,15 +763,19 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
762763
#ifdef HAVE_GCC_GLOBAL_REGS
763764
handler();
764765
if (UNEXPECTED(opline == zend_jit_halt_op)) {
765-
stop = ZEND_JIT_TRACE_STOP_RETURN_HALT;
766+
stop = ZEND_JIT_TRACE_STOP_RETURN;
767+
opline = NULL;
768+
halt = ZEND_JIT_TRACE_HALT;
766769
break;
767770
}
768771
if (UNEXPECTED(execute_data != prev_execute_data)) {
769772
#else
770773
rc = handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
771774
if (rc != 0) {
772775
if (rc < 0) {
773-
stop = ZEND_JIT_TRACE_STOP_RETURN_HALT;
776+
stop = ZEND_JIT_TRACE_STOP_RETURN;
777+
opline = NULL;
778+
halt = ZEND_JIT_TRACE_HALT;
774779
break;
775780
} else if (execute_data == EG(current_execute_data)) {
776781
/* return after interrupt handler */
@@ -1035,8 +1040,7 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
10351040
TRACE_END(ZEND_JIT_TRACE_END, stop, end_opline);
10361041

10371042
#ifdef HAVE_GCC_GLOBAL_REGS
1038-
if (stop != ZEND_JIT_TRACE_STOP_HALT
1039-
&& stop != ZEND_JIT_TRACE_STOP_RETURN_HALT) {
1043+
if (!halt) {
10401044
EX(opline) = opline;
10411045
}
10421046
#endif
@@ -1046,5 +1050,5 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
10461050
opline = save_opline;
10471051
#endif
10481052

1049-
return stop;
1053+
return stop | halt;
10501054
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3532,7 +3532,6 @@ static int zend_jit_trace_handler(dasm_State **Dst, const zend_op_array *op_arra
35323532
}
35333533
if (trace->op != ZEND_JIT_TRACE_END ||
35343534
(trace->stop != ZEND_JIT_TRACE_STOP_RETURN &&
3535-
trace->stop != ZEND_JIT_TRACE_STOP_RETURN_HALT &&
35363535
trace->stop != ZEND_JIT_TRACE_STOP_INTERPRETER)) {
35373536

35383537
const zend_op *next_opline = trace->opline;

0 commit comments

Comments
 (0)