From da81b5c8d220257f79b70afd8a3e7e437c4f4869 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 20 Nov 2024 23:24:43 +0100 Subject: [PATCH] Reapply "Merge branch 'PHP-8.3' into PHP-8.4" This reverts commit 83ca37483c87f1de9384a6977f069589606c8640, and fixes the previous bad merge. --- NEWS | 6 ++++++ ext/opcache/ZendAccelerator.c | 1 + ext/opcache/jit/zend_jit.c | 9 +++++++++ ext/opcache/jit/zend_jit.h | 2 ++ 4 files changed, 18 insertions(+) diff --git a/NEWS b/NEWS index 337fc0b44fdb2..7505ebcd39f29 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +?? ??? ????, PHP 8.4.2 + +- Opcache: + . Fixed bug GH-16851 (JIT_G(enabled) not set correctly on other threads). + (dktapps) + 21 Nov 2024, PHP 8.4.1 - BcMath: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index e0f8cda2298e8..bf536c08153e2 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3282,6 +3282,7 @@ static zend_result accel_post_startup(void) zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Could not enable JIT: could not use reserved buffer!"); } else { zend_jit_startup(ZSMMG(reserved), jit_size, reattached); + zend_jit_startup_ok = true; } } #endif diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 54ffd79a35871..0c6ab6c5cbc8c 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -69,6 +69,8 @@ zend_jit_globals jit_globals; #define JIT_STUB_PREFIX "JIT$$" #define TRACE_PREFIX "TRACE-" +bool zend_jit_startup_ok = false; + zend_ulong zend_jit_profile_counter = 0; int zend_jit_profile_counter_rid = -1; @@ -3634,6 +3636,13 @@ static void zend_jit_reset_counters(void) void zend_jit_activate(void) { +#ifdef ZTS + if (!zend_jit_startup_ok) { + JIT_G(enabled) = 0; + JIT_G(on) = 0; + return; + } +#endif zend_jit_profile_counter = 0; if (JIT_G(on)) { if (JIT_G(trigger) == ZEND_JIT_ON_HOT_COUNTERS) { diff --git a/ext/opcache/jit/zend_jit.h b/ext/opcache/jit/zend_jit.h index 0ce6c1a4409a2..9178d340a0ede 100644 --- a/ext/opcache/jit/zend_jit.h +++ b/ext/opcache/jit/zend_jit.h @@ -100,6 +100,8 @@ typedef struct _zend_jit_trace_rec zend_jit_trace_rec; typedef struct _zend_jit_trace_stack_frame zend_jit_trace_stack_frame; typedef struct _sym_node zend_sym_node; +extern bool zend_jit_startup_ok; + typedef struct _zend_jit_globals { bool enabled; bool on;