From 845661588fd3fde3b64fce05d84a72ca17f8889c Mon Sep 17 00:00:00 2001 From: ndossche <7771979+ndossche@users.noreply.github.com> Date: Fri, 2 Oct 2026 22:45:02 +0200 Subject: [PATCH] Use ZEND_OPCACHE_SHM_REATTACHMENT more commonly --- Zend/Optimizer/zend_optimizer.c | 4 ++-- Zend/zend_inheritance.c | 6 +++--- ext/opcache/jit/zend_jit.c | 4 ++-- ext/opcache/jit/zend_jit_ir.c | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Zend/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c index 6d5b5f541a90..db5cd03a4e44 100644 --- a/Zend/Optimizer/zend_optimizer.c +++ b/Zend/Optimizer/zend_optimizer.c @@ -108,7 +108,7 @@ zend_result zend_optimizer_eval_special_func_call( if (func && func->type == ZEND_INTERNAL_FUNCTION && func->module->type == MODULE_PERSISTENT -#ifdef ZEND_WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT && func->module->handle == NULL #endif ) { @@ -129,7 +129,7 @@ zend_result zend_optimizer_eval_special_func_call( } if (m->type == MODULE_PERSISTENT -#ifdef ZEND_WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT && m->handle == NULL #endif ) { diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 4424c9a1a3ab..82a3e23b6806 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -390,8 +390,8 @@ static void track_class_dependency(zend_class_entry *ce, zend_string *class_name return; } -#ifndef ZEND_WIN32 - /* On non-Windows systems, internal classes are always the same, +#ifndef ZEND_OPCACHE_SHM_REATTACHMENT + /* On systems without reattachment, internal classes are always the same, * so there is no need to explicitly track them. */ if (ce->type == ZEND_INTERNAL_CLASS) { return; @@ -3619,7 +3619,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string } } -#ifndef ZEND_WIN32 +#ifndef ZEND_OPCACHE_SHM_REATTACHMENT if (ce->ce_flags & ZEND_ACC_ENUM) { /* We will add internal methods. */ is_cacheable = false; diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 7b6f62237859..6ea96a829301 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -704,7 +704,7 @@ static bool zend_jit_class_may_be_modified(const zend_class_entry *ce, const zen uint32_t i; if (ce->type == ZEND_INTERNAL_CLASS) { -#ifdef _WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT /* ASLR */ return 1; #else @@ -752,7 +752,7 @@ static bool zend_jit_class_may_be_modified(const zend_class_entry *ce, const zen static bool zend_jit_may_be_modified(const zend_function *func, const zend_op_array *called_from) { if (func->type == ZEND_INTERNAL_FUNCTION) { -#ifdef _WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT /* ASLR */ return 1; #else diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index c7716eb96ff8..66f07794fd6a 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -8582,7 +8582,7 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co if_enough_stack = ir_IF(ref); ir_IF_FALSE_cold(if_enough_stack); -#ifdef _WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT if (0) { #else if (opline->opcode == ZEND_INIT_FCALL && func && func->type == ZEND_INTERNAL_FUNCTION) { @@ -8631,7 +8631,7 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co // JIT: ZEND_SET_CALL_INFO(call, 0, call_info); ir_STORE(jit_CALL(rx, This.u1.type_info), ir_CONST_U32(IS_UNDEF | ZEND_CALL_NESTED_FUNCTION)); } -#ifdef _WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT if (0) { #else if (opline->opcode == ZEND_INIT_FCALL && func && func->type == ZEND_INTERNAL_FUNCTION) { @@ -8768,7 +8768,7 @@ static int zend_jit_func_guard(zend_jit_ctx *jit, ir_ref func_ref, const zend_fu ir_LOAD_A(ir_ADD_OFFSET(func_ref, offsetof(zend_op_array, opcodes))), ir_CONST_ADDR(opcodes)), ir_CONST_ADDR(exit_addr)); -#ifdef ZEND_WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT } else if (func->type == ZEND_INTERNAL_FUNCTION) { // ASLR may cause different addresses in different workers. Check for the internal function handler. // JIT: if (call->func.internal_function.handler != handler) goto exit_addr; @@ -8841,7 +8841,7 @@ static int zend_jit_init_fcall(zend_jit_ctx *jit, const zend_op *opline, uint32_ if (!func && trace && trace->op == ZEND_JIT_TRACE_INIT_CALL) { -#ifdef _WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT /* ASLR */ if (trace->func->type != ZEND_INTERNAL_FUNCTION) { func = (zend_function*)trace->func; @@ -8851,7 +8851,7 @@ static int zend_jit_init_fcall(zend_jit_ctx *jit, const zend_op *opline, uint32_ #endif } -#ifdef _WIN32 +#ifdef ZEND_OPCACHE_SHM_REATTACHMENT if (0) { #else if (opline->opcode == ZEND_INIT_FCALL @@ -10092,7 +10092,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen if (trace && !func) { if (trace->op == ZEND_JIT_TRACE_DO_ICALL) { ZEND_ASSERT(!trace->func || trace->func->type == ZEND_INTERNAL_FUNCTION); -#ifndef ZEND_WIN32 +#ifndef ZEND_OPCACHE_SHM_REATTACHMENT // TODO: ASLR may cause different addresses in different workers ??? func = trace->func; if (JIT_G(current_frame) &&