mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Convert Realm::create() to NonnullGCPtr
This commit is contained in:
parent
e0818bf21e
commit
bfb8d83535
Notes:
sideshowbarker
2024-07-17 03:17:00 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/bfb8d83535 Pull-request: https://github.com/SerenityOS/serenity/pull/16479 Reviewed-by: https://github.com/davidot ✅
4 changed files with 6 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() };
|
||||
|
|
Loading…
Reference in a new issue