Skip to content

Commit 9aa8e88

Browse files
authored
Remove zend_jit_vm_kind (#19299)
JIT used to not have a compile-time dependency on VM kind, such that a single build of opcache could work with different VM kinds at runtime. This has been broken over time and would be difficult to restore. Additionally, as opcache is now built-in, this would not be useful anymore. Remove the zend_jit_vm_kind variable.
1 parent 98e0dbc commit 9aa8e88

File tree

2 files changed

+25
-31
lines changed

2 files changed

+25
-31
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ int zend_jit_profile_counter_rid = -1;
7777
int16_t zend_jit_hot_counters[ZEND_HOT_COUNTERS_COUNT];
7878

7979
const zend_op *zend_jit_halt_op = NULL;
80-
static int zend_jit_vm_kind = 0;
8180
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
8281
static int zend_write_protect = 1;
8382
#endif
@@ -3707,19 +3706,14 @@ void zend_jit_init(void)
37073706
#endif
37083707
}
37093708

3709+
#if ZEND_VM_KIND != ZEND_VM_KIND_CALL && ZEND_VM_KIND != ZEND_VM_KIND_HYBRID
3710+
# error JIT is compatible only with CALL and HYBRID VM
3711+
#endif
3712+
37103713
int zend_jit_check_support(void)
37113714
{
37123715
int i;
37133716

3714-
zend_jit_vm_kind = zend_vm_kind();
3715-
if (zend_jit_vm_kind != ZEND_VM_KIND_CALL &&
3716-
zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
3717-
zend_error(E_WARNING, "JIT is compatible only with CALL and HYBRID VM. JIT disabled.");
3718-
JIT_G(enabled) = 0;
3719-
JIT_G(on) = 0;
3720-
return FAILURE;
3721-
}
3722-
37233717
if (zend_execute_ex != execute_ex) {
37243718
if (zend_dtrace_enabled) {
37253719
zend_error(E_WARNING, "JIT is incompatible with DTrace. JIT disabled.");

ext/opcache/jit/zend_jit_ir.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ static void zend_jit_vm_leave(zend_jit_ctx *jit, ir_ref to_opline)
19261926

19271927
static int zend_jit_exception_handler_stub(zend_jit_ctx *jit)
19281928
{
1929-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
1929+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
19301930
zend_vm_opcode_handler_func_t handler = (zend_vm_opcode_handler_func_t)zend_get_opcode_handler_func(EG(exception_op));
19311931

19321932
ir_CALL(IR_VOID, ir_CONST_FUNC(handler));
@@ -2051,7 +2051,7 @@ static int zend_jit_leave_function_handler_stub(zend_jit_ctx *jit)
20512051

20522052
ir_IF_FALSE(if_top);
20532053

2054-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
2054+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
20552055
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_leave_nested_func_helper), call_info);
20562056
jit_STORE_IP(jit,
20572057
ir_LOAD_A(jit_EX(opline)));
@@ -2064,7 +2064,7 @@ static int zend_jit_leave_function_handler_stub(zend_jit_ctx *jit)
20642064

20652065
ir_IF_TRUE(if_top);
20662066

2067-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
2067+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
20682068
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_leave_top_func_helper), call_info);
20692069
ir_TAILCALL(IR_VOID, ir_LOAD_A(jit_IP(jit)));
20702070
} else if (GCC_GLOBAL_REGS) {
@@ -2248,7 +2248,7 @@ static int zend_jit_leave_throw_stub(zend_jit_ctx *jit)
22482248

22492249
static int zend_jit_hybrid_runtime_jit_stub(zend_jit_ctx *jit)
22502250
{
2251-
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
2251+
if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID) {
22522252
return 0;
22532253
}
22542254

@@ -2261,7 +2261,7 @@ static int zend_jit_hybrid_profile_jit_stub(zend_jit_ctx *jit)
22612261
{
22622262
ir_ref addr, func, run_time_cache, jit_extension;
22632263

2264-
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
2264+
if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID) {
22652265
return 0;
22662266
}
22672267

@@ -2317,7 +2317,7 @@ static int _zend_jit_hybrid_hot_counter_stub(zend_jit_ctx *jit, uint32_t cost)
23172317

23182318
static int zend_jit_hybrid_func_hot_counter_stub(zend_jit_ctx *jit)
23192319
{
2320-
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID || !JIT_G(hot_func)) {
2320+
if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID || !JIT_G(hot_func)) {
23212321
return 0;
23222322
}
23232323

@@ -2327,7 +2327,7 @@ static int zend_jit_hybrid_func_hot_counter_stub(zend_jit_ctx *jit)
23272327

23282328
static int zend_jit_hybrid_loop_hot_counter_stub(zend_jit_ctx *jit)
23292329
{
2330-
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID || !JIT_G(hot_loop)) {
2330+
if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID || !JIT_G(hot_loop)) {
23312331
return 0;
23322332
}
23332333

@@ -2389,7 +2389,7 @@ static int _zend_jit_hybrid_trace_counter_stub(zend_jit_ctx *jit, uint32_t cost)
23892389

23902390
static int zend_jit_hybrid_func_trace_counter_stub(zend_jit_ctx *jit)
23912391
{
2392-
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID || !JIT_G(hot_func)) {
2392+
if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID || !JIT_G(hot_func)) {
23932393
return 0;
23942394
}
23952395

@@ -2399,7 +2399,7 @@ static int zend_jit_hybrid_func_trace_counter_stub(zend_jit_ctx *jit)
23992399

24002400
static int zend_jit_hybrid_ret_trace_counter_stub(zend_jit_ctx *jit)
24012401
{
2402-
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID || !JIT_G(hot_return)) {
2402+
if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID || !JIT_G(hot_return)) {
24032403
return 0;
24042404
}
24052405

@@ -2409,7 +2409,7 @@ static int zend_jit_hybrid_ret_trace_counter_stub(zend_jit_ctx *jit)
24092409

24102410
static int zend_jit_hybrid_loop_trace_counter_stub(zend_jit_ctx *jit)
24112411
{
2412-
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID || !JIT_G(hot_loop)) {
2412+
if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID || !JIT_G(hot_loop)) {
24132413
return 0;
24142414
}
24152415

@@ -2419,7 +2419,7 @@ static int zend_jit_hybrid_loop_trace_counter_stub(zend_jit_ctx *jit)
24192419

24202420
static int zend_jit_trace_halt_stub(zend_jit_ctx *jit)
24212421
{
2422-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
2422+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
24232423
ir_TAILCALL(IR_VOID, ir_CONST_FC_FUNC(zend_jit_halt_op->handler));
24242424
} else if (GCC_GLOBAL_REGS) {
24252425
jit_STORE_IP(jit, IR_NULL);
@@ -2676,7 +2676,7 @@ static void zend_jit_init_ctx(zend_jit_ctx *jit, uint32_t flags)
26762676
jit->ctx.fixed_regset = (1<<ZREG_FP) | (1<<ZREG_IP);
26772677
if (!(flags & IR_FUNCTION)) {
26782678
jit->ctx.flags |= IR_NO_STACK_COMBINE;
2679-
if (zend_jit_vm_kind == ZEND_VM_KIND_CALL) {
2679+
if (ZEND_VM_KIND == ZEND_VM_KIND_CALL) {
26802680
jit->ctx.flags |= IR_FUNCTION;
26812681
/* Stack must be 16 byte aligned */
26822682
/* TODO: select stack size ??? */
@@ -3146,7 +3146,7 @@ static void zend_jit_calc_trace_prologue_size(void)
31463146
void *entry;
31473147
size_t size;
31483148

3149-
zend_jit_init_ctx(jit, (zend_jit_vm_kind == ZEND_VM_KIND_CALL) ? 0 : IR_START_BR_TARGET);
3149+
zend_jit_init_ctx(jit, (ZEND_VM_KIND == ZEND_VM_KIND_CALL) ? 0 : IR_START_BR_TARGET);
31503150

31513151
if (!GCC_GLOBAL_REGS) {
31523152
ir_ref execute_data_ref = ir_PARAM(IR_ADDR, "execute_data", 1);
@@ -3333,7 +3333,7 @@ static void zend_jit_setup(bool reattached)
33333333
#endif
33343334

33353335
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
3336-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
3336+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
33373337
zend_jit_set_sp_adj_vm(); // set zend_jit_hybrid_vm_sp_adj
33383338
}
33393339
#endif
@@ -4073,7 +4073,7 @@ static int zend_jit_tail_handler(zend_jit_ctx *jit, const zend_op *opline)
40734073
zend_basic_block *bb;
40744074

40754075
zend_jit_set_ip(jit, opline);
4076-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
4076+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
40774077
if (opline->opcode == ZEND_DO_UCALL ||
40784078
opline->opcode == ZEND_DO_FCALL_BY_NAME ||
40794079
opline->opcode == ZEND_DO_FCALL ||
@@ -10984,7 +10984,7 @@ static int zend_jit_leave_func(zend_jit_ctx *jit,
1098410984

1098510985
if (may_be_top_frame) {
1098610986
// TODO: try to avoid this check ???
10987-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
10987+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
1098810988
#if 0
1098910989
/* this check should be handled by the following OPLINE guard */
1099010990
| cmp IP, zend_jit_halt_op
@@ -16566,7 +16566,7 @@ static int zend_jit_start(zend_jit_ctx *jit, const zend_op_array *op_array, zend
1656616566
int i, count;
1656716567
zend_basic_block *bb;
1656816568

16569-
zend_jit_init_ctx(jit, (zend_jit_vm_kind == ZEND_VM_KIND_CALL) ? 0 : (IR_START_BR_TARGET|IR_ENTRY_BR_TARGET));
16569+
zend_jit_init_ctx(jit, (ZEND_VM_KIND == ZEND_VM_KIND_CALL) ? 0 : (IR_START_BR_TARGET|IR_ENTRY_BR_TARGET));
1657016570

1657116571
jit->ctx.spill_base = ZREG_FP;
1657216572

@@ -16644,7 +16644,7 @@ static zend_vm_opcode_handler_t zend_jit_finish(zend_jit_ctx *jit)
1664416644

1664516645
// ir_mem_unprotect(entry, size);
1664616646
if (!(jit->ctx.flags & IR_FUNCTION)
16647-
&& zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
16647+
&& ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
1664816648
#if !defined(ZEND_WIN32) && !defined(IR_TARGET_AARCH64)
1664916649
sp_offset = zend_jit_hybrid_vm_sp_adj;
1665016650
#else
@@ -17012,7 +17012,7 @@ static int zend_jit_trace_handler(zend_jit_ctx *jit, const zend_op_array *op_arr
1701217012
opline->opcode == ZEND_RETURN_BY_REF ||
1701317013
opline->opcode == ZEND_GENERATOR_CREATE) {
1701417014

17015-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
17015+
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
1701617016
if (trace->op != ZEND_JIT_TRACE_END ||
1701717017
(trace->stop != ZEND_JIT_TRACE_STOP_RETURN &&
1701817018
trace->stop < ZEND_JIT_TRACE_STOP_INTERPRETER)) {
@@ -17126,7 +17126,7 @@ static int zend_jit_deoptimizer_start(zend_jit_ctx *jit,
1712617126
uint32_t trace_num,
1712717127
uint32_t exit_num)
1712817128
{
17129-
zend_jit_init_ctx(jit, (zend_jit_vm_kind == ZEND_VM_KIND_CALL) ? 0 : IR_START_BR_TARGET);
17129+
zend_jit_init_ctx(jit, (ZEND_VM_KIND == ZEND_VM_KIND_CALL) ? 0 : IR_START_BR_TARGET);
1713017130

1713117131
jit->ctx.spill_base = ZREG_FP;
1713217132

@@ -17147,7 +17147,7 @@ static int zend_jit_trace_start(zend_jit_ctx *jit,
1714717147
zend_jit_trace_info *parent,
1714817148
uint32_t exit_num)
1714917149
{
17150-
zend_jit_init_ctx(jit, (zend_jit_vm_kind == ZEND_VM_KIND_CALL) ? 0 : IR_START_BR_TARGET);
17150+
zend_jit_init_ctx(jit, (ZEND_VM_KIND == ZEND_VM_KIND_CALL) ? 0 : IR_START_BR_TARGET);
1715117151

1715217152
jit->ctx.spill_base = ZREG_FP;
1715317153

0 commit comments

Comments
 (0)