mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:17:45 +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:
parent
84c4b66721
commit
50428ea8d2
217 changed files with 1305 additions and 1039 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -7,10 +7,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Runtime/Intrinsics.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -33,6 +35,14 @@ public:
|
|||
[[nodiscard]] GlobalObject& global_object() const { return *m_global_object; }
|
||||
[[nodiscard]] GlobalEnvironment& global_environment() const { return *m_global_environment; }
|
||||
|
||||
[[nodiscard]] Intrinsics const& intrinsics() const { return *m_intrinsics; }
|
||||
[[nodiscard]] Intrinsics& intrinsics() { return *m_intrinsics; }
|
||||
void set_intrinsics(Badge<Intrinsics>, Intrinsics& intrinsics)
|
||||
{
|
||||
VERIFY(!m_intrinsics);
|
||||
m_intrinsics = &intrinsics;
|
||||
}
|
||||
|
||||
HostDefined* host_defined() { return m_host_defined; }
|
||||
void set_host_defined(OwnPtr<HostDefined> host_defined) { m_host_defined = move(host_defined); }
|
||||
|
||||
|
@ -40,6 +50,7 @@ private:
|
|||
virtual StringView class_name() const override { return "Realm"sv; }
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
Intrinsics* m_intrinsics { nullptr }; // [[Intrinsics]]
|
||||
GlobalObject* m_global_object { nullptr }; // [[GlobalObject]]
|
||||
GlobalEnvironment* m_global_environment { nullptr }; // [[GlobalEnv]]
|
||||
OwnPtr<HostDefined> m_host_defined; // [[HostDefined]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue