diff options
4 files changed, 6 insertions, 7 deletions
diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp index 3691d034b5..671126e0ab 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp @@ -58,8 +58,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::clear_kept_objects) JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm) { - auto* realm = Realm::create(vm); - VERIFY(realm); + auto realm = Realm::create(vm); auto* realm_global_object = vm.heap().allocate_without_realm<GlobalObject>(*realm); VERIFY(realm_global_object); realm->set_global_object(realm_global_object, nullptr); 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() }; |