1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibJS: Remove {Bytecode::,}Interpreter::global_object()

The basic idea is that a global object cannot just come out of nowhere,
it must be associated to a realm - so get it from there, if needed.

This is to enforce the changes from all the previous commits by not
handing out global objects unless you actually have an initialized
realm (either stored somewhere, or the VM's current realm).
This commit is contained in:
Linus Groh 2022-08-22 19:35:23 +01:00
parent b345a0acca
commit 275dea9d98
10 changed files with 15 additions and 37 deletions

View file

@ -25,7 +25,6 @@ NonnullOwnPtr<Interpreter> Interpreter::create_with_existing_realm(Realm& realm)
auto& vm = realm.vm();
DeferGC defer_gc(vm.heap());
auto interpreter = adopt_own(*new Interpreter(vm));
interpreter->m_global_object = make_handle(&realm.global_object());
interpreter->m_realm = make_handle(&realm);
return interpreter;
}
@ -140,16 +139,6 @@ ThrowCompletionOr<Value> Interpreter::run(SourceTextModule& module)
return js_undefined();
}
GlobalObject& Interpreter::global_object()
{
return static_cast<GlobalObject&>(*m_global_object.cell());
}
GlobalObject const& Interpreter::global_object() const
{
return static_cast<GlobalObject const&>(*m_global_object.cell());
}
Realm& Interpreter::realm()
{
return static_cast<Realm&>(*m_realm.cell());