From aef5932235bf44feb1c9ab6d01177c7a824f4244 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Thu, 18 Jan 2024 12:49:35 -0700 Subject: [PATCH] LibJS: Add method to VM to clear the execution context stack This is needed for the spin the event loop AO in LibWeb --- Userland/Libraries/LibJS/Runtime/VM.cpp | 5 +++++ Userland/Libraries/LibJS/Runtime/VM.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index 26751a4fa5..e100c10153 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -742,6 +742,11 @@ void VM::save_execution_context_stack() m_saved_execution_context_stacks.append(move(m_execution_context_stack)); } +void VM::clear_execution_context_stack() +{ + m_execution_context_stack.clear_with_capacity(); +} + void VM::restore_execution_context_stack() { m_execution_context_stack = m_saved_execution_context_stacks.take_last(); diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 9e835b9339..ad876b6e58 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -229,6 +229,7 @@ public: ThrowCompletionOr named_evaluation_if_anonymous_function(ASTNode const& expression, DeprecatedFlyString const& name); void save_execution_context_stack(); + void clear_execution_context_stack(); void restore_execution_context_stack(); // Do not call this method unless you are sure this is the only and first module to be loaded in this vm.