Skip to content

Commit bf6b66f

Browse files
committed
Restored support for CPU cache demotion
1 parent 9c0ca38 commit bf6b66f

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,10 +3424,6 @@ ZEND_EXT_API void zend_jit_startup(void *buf, size_t size, bool reattached)
34243424
zend_jit_halt_op = zend_get_halt_op();
34253425
zend_jit_profile_counter_rid = zend_get_op_array_extension_handle(ACCELERATOR_PRODUCT_NAME);
34263426

3427-
#if ZEND_JIT_SUPPORT_CLDEMOTE
3428-
cpu_support_cldemote = zend_cpu_supports_cldemote();
3429-
#endif
3430-
34313427
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
34323428
zend_write_protect = pthread_jit_write_protect_supported_np();
34333429
#endif

ext/opcache/jit/zend_jit_ir.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static void ir_refs_add(ir_refs *refs, ir_ref ref)
162162
static size_t zend_jit_trace_prologue_size = (size_t)-1;
163163
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
164164
static uint32_t allowed_opt_flags = 0;
165+
static uint32_t default_mflags = 0;
165166
#endif
166167
static bool delayed_call_chain = 0; // TODO: remove this var (use jit->delayed_call_level) ???
167168

@@ -2609,6 +2610,7 @@ static void zend_jit_init_ctx(zend_jit_ctx *jit, uint32_t flags)
26092610
jit->ctx.ret_type = -1;
26102611

26112612
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
2613+
jit->ctx.mflags |= default_mflags;
26122614
if (JIT_G(opt_flags) & allowed_opt_flags & ZEND_JIT_CPU_AVX) {
26132615
jit->ctx.mflags |= IR_X86_AVX;
26142616
}
@@ -3154,6 +3156,9 @@ static void zend_jit_setup(void)
31543156
if (zend_cpu_supports_avx()) {
31553157
allowed_opt_flags |= ZEND_JIT_CPU_AVX;
31563158
}
3159+
if (zend_cpu_supports_cldemote()) {
3160+
default_mflags |= IR_X86_CLDEMOTE;
3161+
}
31573162
#endif
31583163
#ifdef ZTS
31593164
#if defined(IR_TARGET_AARCH64)
@@ -15663,6 +15668,10 @@ static void *zend_jit_finish(zend_jit_ctx *jit)
1566315668
} else if (jit->trace) {
1566415669
jit->ctx.deoptimization_exits = jit->trace->exit_count;
1566515670
jit->ctx.get_exit_addr = zend_jit_trace_get_exit_addr;
15671+
#endif
15672+
} else {
15673+
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
15674+
jit->ctx.flags |= IR_GEN_CACHE_DEMOTE;
1566615675
#endif
1566715676
}
1566815677

@@ -15747,12 +15756,6 @@ static void *zend_jit_finish(zend_jit_ctx *jit)
1574715756
}
1574815757

1574915758
zend_jit_trace_add_code(entry, size);
15750-
15751-
#if ZEND_JIT_SUPPORT_CLDEMOTE
15752-
if (cpu_support_cldemote) {
15753-
shared_cacheline_demote((uintptr_t)entry, size);
15754-
}
15755-
#endif
1575615759
}
1575715760
}
1575815761

0 commit comments

Comments
 (0)