1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Restored support for CPU cache demotion

This commit is contained in:
Dmitry Stogov
2023-12-01 11:56:02 +03:00
parent 9c0ca381d7
commit bf6b66febe
2 changed files with 9 additions and 10 deletions

View File

@@ -3424,10 +3424,6 @@ ZEND_EXT_API void zend_jit_startup(void *buf, size_t size, bool reattached)
zend_jit_halt_op = zend_get_halt_op();
zend_jit_profile_counter_rid = zend_get_op_array_extension_handle(ACCELERATOR_PRODUCT_NAME);
#if ZEND_JIT_SUPPORT_CLDEMOTE
cpu_support_cldemote = zend_cpu_supports_cldemote();
#endif
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
zend_write_protect = pthread_jit_write_protect_supported_np();
#endif

View File

@@ -162,6 +162,7 @@ static void ir_refs_add(ir_refs *refs, ir_ref ref)
static size_t zend_jit_trace_prologue_size = (size_t)-1;
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
static uint32_t allowed_opt_flags = 0;
static uint32_t default_mflags = 0;
#endif
static bool delayed_call_chain = 0; // TODO: remove this var (use jit->delayed_call_level) ???
@@ -2609,6 +2610,7 @@ static void zend_jit_init_ctx(zend_jit_ctx *jit, uint32_t flags)
jit->ctx.ret_type = -1;
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
jit->ctx.mflags |= default_mflags;
if (JIT_G(opt_flags) & allowed_opt_flags & ZEND_JIT_CPU_AVX) {
jit->ctx.mflags |= IR_X86_AVX;
}
@@ -3154,6 +3156,9 @@ static void zend_jit_setup(void)
if (zend_cpu_supports_avx()) {
allowed_opt_flags |= ZEND_JIT_CPU_AVX;
}
if (zend_cpu_supports_cldemote()) {
default_mflags |= IR_X86_CLDEMOTE;
}
#endif
#ifdef ZTS
#if defined(IR_TARGET_AARCH64)
@@ -15663,6 +15668,10 @@ static void *zend_jit_finish(zend_jit_ctx *jit)
} else if (jit->trace) {
jit->ctx.deoptimization_exits = jit->trace->exit_count;
jit->ctx.get_exit_addr = zend_jit_trace_get_exit_addr;
#endif
} else {
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
jit->ctx.flags |= IR_GEN_CACHE_DEMOTE;
#endif
}
@@ -15747,12 +15756,6 @@ static void *zend_jit_finish(zend_jit_ctx *jit)
}
zend_jit_trace_add_code(entry, size);
#if ZEND_JIT_SUPPORT_CLDEMOTE
if (cpu_support_cldemote) {
shared_cacheline_demote((uintptr_t)entry, size);
}
#endif
}
}