1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:38:11 +00:00

LibJS/Bytecode: Cache realm, global object, and more in interpreter

Instead of looking these up in the VM execution context stack whenever
we need them, we now just cache them in the interpreter when entering
a new call frame.
This commit is contained in:
Andreas Kling 2024-02-28 18:49:52 +01:00
parent 01e9eee7dd
commit 953573565c
3 changed files with 11 additions and 10 deletions

View file

@ -426,6 +426,9 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable& executa
TemporaryChange restore_executable { m_current_executable, &executable };
TemporaryChange restore_saved_jump { m_scheduled_jump, static_cast<BasicBlock const*>(nullptr) };
TemporaryChange restore_realm { m_realm, vm().current_realm() };
TemporaryChange restore_global_object { m_global_object, &m_realm->global_object() };
TemporaryChange restore_global_declarative_environment { m_global_declarative_environment, &m_realm->global_environment().declarative_record() };
VERIFY(!vm().execution_context_stack().is_empty());
@ -530,11 +533,6 @@ ThrowCompletionOr<NonnullGCPtr<Bytecode::Executable>> compile(VM& vm, ASTNode co
return bytecode_executable;
}
Realm& Interpreter::realm()
{
return *m_vm.current_realm();
}
void Interpreter::push_call_frame(Variant<NonnullOwnPtr<CallFrame>, CallFrame*> frame)
{
m_call_frames.append(move(frame));