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

Merge branch 'PHP-8.2'

* PHP-8.2:
  Fix zend_jit_stop_counter_handlers() performance issues with protect_memory=1
This commit is contained in:
Ilija Tovilo
2023-05-26 10:55:46 +02:00

View File

@@ -7188,8 +7188,6 @@ static void zend_jit_stop_hot_trace_counters(zend_op_array *op_array)
uint32_t i; uint32_t i;
jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array); jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
zend_shared_alloc_lock();
SHM_UNPROTECT();
for (i = 0; i < op_array->last; i++) { for (i = 0; i < op_array->last; i++) {
/* Opline with Jit-ed code handler is skipped. */ /* Opline with Jit-ed code handler is skipped. */
if (jit_extension->trace_info[i].trace_flags & 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)
op_array->opcodes[i].handler = jit_extension->trace_info[i].orig_handler; op_array->opcodes[i].handler = jit_extension->trace_info[i].orig_handler;
} }
} }
SHM_PROTECT();
zend_shared_alloc_unlock();
} }
/* Get the tracing op_array. */ /* Get the tracing op_array. */
@@ -7241,6 +7237,9 @@ static void zend_jit_stop_persistent_script(zend_persistent_script *script)
/* Get all scripts which are accelerated by JIT */ /* Get all scripts which are accelerated by JIT */
static void zend_jit_stop_counter_handlers(void) static void zend_jit_stop_counter_handlers(void)
{ {
zend_shared_alloc_lock();
/* mprotect has an extreme overhead, avoid calls to it for every function. */
SHM_UNPROTECT();
for (uint32_t i = 0; i < ZCSG(hash).max_num_entries; i++) { for (uint32_t i = 0; i < ZCSG(hash).max_num_entries; i++) {
zend_accel_hash_entry *cache_entry; zend_accel_hash_entry *cache_entry;
for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; cache_entry = cache_entry->next) { 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)
zend_jit_stop_persistent_script(script); zend_jit_stop_persistent_script(script);
} }
} }
SHM_PROTECT();
zend_shared_alloc_unlock();
} }
static void zend_jit_blacklist_root_trace(const zend_op *opline, size_t offset) static void zend_jit_blacklist_root_trace(const zend_op *opline, size_t offset)