diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 6168f542cc..4dab5e2717 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -344,4 +344,16 @@ private: OwnPtr m_bytecode_interpreter; }; +template +[[nodiscard]] static NonnullOwnPtr create_simple_execution_context(VM& vm, Args&&... args) +{ + auto root_execution_context = MUST(Realm::initialize_host_defined_realm( + vm, + [&](Realm& realm_) -> GlobalObject* { + return vm.heap().allocate_without_realm(realm_, forward(args)...); + }, + nullptr)); + return root_execution_context; +} + }