From 233097c250a7da825308d0886335268585bee075 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 28 Apr 2025 11:53:15 +0200 Subject: [PATCH] LibJS: Inline part of VM::run_queued_promise_jobs() Most of the time there are no queued promise jobs to run after exiting a stack frame. By moving the check inline, leaving a function call gets a measurable speedup in the common case. --- Libraries/LibJS/Runtime/VM.cpp | 2 +- Libraries/LibJS/Runtime/VM.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/Runtime/VM.cpp b/Libraries/LibJS/Runtime/VM.cpp index 0340e60dd4a..d12ed2dffc9 100644 --- a/Libraries/LibJS/Runtime/VM.cpp +++ b/Libraries/LibJS/Runtime/VM.cpp @@ -419,7 +419,7 @@ bool VM::in_strict_mode() const return running_execution_context().is_strict_mode; } -void VM::run_queued_promise_jobs() +void VM::run_queued_promise_jobs_impl() { dbgln_if(PROMISE_DEBUG, "Running queued promise jobs"); diff --git a/Libraries/LibJS/Runtime/VM.h b/Libraries/LibJS/Runtime/VM.h index 31c6c4cfad8..2a6cf4f1bbf 100644 --- a/Libraries/LibJS/Runtime/VM.h +++ b/Libraries/LibJS/Runtime/VM.h @@ -228,7 +228,13 @@ public: GC::Ptr object_Object; } cached_strings; - void run_queued_promise_jobs(); + void run_queued_promise_jobs() + { + if (m_promise_jobs.is_empty()) + return; + run_queued_promise_jobs_impl(); + } + void enqueue_promise_job(GC::Ref()>> job, Realm*); void run_queued_finalization_registry_cleanup_jobs(); @@ -299,6 +305,8 @@ private: void set_well_known_symbols(WellKnownSymbols well_known_symbols) { m_well_known_symbols = move(well_known_symbols); } + void run_queued_promise_jobs_impl(); + HashMap> m_string_cache; HashMap> m_utf16_string_cache;