@@ -63,6 +63,7 @@ static int zend_jit_trace_startup(bool reattached)
63
63
ZEND_JIT_EXIT_COUNTERS = 0 ;
64
64
ZCSG (jit_traces ) = zend_jit_traces ;
65
65
ZCSG (jit_exit_groups ) = zend_jit_exit_groups ;
66
+ ZCSG (jit_counters_stopped ) = false;
66
67
} else {
67
68
zend_jit_traces = ZCSG (jit_traces );
68
69
if (!zend_jit_traces ) {
@@ -7255,16 +7256,23 @@ static void zend_jit_stop_persistent_script(zend_persistent_script *script)
7255
7256
/* Get all scripts which are accelerated by JIT */
7256
7257
static void zend_jit_stop_counter_handlers (void )
7257
7258
{
7259
+ if (ZCSG (jit_counters_stopped )) {
7260
+ return ;
7261
+ }
7262
+
7258
7263
zend_shared_alloc_lock ();
7259
7264
/* mprotect has an extreme overhead, avoid calls to it for every function. */
7260
7265
SHM_UNPROTECT ();
7261
- for (uint32_t i = 0 ; i < ZCSG (hash ).max_num_entries ; i ++ ) {
7262
- zend_accel_hash_entry * cache_entry ;
7263
- for (cache_entry = ZCSG (hash ).hash_table [i ]; cache_entry ; cache_entry = cache_entry -> next ) {
7264
- zend_persistent_script * script ;
7265
- if (cache_entry -> indirect ) continue ;
7266
- script = (zend_persistent_script * )cache_entry -> data ;
7267
- zend_jit_stop_persistent_script (script );
7266
+ if (!ZCSG (jit_counters_stopped )) {
7267
+ ZCSG (jit_counters_stopped ) = true;
7268
+ for (uint32_t i = 0 ; i < ZCSG (hash ).max_num_entries ; i ++ ) {
7269
+ zend_accel_hash_entry * cache_entry ;
7270
+ for (cache_entry = ZCSG (hash ).hash_table [i ]; cache_entry ; cache_entry = cache_entry -> next ) {
7271
+ zend_persistent_script * script ;
7272
+ if (cache_entry -> indirect ) continue ;
7273
+ script = (zend_persistent_script * )cache_entry -> data ;
7274
+ zend_jit_stop_persistent_script (script );
7275
+ }
7268
7276
}
7269
7277
}
7270
7278
SHM_PROTECT ();
@@ -8438,6 +8446,7 @@ static void zend_jit_trace_restart(void)
8438
8446
ZEND_JIT_COUNTER_NUM = 0 ;
8439
8447
ZEND_JIT_EXIT_NUM = 0 ;
8440
8448
ZEND_JIT_EXIT_COUNTERS = 0 ;
8449
+ ZCSG (jit_counters_stopped ) = false;
8441
8450
8442
8451
zend_jit_trace_init_caches ();
8443
8452
}
0 commit comments