summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-13 20:49:50 +0000
committerLinus Groh <mail@linusgroh.de>2022-12-14 09:59:45 +0000
commitbfb8d835350e5a8c076be64dbb2f5d288f962595 (patch)
treef83217463064de3216b3174c25eddf30d373b584 /Userland/Libraries/LibJS/Runtime
parente0818bf21e08f142516dca4c9aca1e86b6cd67ed (diff)
downloadserenity-bfb8d835350e5a8c076be64dbb2f5d288f962595.zip
LibJS: Convert Realm::create() to NonnullGCPtr
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Realm.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Realm.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp2
3 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Realm.cpp b/Userland/Libraries/LibJS/Runtime/Realm.cpp
index 5a70f10258..ff7206219f 100644
--- a/Userland/Libraries/LibJS/Runtime/Realm.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Realm.cpp
@@ -15,7 +15,7 @@
namespace JS {
// 9.3.1 CreateRealm ( ), https://tc39.es/ecma262/#sec-createrealm
-Realm* Realm::create(VM& vm)
+NonnullGCPtr<Realm> Realm::create(VM& vm)
{
// 1. Let realmRec be a new Realm Record.
auto* realm = vm.heap().allocate_without_realm<Realm>();
@@ -28,7 +28,7 @@ Realm* Realm::create(VM& vm)
// 5. Set realmRec.[[TemplateMap]] to a new empty List.
// 6. Return realmRec.
- return realm;
+ return *realm;
}
// 9.6 InitializeHostDefinedRealm ( ), https://tc39.es/ecma262/#sec-initializehostdefinedrealm
@@ -37,7 +37,7 @@ ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> Realm::initialize_host_define
DeferGC defer_gc(vm.heap());
// 1. Let realm be CreateRealm().
- auto* realm = Realm::create(vm);
+ auto realm = Realm::create(vm);
// 2. Let newContext be a new execution context.
auto new_context = make<ExecutionContext>(vm.heap());
diff --git a/Userland/Libraries/LibJS/Runtime/Realm.h b/Userland/Libraries/LibJS/Runtime/Realm.h
index e4a5aee610..e56f58f107 100644
--- a/Userland/Libraries/LibJS/Runtime/Realm.h
+++ b/Userland/Libraries/LibJS/Runtime/Realm.h
@@ -29,7 +29,7 @@ public:
virtual void visit_edges(Cell::Visitor&) { }
};
- static Realm* create(VM&);
+ static NonnullGCPtr<Realm> create(VM&);
static ThrowCompletionOr<NonnullOwnPtr<ExecutionContext>> initialize_host_defined_realm(VM&, Function<Object*(Realm&)> create_global_object, Function<Object*(Realm&)> create_global_this_value);
void set_global_object(Object* global_object, Object* this_value);
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
index 853240f564..b3508761a0 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp
@@ -42,7 +42,7 @@ ThrowCompletionOr<Object*> ShadowRealmConstructor::construct(FunctionObject& new
auto& vm = this->vm();
// 3. Let realmRec be CreateRealm().
- auto* realm = Realm::create(vm);
+ auto realm = Realm::create(vm);
// 5. Let context be a new execution context.
auto context = ExecutionContext { vm.heap() };