1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:27:43 +00:00

LibJS: Move intrinsics to the realm

Intrinsics, i.e. mostly constructor and prototype objects, but also
things like empty and new object shape now live on a new heap-allocated
JS::Intrinsics object, thus completing the long journey of taking all
the magic away from the global object.
This represents the Realm's [[Intrinsics]] slot in the spec and matches
its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of
architecture.

In the majority of cases it should now be possibly to fully allocate a
regular object without the global object existing, and in fact that's
what we do now - the realm is allocated before the global object, and
the intrinsics between both :^)
This commit is contained in:
Linus Groh 2022-08-27 00:54:55 +01:00
parent 84c4b66721
commit 50428ea8d2
217 changed files with 1305 additions and 1039 deletions

View file

@ -201,7 +201,7 @@ ThrowCompletionOr<Promise*> CyclicModule::evaluate(VM& vm)
// 6. Let capability be ! NewPromiseCapability(%Promise%).
// 7. Set module.[[TopLevelCapability]] to capability.
m_top_level_capability = MUST(new_promise_capability(vm, realm.global_object().promise_constructor()));
m_top_level_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
// 8. Let result be Completion(InnerModuleEvaluation(module, stack, 0)).
auto result = inner_module_evaluation(vm, stack, 0);
@ -442,7 +442,7 @@ void CyclicModule::execute_async_module(VM& vm)
VERIFY(m_has_top_level_await);
// 3. Let capability be ! NewPromiseCapability(%Promise%).
auto capability = MUST(new_promise_capability(vm, realm.global_object().promise_constructor()));
auto capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
// 4. Let fulfilledClosure be a new Abstract Closure with no parameters that captures module and performs the following steps when called:
auto fulfilled_closure = [&](VM& vm) -> ThrowCompletionOr<Value> {