Skip to content

Commit 2d86e95

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix zend_jit_stop_counter_handlers() performance issues with protect_memory=1
2 parents 56b1c11 + 5b033b0 commit 2d86e95

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7188,8 +7188,6 @@ static void zend_jit_stop_hot_trace_counters(zend_op_array *op_array)
71887188
uint32_t i;
71897189

71907190
jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
7191-
zend_shared_alloc_lock();
7192-
SHM_UNPROTECT();
71937191
for (i = 0; i < op_array->last; i++) {
71947192
/* Opline with Jit-ed code handler is skipped. */
71957193
if (jit_extension->trace_info[i].trace_flags &
@@ -7201,8 +7199,6 @@ static void zend_jit_stop_hot_trace_counters(zend_op_array *op_array)
72017199
op_array->opcodes[i].handler = jit_extension->trace_info[i].orig_handler;
72027200
}
72037201
}
7204-
SHM_PROTECT();
7205-
zend_shared_alloc_unlock();
72067202
}
72077203

72087204
/* Get the tracing op_array. */
@@ -7241,6 +7237,9 @@ static void zend_jit_stop_persistent_script(zend_persistent_script *script)
72417237
/* Get all scripts which are accelerated by JIT */
72427238
static void zend_jit_stop_counter_handlers(void)
72437239
{
7240+
zend_shared_alloc_lock();
7241+
/* mprotect has an extreme overhead, avoid calls to it for every function. */
7242+
SHM_UNPROTECT();
72447243
for (uint32_t i = 0; i < ZCSG(hash).max_num_entries; i++) {
72457244
zend_accel_hash_entry *cache_entry;
72467245
for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; cache_entry = cache_entry->next) {
@@ -7250,6 +7249,8 @@ static void zend_jit_stop_counter_handlers(void)
72507249
zend_jit_stop_persistent_script(script);
72517250
}
72527251
}
7252+
SHM_PROTECT();
7253+
zend_shared_alloc_unlock();
72537254
}
72547255

72557256
static void zend_jit_blacklist_root_trace(const zend_op *opline, size_t offset)

0 commit comments

Comments
 (0)