diff options
Diffstat (limited to 'Userland')
314 files changed, 568 insertions, 532 deletions
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index dcd67770e5..95b924ec32 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -365,8 +365,8 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound) return JS::Value(bounds.row); } -WorkbookObject::WorkbookObject(Workbook& workbook, JS::GlobalObject& global_object) - : JS::Object(*JS::Object::create(global_object, global_object.object_prototype())) +WorkbookObject::WorkbookObject(JS::Realm& realm, Workbook& workbook) + : JS::Object(*realm.global_object().object_prototype()) , m_workbook(workbook) { } diff --git a/Userland/Applications/Spreadsheet/JSIntegration.h b/Userland/Applications/Spreadsheet/JSIntegration.h index f879c99880..78433d0f5b 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.h +++ b/Userland/Applications/Spreadsheet/JSIntegration.h @@ -50,7 +50,7 @@ class WorkbookObject final : public JS::Object { JS_OBJECT(WorkbookObject, JS::Object); public: - WorkbookObject(Workbook&, JS::GlobalObject&); + WorkbookObject(JS::Realm&, Workbook&); virtual ~WorkbookObject() override = default; diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index b418c49cbe..aae822b2e8 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -29,7 +29,7 @@ Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_wind , m_main_execution_context(m_vm->heap()) , m_parent_window(parent_window) { - m_workbook_object = m_vm->heap().allocate<WorkbookObject>(m_interpreter->global_object(), *this, m_interpreter->global_object()); + m_workbook_object = m_vm->heap().allocate<WorkbookObject>(m_interpreter->global_object(), m_interpreter->realm(), *this); m_interpreter->global_object().define_direct_property("workbook", workbook_object(), JS::default_attributes); m_main_execution_context.current_node = nullptr; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp index 23b2e206a3..ef3fdc30e0 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp @@ -18,8 +18,8 @@ namespace JS::Test262 { -$262Object::$262Object(JS::GlobalObject& global_object) - : Object(Object::ConstructWithoutPrototypeTag::Tag, global_object) +$262Object::$262Object(Realm& realm) + : Object(Object::ConstructWithoutPrototypeTag::Tag, realm) { } @@ -27,8 +27,9 @@ void $262Object::initialize(JS::GlobalObject& global_object) { Base::initialize(global_object); - m_agent = vm().heap().allocate<AgentObject>(global_object, global_object); - m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(global_object, global_object); + auto& realm = *global_object.associated_realm(); + m_agent = vm().heap().allocate<AgentObject>(global_object, realm); + m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(global_object, realm); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function("clearKeptObjects", clear_kept_objects, 0, attr); diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h index 08caddd6bb..79445dee1c 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h @@ -17,7 +17,7 @@ class $262Object final : public Object { JS_OBJECT($262Object, Object); public: - $262Object(JS::GlobalObject&); + explicit $262Object(Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~$262Object() override = default; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp index c801485b5b..fbc8ef4b14 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp @@ -12,8 +12,8 @@ namespace JS::Test262 { -AgentObject::AgentObject(JS::GlobalObject& global_object) - : Object(Object::ConstructWithoutPrototypeTag::Tag, global_object) +AgentObject::AgentObject(Realm& realm) + : Object(Object::ConstructWithoutPrototypeTag::Tag, realm) { } diff --git a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h index 2a961305d8..eeed225a89 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h @@ -15,7 +15,7 @@ class AgentObject final : public Object { JS_OBJECT(AgentObject, Object); public: - AgentObject(JS::GlobalObject&); + explicit AgentObject(Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~AgentObject() override = default; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp index 1a7bf5e212..fe6d29f7d4 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp @@ -18,7 +18,8 @@ void GlobalObject::initialize_global_object() { Base::initialize_global_object(); - m_$262 = vm().heap().allocate<$262Object>(*this, *this); + auto& realm = *associated_realm(); + m_$262 = vm().heap().allocate<$262Object>(*this, realm); // https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions u8 attr = Attribute::Writable | Attribute::Configurable; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp index 8c60c99b2b..68b6a37398 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.cpp @@ -9,9 +9,9 @@ namespace JS::Test262 { -IsHTMLDDA::IsHTMLDDA(JS::GlobalObject& global_object) +IsHTMLDDA::IsHTMLDDA(Realm& realm) // NativeFunction without prototype is currently not possible (only due to the lack of a ctor that supports it) - : NativeFunction("IsHTMLDDA", *global_object.function_prototype()) + : NativeFunction("IsHTMLDDA", *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h index a08d09a2b8..f34322e4ea 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h @@ -14,7 +14,7 @@ class IsHTMLDDA final : public NativeFunction { JS_OBJECT(IsHTMLDDA, NativeFunction); public: - explicit IsHTMLDDA(JS::GlobalObject&); + explicit IsHTMLDDA(Realm&); virtual ~IsHTMLDDA() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Module.cpp b/Userland/Libraries/LibJS/Module.cpp index 92d5db9b21..ef3d315a05 100644 --- a/Userland/Libraries/LibJS/Module.cpp +++ b/Userland/Libraries/LibJS/Module.cpp @@ -97,7 +97,7 @@ Object* Module::module_namespace_create(VM& vm, Vector<FlyString> unambiguous_na // 6. Let sortedExports be a List whose elements are the elements of exports ordered as if an Array of the same values had been sorted using %Array.prototype.sort% using undefined as comparefn. // 7. Set M.[[Exports]] to sortedExports. // 8. Create own properties of M corresponding to the definitions in 28.3. - Object* module_namespace = vm.heap().allocate<ModuleNamespaceObject>(realm().global_object(), realm().global_object(), this, move(unambiguous_names)); + Object* module_namespace = vm.heap().allocate<ModuleNamespaceObject>(realm().global_object(), realm(), this, move(unambiguous_names)); // 9. Set module.[[Namespace]] to M. m_namespace = make_handle(module_namespace); diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 3c13c0f3f0..a26fe25f39 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -1076,6 +1076,7 @@ Object* create_unmapped_arguments_object(GlobalObject& global_object, Span<Value Object* create_mapped_arguments_object(GlobalObject& global_object, FunctionObject& function, Vector<FunctionNode::Parameter> const& formals, Span<Value> arguments, Environment& environment) { auto& vm = global_object.vm(); + auto& realm = *global_object.associated_realm(); // 1. Assert: formals does not contain a rest parameter, any binding patterns, or any initializers. It may contain duplicate identifiers. @@ -1090,7 +1091,7 @@ Object* create_mapped_arguments_object(GlobalObject& global_object, FunctionObje // 7. Set obj.[[Set]] as specified in 10.4.4.4. // 8. Set obj.[[Delete]] as specified in 10.4.4.5. // 9. Set obj.[[Prototype]] to %Object.prototype%. - auto* object = vm.heap().allocate<ArgumentsObject>(global_object, global_object, environment); + auto* object = vm.heap().allocate<ArgumentsObject>(global_object, realm, environment); // 14. Let index be 0. // 15. Repeat, while index < len, diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp index 73c364744c..8562f99df7 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp @@ -14,8 +14,8 @@ namespace JS { -AggregateErrorConstructor::AggregateErrorConstructor(GlobalObject& global_object) - : NativeFunction(*static_cast<Object*>(global_object.error_constructor())) +AggregateErrorConstructor::AggregateErrorConstructor(Realm& realm) + : NativeFunction(static_cast<Object&>(*realm.global_object().error_constructor())) { } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h index 94d272a653..42ddad0121 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h @@ -14,7 +14,7 @@ class AggregateErrorConstructor final : public NativeFunction { JS_OBJECT(AggregateErrorConstructor, NativeFunction); public: - explicit AggregateErrorConstructor(GlobalObject&); + explicit AggregateErrorConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AggregateErrorConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp index ae37c8bea8..33e09e4c81 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp @@ -10,8 +10,8 @@ namespace JS { -AggregateErrorPrototype::AggregateErrorPrototype(GlobalObject& global_object) - : Object(*global_object.error_prototype()) +AggregateErrorPrototype::AggregateErrorPrototype(Realm& realm) + : Object(*realm.global_object().error_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h index 2820175dfc..a2f4d56b9b 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h @@ -14,7 +14,7 @@ class AggregateErrorPrototype final : public Object { JS_OBJECT(AggregateErrorPrototype, Object); public: - explicit AggregateErrorPrototype(GlobalObject&); + explicit AggregateErrorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AggregateErrorPrototype() override = default; }; diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp index f9b6d0eb90..ddbbdaa778 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp @@ -10,8 +10,8 @@ namespace JS { -ArgumentsObject::ArgumentsObject(GlobalObject& global_object, Environment& environment) - : Object(*global_object.object_prototype()) +ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment) + : Object(*realm.global_object().object_prototype()) , m_environment(environment) { } diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h index b8a9c3b2e2..895592325e 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h @@ -16,7 +16,7 @@ class ArgumentsObject final : public Object { JS_OBJECT(ArgumentsObject, Object); public: - ArgumentsObject(GlobalObject&, Environment&); + ArgumentsObject(Realm&, Environment&); virtual void initialize(GlobalObject&) override; virtual ~ArgumentsObject() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp index 2b9c6e2f55..a4e1ead4a2 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp @@ -13,8 +13,8 @@ namespace JS { -ArrayBufferConstructor::ArrayBufferConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.ArrayBuffer.as_string(), *global_object.function_prototype()) +ArrayBufferConstructor::ArrayBufferConstructor(Realm& realm) + : NativeFunction(vm().names.ArrayBuffer.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h index 10d7b41de2..3803030412 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h @@ -14,7 +14,7 @@ class ArrayBufferConstructor final : public NativeFunction { JS_OBJECT(ArrayBufferConstructor, NativeFunction); public: - explicit ArrayBufferConstructor(GlobalObject&); + explicit ArrayBufferConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ArrayBufferConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp index 463d944c48..bdd0425965 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp @@ -14,8 +14,8 @@ namespace JS { -ArrayBufferPrototype::ArrayBufferPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +ArrayBufferPrototype::ArrayBufferPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h index 2baae73737..d2515d6c7e 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h @@ -15,7 +15,7 @@ class ArrayBufferPrototype final : public PrototypeObject<ArrayBufferPrototype, JS_PROTOTYPE_OBJECT(ArrayBufferPrototype, ArrayBuffer, ArrayBuffer); public: - explicit ArrayBufferPrototype(GlobalObject&); + explicit ArrayBufferPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ArrayBufferPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 389e8ab565..0834b92401 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -16,8 +16,8 @@ namespace JS { -ArrayConstructor::ArrayConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Array.as_string(), *global_object.function_prototype()) +ArrayConstructor::ArrayConstructor(Realm& realm) + : NativeFunction(vm().names.Array.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h index 5886736b4b..57c0017779 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h @@ -14,7 +14,7 @@ class ArrayConstructor final : public NativeFunction { JS_OBJECT(ArrayConstructor, NativeFunction); public: - explicit ArrayConstructor(GlobalObject&); + explicit ArrayConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ArrayConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp index 725e6e8bf9..6ed18d71b4 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp @@ -14,8 +14,8 @@ namespace JS { -ArrayIteratorPrototype::ArrayIteratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.iterator_prototype()) +ArrayIteratorPrototype::ArrayIteratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h index efe5f0d1c4..b17d106470 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h @@ -15,7 +15,7 @@ class ArrayIteratorPrototype final : public PrototypeObject<ArrayIteratorPrototy JS_PROTOTYPE_OBJECT(ArrayIteratorPrototype, ArrayIterator, ArrayIterator); public: - ArrayIteratorPrototype(GlobalObject&); + ArrayIteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ArrayIteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 47cfd75cc9..257e32b7c6 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -28,8 +28,8 @@ namespace JS { static HashTable<Object*> s_array_join_seen_objects; -ArrayPrototype::ArrayPrototype(GlobalObject& global_object) - : Array(*global_object.object_prototype()) +ArrayPrototype::ArrayPrototype(Realm& realm) + : Array(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h index dac104540f..d631861069 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h @@ -15,7 +15,7 @@ class ArrayPrototype final : public Array { JS_OBJECT(ArrayPrototype, Array); public: - ArrayPrototype(GlobalObject&); + ArrayPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ArrayPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp index 05446dcc74..2e8793350b 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp @@ -13,11 +13,12 @@ namespace JS { AsyncFromSyncIterator* AsyncFromSyncIterator::create(GlobalObject& global_object, Iterator sync_iterator_record) { - return global_object.heap().allocate<AsyncFromSyncIterator>(global_object, global_object, sync_iterator_record); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate<AsyncFromSyncIterator>(global_object, realm, sync_iterator_record); } -AsyncFromSyncIterator::AsyncFromSyncIterator(GlobalObject& global_object, Iterator sync_iterator_record) - : Object(*global_object.async_from_sync_iterator_prototype()) +AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record) + : Object(*realm.global_object().async_from_sync_iterator_prototype()) , m_sync_iterator_record(sync_iterator_record) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h index 69c6cdb448..66e361c9d2 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h @@ -19,7 +19,7 @@ class AsyncFromSyncIterator final : public Object { public: static AsyncFromSyncIterator* create(GlobalObject&, Iterator sync_iterator_record); - explicit AsyncFromSyncIterator(GlobalObject&, Iterator sync_iterator_record); + explicit AsyncFromSyncIterator(Realm&, Iterator sync_iterator_record); virtual void initialize(GlobalObject&) override; virtual ~AsyncFromSyncIterator() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp index 09832934a2..fff5f98f80 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp @@ -14,8 +14,8 @@ namespace JS { -AsyncFromSyncIteratorPrototype::AsyncFromSyncIteratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.async_iterator_prototype()) +AsyncFromSyncIteratorPrototype::AsyncFromSyncIteratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().async_iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h index fa4fada97b..f91fcaf5b7 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h @@ -19,7 +19,7 @@ class AsyncFromSyncIteratorPrototype final : public PrototypeObject<AsyncFromSyn JS_PROTOTYPE_OBJECT(AsyncFromSyncIteratorPrototype, AsyncFromSyncIterator, AsyncFromSyncIterator); public: - explicit AsyncFromSyncIteratorPrototype(GlobalObject&); + explicit AsyncFromSyncIteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AsyncFromSyncIteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp index 2ba804870d..eb24afe0d7 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp @@ -12,8 +12,8 @@ namespace JS { -AsyncFunctionConstructor::AsyncFunctionConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.AsyncFunction.as_string(), *global_object.function_constructor()) +AsyncFunctionConstructor::AsyncFunctionConstructor(Realm& realm) + : NativeFunction(vm().names.AsyncFunction.as_string(), *realm.global_object().function_constructor()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h index 9258740675..4d42d1da34 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h @@ -15,7 +15,7 @@ class AsyncFunctionConstructor final : public NativeFunction { JS_OBJECT(AsyncFunctionConstructor, NativeFunction); public: - explicit AsyncFunctionConstructor(GlobalObject&); + explicit AsyncFunctionConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AsyncFunctionConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp index f76bf9ce86..72300237e2 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp @@ -14,17 +14,18 @@ namespace JS { ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::create(GlobalObject& global_object, GeneratorObject* generator_object) { - auto wrapper = global_object.heap().allocate<AsyncFunctionDriverWrapper>(global_object, global_object, generator_object); + auto& realm = *global_object.associated_realm(); + auto wrapper = global_object.heap().allocate<AsyncFunctionDriverWrapper>(global_object, realm, generator_object); return wrapper->react_to_async_task_completion(global_object.vm(), global_object, js_undefined(), true); } -AsyncFunctionDriverWrapper::AsyncFunctionDriverWrapper(GlobalObject& global_object, GeneratorObject* generator_object) - : Promise(*global_object.promise_prototype()) +AsyncFunctionDriverWrapper::AsyncFunctionDriverWrapper(Realm& realm, GeneratorObject* generator_object) + : Promise(*realm.global_object().promise_prototype()) , m_generator_object(generator_object) - , m_on_fulfillment(NativeFunction::create(global_object, "async.on_fulfillment"sv, [this](VM& vm, GlobalObject& global_object) { + , m_on_fulfillment(NativeFunction::create(realm.global_object(), "async.on_fulfillment"sv, [this](VM& vm, GlobalObject& global_object) { return react_to_async_task_completion(vm, global_object, vm.argument(0), true); })) - , m_on_rejection(NativeFunction::create(global_object, "async.on_rejection"sv, [this](VM& vm, GlobalObject& global_object) { + , m_on_rejection(NativeFunction::create(realm.global_object(), "async.on_rejection"sv, [this](VM& vm, GlobalObject& global_object) { return react_to_async_task_completion(vm, global_object, vm.argument(0), false); })) { diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h index 5ef0d49ba8..27e533858f 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.h @@ -19,7 +19,7 @@ class AsyncFunctionDriverWrapper final : public Promise { public: static ThrowCompletionOr<Value> create(GlobalObject&, GeneratorObject*); - explicit AsyncFunctionDriverWrapper(GlobalObject&, GeneratorObject*); + explicit AsyncFunctionDriverWrapper(Realm&, GeneratorObject*); virtual ~AsyncFunctionDriverWrapper() override = default; void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp index ad3a7ba896..09cb59e1a0 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp @@ -9,8 +9,8 @@ namespace JS { -AsyncFunctionPrototype::AsyncFunctionPrototype(GlobalObject& global_object) - : Object(*global_object.function_prototype()) +AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm) + : Object(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h index ac8d91654e..b0a3df4701 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h @@ -14,7 +14,7 @@ class AsyncFunctionPrototype final : public Object { JS_OBJECT(AsyncFunctionPrototype, Object); public: - explicit AsyncFunctionPrototype(GlobalObject&); + explicit AsyncFunctionPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AsyncFunctionPrototype() override = default; }; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp index 6ba69c2f36..0341bd3313 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp @@ -12,8 +12,8 @@ namespace JS { -AsyncGeneratorFunctionConstructor::AsyncGeneratorFunctionConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.AsyncGeneratorFunction.as_string(), *global_object.function_prototype()) +AsyncGeneratorFunctionConstructor::AsyncGeneratorFunctionConstructor(Realm& realm) + : NativeFunction(vm().names.AsyncGeneratorFunction.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h index 4395ced16e..6434aaf9f5 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h @@ -14,7 +14,7 @@ class AsyncGeneratorFunctionConstructor final : public NativeFunction { JS_OBJECT(AsyncGeneratorFunctionConstructor, NativeFunction); public: - explicit AsyncGeneratorFunctionConstructor(GlobalObject&); + explicit AsyncGeneratorFunctionConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AsyncGeneratorFunctionConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp index a2afd60eca..14096ab6f0 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp @@ -11,8 +11,8 @@ namespace JS { -AsyncGeneratorFunctionPrototype::AsyncGeneratorFunctionPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.function_prototype()) +AsyncGeneratorFunctionPrototype::AsyncGeneratorFunctionPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h index 23179d585b..78ee0e2982 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h @@ -14,7 +14,7 @@ class AsyncGeneratorFunctionPrototype final : public PrototypeObject<AsyncGenera JS_PROTOTYPE_OBJECT(AsyncGeneratorFunctionPrototype, AsyncGeneratorFunction, AsyncGeneratorFunction); public: - explicit AsyncGeneratorFunctionPrototype(GlobalObject&); + explicit AsyncGeneratorFunctionPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AsyncGeneratorFunctionPrototype() override = default; }; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp index ba6bb4f23e..1dbce4bc00 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp @@ -9,8 +9,8 @@ namespace JS { // 27.6.1 Properties of the AsyncGenerator Prototype Object, https://tc39.es/ecma262/#sec-properties-of-asyncgenerator-prototype -AsyncGeneratorPrototype::AsyncGeneratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.async_iterator_prototype()) +AsyncGeneratorPrototype::AsyncGeneratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().async_iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h index 6ba8d53b89..39a9ac8300 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h @@ -15,7 +15,7 @@ class AsyncGeneratorPrototype final : public PrototypeObject<AsyncGeneratorProto JS_PROTOTYPE_OBJECT(AsyncGeneratorPrototype, AsyncGenerator, AsyncGenerator) public: - explicit AsyncGeneratorPrototype(GlobalObject&); + explicit AsyncGeneratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AsyncGeneratorPrototype() override = default; }; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp index b3e95ae5e4..322b9d026f 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp @@ -8,8 +8,8 @@ namespace JS { -AsyncIteratorPrototype::AsyncIteratorPrototype(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h index 1f02d29505..8ebe1bf17a 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h @@ -14,7 +14,7 @@ class AsyncIteratorPrototype final : public Object { JS_OBJECT(AsyncIteratorPrototype, Object) public: - explicit AsyncIteratorPrototype(GlobalObject&); + explicit AsyncIteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AsyncIteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp index c677a21431..3099892efb 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp @@ -129,8 +129,8 @@ static ThrowCompletionOr<Value> perform_atomic_operation(GlobalObject& global_ob return atomic_read_modify_write(global_object, typed_array, index, value, move(operation_wrapper)); } -AtomicsObject::AtomicsObject(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +AtomicsObject::AtomicsObject(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.h b/Userland/Libraries/LibJS/Runtime/AtomicsObject.h index 00e89c5c83..8fb1df29e3 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.h +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.h @@ -14,7 +14,7 @@ class AtomicsObject : public Object { JS_OBJECT(AtomicsObject, Object); public: - explicit AtomicsObject(GlobalObject&); + explicit AtomicsObject(Realm&); virtual void initialize(GlobalObject&) override; virtual ~AtomicsObject() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index 98eae0460e..7a07eda17d 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -17,8 +17,8 @@ namespace JS { static const Crypto::SignedBigInteger BIGINT_ONE { 1 }; -BigIntConstructor::BigIntConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.BigInt.as_string(), *global_object.function_prototype()) +BigIntConstructor::BigIntConstructor(Realm& realm) + : NativeFunction(vm().names.BigInt.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h index 31d1844368..fc81ada21e 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h @@ -14,7 +14,7 @@ class BigIntConstructor final : public NativeFunction { JS_OBJECT(BigIntConstructor, NativeFunction); public: - explicit BigIntConstructor(GlobalObject&); + explicit BigIntConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~BigIntConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp index f4c2b92c62..5c0ffd8689 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp @@ -17,8 +17,8 @@ namespace JS { -BigIntPrototype::BigIntPrototype(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +BigIntPrototype::BigIntPrototype(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h index 94990c2e52..62f171da56 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h @@ -14,7 +14,7 @@ class BigIntPrototype final : public Object { JS_OBJECT(BigIntPrototype, Object); public: - explicit BigIntPrototype(GlobalObject&); + explicit BigIntPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~BigIntPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp index b8f0847966..90a56f184c 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp @@ -11,8 +11,8 @@ namespace JS { -BooleanConstructor::BooleanConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Boolean.as_string(), *global_object.function_prototype()) +BooleanConstructor::BooleanConstructor(Realm& realm) + : NativeFunction(vm().names.Boolean.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h index 8eaf557540..8c6e22e88b 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h @@ -14,7 +14,7 @@ class BooleanConstructor final : public NativeFunction { JS_OBJECT(BooleanConstructor, NativeFunction); public: - explicit BooleanConstructor(GlobalObject&); + explicit BooleanConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~BooleanConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp index 4d36bcbba9..bdf4daaa10 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp @@ -12,8 +12,8 @@ namespace JS { -BooleanPrototype::BooleanPrototype(GlobalObject& global_object) - : BooleanObject(false, *global_object.object_prototype()) +BooleanPrototype::BooleanPrototype(Realm& realm) + : BooleanObject(false, *realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h index b3e55e7466..48f5672286 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h @@ -14,7 +14,7 @@ class BooleanPrototype final : public BooleanObject { JS_OBJECT(BooleanPrototype, BooleanObject); public: - explicit BooleanPrototype(GlobalObject&); + explicit BooleanPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~BooleanPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index d4862d1783..a9fa182217 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -14,6 +14,8 @@ namespace JS { // 10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs ), https://tc39.es/ecma262/#sec-boundfunctioncreate ThrowCompletionOr<BoundFunction*> BoundFunction::create(GlobalObject& global_object, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments) { + auto& realm = *global_object.associated_realm(); + // 1. Let proto be ? targetFunction.[[GetPrototypeOf]](). auto* prototype = TRY(target_function.internal_get_prototype_of()); @@ -26,14 +28,14 @@ ThrowCompletionOr<BoundFunction*> BoundFunction::create(GlobalObject& global_obj // 7. Set obj.[[BoundTargetFunction]] to targetFunction. // 8. Set obj.[[BoundThis]] to boundThis. // 9. Set obj.[[BoundArguments]] to boundArgs. - auto* object = global_object.heap().allocate<BoundFunction>(global_object, global_object, target_function, bound_this, move(bound_arguments), prototype); + auto* object = global_object.heap().allocate<BoundFunction>(global_object, realm, target_function, bound_this, move(bound_arguments), prototype); // 10. Return obj. return object; } -BoundFunction::BoundFunction(GlobalObject& global_object, FunctionObject& bound_target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype) - : FunctionObject(global_object, prototype) +BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype) + : FunctionObject(realm, prototype) , m_bound_target_function(&bound_target_function) , m_bound_this(bound_this) , m_bound_arguments(move(bound_arguments)) diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.h b/Userland/Libraries/LibJS/Runtime/BoundFunction.h index 9993ffcc4a..b7dabe66f5 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.h @@ -17,7 +17,7 @@ class BoundFunction final : public FunctionObject { public: static ThrowCompletionOr<BoundFunction*> create(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments); - BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype); + BoundFunction(Realm&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype); virtual ~BoundFunction() override = default; virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override; diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp index 99dc11f333..8d82aa5492 100644 --- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp @@ -12,8 +12,8 @@ namespace JS { -ConsoleObject::ConsoleObject(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +ConsoleObject::ConsoleObject(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.h b/Userland/Libraries/LibJS/Runtime/ConsoleObject.h index 76a0e4c8ba..2749cc8ae1 100644 --- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.h +++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.h @@ -14,7 +14,7 @@ class ConsoleObject final : public Object { JS_OBJECT(ConsoleObject, Object); public: - explicit ConsoleObject(GlobalObject&); + explicit ConsoleObject(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ConsoleObject() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp index 20e59c5528..975c571626 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp @@ -13,8 +13,8 @@ namespace JS { -DataViewConstructor::DataViewConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.DataView.as_string(), *global_object.function_prototype()) +DataViewConstructor::DataViewConstructor(Realm& realm) + : NativeFunction(vm().names.DataView.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h index 16c5097694..d00c222a3f 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h @@ -14,7 +14,7 @@ class DataViewConstructor final : public NativeFunction { JS_OBJECT(DataViewConstructor, NativeFunction); public: - explicit DataViewConstructor(GlobalObject&); + explicit DataViewConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DataViewConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp index 739144f0ec..a7c198f726 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp @@ -10,8 +10,8 @@ namespace JS { -DataViewPrototype::DataViewPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +DataViewPrototype::DataViewPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h index 1b754b4396..41a9bec2f3 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h @@ -15,7 +15,7 @@ class DataViewPrototype final : public PrototypeObject<DataViewPrototype, DataVi JS_PROTOTYPE_OBJECT(DataViewPrototype, DataView, DataView); public: - DataViewPrototype(GlobalObject&); + DataViewPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DataViewPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index 2527cd74f2..51ceda793b 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -162,8 +162,8 @@ static double parse_date_string(String const& date_string) return NAN; } -DateConstructor::DateConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Date.as_string(), *global_object.function_prototype()) +DateConstructor::DateConstructor(Realm& realm) + : NativeFunction(vm().names.Date.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.h b/Userland/Libraries/LibJS/Runtime/DateConstructor.h index a22406935e..54207f70d8 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.h @@ -14,7 +14,7 @@ class DateConstructor final : public NativeFunction { JS_OBJECT(DateConstructor, NativeFunction); public: - explicit DateConstructor(GlobalObject&); + explicit DateConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DateConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 5f5baaf3ae..03c1e7bfe7 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -30,8 +30,8 @@ namespace JS { -DatePrototype::DatePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +DatePrototype::DatePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.h b/Userland/Libraries/LibJS/Runtime/DatePrototype.h index f3c75d2b15..0a922cef9a 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.h @@ -15,7 +15,7 @@ class DatePrototype final : public PrototypeObject<DatePrototype, Date> { JS_PROTOTYPE_OBJECT(DatePrototype, Date, Date); public: - explicit DatePrototype(GlobalObject&); + explicit DatePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DatePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp index 900c8c4a2d..7b9ceb3e3d 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -11,8 +11,8 @@ namespace JS { -ErrorConstructor::ErrorConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Error.as_string(), *global_object.function_prototype()) +ErrorConstructor::ErrorConstructor(Realm& realm) + : NativeFunction(vm().names.Error.as_string(), *realm.global_object().function_prototype()) { } @@ -63,8 +63,8 @@ ThrowCompletionOr<Object*> ErrorConstructor::construct(FunctionObject& new_targe } #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - ConstructorName::ConstructorName(GlobalObject& global_object) \ - : NativeFunction(vm().names.ClassName.as_string(), *static_cast<Object*>(global_object.error_constructor())) \ + ConstructorName::ConstructorName(Realm& realm) \ + : NativeFunction(vm().names.ClassName.as_string(), *static_cast<Object*>(realm.global_object().error_constructor())) \ { \ } \ \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h index 4226c6107f..534cf62e59 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h @@ -15,7 +15,7 @@ class ErrorConstructor final : public NativeFunction { JS_OBJECT(ErrorConstructor, NativeFunction); public: - explicit ErrorConstructor(GlobalObject&); + explicit ErrorConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ErrorConstructor() override = default; @@ -31,7 +31,7 @@ private: JS_OBJECT(ConstructorName, NativeFunction); \ \ public: \ - explicit ConstructorName(GlobalObject&); \ + explicit ConstructorName(Realm&); \ virtual void initialize(GlobalObject&) override; \ virtual ~ConstructorName() override; \ virtual ThrowCompletionOr<Value> call() override; \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 1167e37de1..4c5a51d12d 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -15,8 +15,8 @@ namespace JS { -ErrorPrototype::ErrorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +ErrorPrototype::ErrorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } @@ -124,8 +124,8 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter) } #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - PrototypeName::PrototypeName(GlobalObject& global_object) \ - : PrototypeObject(*global_object.error_prototype()) \ + PrototypeName::PrototypeName(Realm& realm) \ + : PrototypeObject(*realm.global_object().error_prototype()) \ { \ } \ \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h index 5a7ce94e01..c3e3566531 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h @@ -16,7 +16,7 @@ class ErrorPrototype final : public PrototypeObject<ErrorPrototype, Error> { JS_PROTOTYPE_OBJECT(ErrorPrototype, Error, Error); public: - explicit ErrorPrototype(GlobalObject&); + explicit ErrorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ErrorPrototype() override = default; @@ -31,7 +31,7 @@ private: JS_PROTOTYPE_OBJECT(PrototypeName, ClassName, ClassName); \ \ public: \ - explicit PrototypeName(GlobalObject&); \ + explicit PrototypeName(Realm&); \ virtual void initialize(GlobalObject&) override; \ virtual ~PrototypeName() override = default; \ }; diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp index b438282cf9..dfd681e48e 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp @@ -13,8 +13,8 @@ namespace JS { -FinalizationRegistryConstructor::FinalizationRegistryConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.FinalizationRegistry.as_string(), *global_object.function_prototype()) +FinalizationRegistryConstructor::FinalizationRegistryConstructor(Realm& realm) + : NativeFunction(vm().names.FinalizationRegistry.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h index c09a01e1c6..9516e4f102 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h @@ -14,7 +14,7 @@ class FinalizationRegistryConstructor final : public NativeFunction { JS_OBJECT(FinalizationRegistryConstructor, NativeFunction); public: - explicit FinalizationRegistryConstructor(GlobalObject&); + explicit FinalizationRegistryConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~FinalizationRegistryConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp index 03f59b1538..d9aa36ed08 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp @@ -9,8 +9,8 @@ namespace JS { -FinalizationRegistryPrototype::FinalizationRegistryPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +FinalizationRegistryPrototype::FinalizationRegistryPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h index d7e81ab2f0..a530fb482f 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h @@ -15,7 +15,7 @@ class FinalizationRegistryPrototype final : public PrototypeObject<FinalizationR JS_PROTOTYPE_OBJECT(FinalizationRegistryPrototype, FinalizationRegistry, FinalizationRegistry); public: - FinalizationRegistryPrototype(GlobalObject&); + FinalizationRegistryPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~FinalizationRegistryPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index 9ea55d84f2..0488909712 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -19,8 +19,8 @@ namespace JS { -FunctionConstructor::FunctionConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Function.as_string(), *global_object.function_prototype()) +FunctionConstructor::FunctionConstructor(Realm& realm) + : NativeFunction(vm().names.Function.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h index 80b15cf08f..159c50ee3b 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h @@ -17,7 +17,7 @@ class FunctionConstructor final : public NativeFunction { public: static ThrowCompletionOr<ECMAScriptFunctionObject*> create_dynamic_function(GlobalObject& global_object, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args); - explicit FunctionConstructor(GlobalObject&); + explicit FunctionConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~FunctionConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp index c7f2d2999b..af428297df 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.cpp @@ -11,8 +11,8 @@ namespace JS { -FunctionObject::FunctionObject(GlobalObject& global_object, Object* prototype) - : Object(global_object, prototype) +FunctionObject::FunctionObject(Realm& realm, Object* prototype) + : Object(realm, prototype) { } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.h b/Userland/Libraries/LibJS/Runtime/FunctionObject.h index 38b1b6fe9f..38b7689fa8 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.h @@ -40,7 +40,7 @@ public: virtual Realm* realm() const { return nullptr; } protected: - explicit FunctionObject(GlobalObject&, Object* prototype); + explicit FunctionObject(Realm&, Object* prototype); explicit FunctionObject(Object& prototype); private: diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 771a4e3f8d..ab45ad95df 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -20,8 +20,8 @@ namespace JS { -FunctionPrototype::FunctionPrototype(GlobalObject& global_object) - : FunctionObject(*global_object.object_prototype()) +FunctionPrototype::FunctionPrototype(Realm& realm) + : FunctionObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h index ffaa42a0ed..e7aef3b389 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h @@ -14,7 +14,7 @@ class FunctionPrototype final : public FunctionObject { JS_OBJECT(FunctionPrototype, FunctionObject); public: - explicit FunctionPrototype(GlobalObject&); + explicit FunctionPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~FunctionPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp index 950a413778..6fae3b8ad2 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp @@ -11,8 +11,8 @@ namespace JS { -GeneratorFunctionConstructor::GeneratorFunctionConstructor(GlobalObject& global_object) - : NativeFunction(*static_cast<Object*>(global_object.function_constructor())) +GeneratorFunctionConstructor::GeneratorFunctionConstructor(Realm& realm) + : NativeFunction(static_cast<Object&>(*realm.global_object().function_constructor())) { } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h index 41005469b1..90ce4bccb9 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h @@ -15,7 +15,7 @@ class GeneratorFunctionConstructor final : public NativeFunction { JS_OBJECT(GeneratorFunctionConstructor, NativeFunction); public: - explicit GeneratorFunctionConstructor(GlobalObject&); + explicit GeneratorFunctionConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~GeneratorFunctionConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp index aff916cd6f..00d0e5ca93 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp @@ -10,8 +10,8 @@ namespace JS { -GeneratorFunctionPrototype::GeneratorFunctionPrototype(GlobalObject& global_object) - : Object(*global_object.function_prototype()) +GeneratorFunctionPrototype::GeneratorFunctionPrototype(Realm& realm) + : Object(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h index ed528874b6..65d2798975 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h @@ -16,7 +16,7 @@ class GeneratorFunctionPrototype final : public Object { JS_OBJECT(GeneratorFunctionPrototype, Object); public: - explicit GeneratorFunctionPrototype(GlobalObject&); + explicit GeneratorFunctionPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~GeneratorFunctionPrototype() override = default; }; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 843becbb12..b274677292 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -15,6 +15,8 @@ namespace JS { ThrowCompletionOr<GeneratorObject*> GeneratorObject::create(GlobalObject& global_object, Value initial_value, ECMAScriptFunctionObject* generating_function, ExecutionContext execution_context, Bytecode::RegisterWindow frame) { + auto& realm = *global_object.associated_realm(); + // This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png) Value generating_function_prototype; if (generating_function->kind() == FunctionKind::Async) { @@ -26,14 +28,14 @@ ThrowCompletionOr<GeneratorObject*> GeneratorObject::create(GlobalObject& global generating_function_prototype = TRY(generating_function->get(global_object.vm().names.prototype)); } auto* generating_function_prototype_object = TRY(generating_function_prototype.to_object(global_object)); - auto object = global_object.heap().allocate<GeneratorObject>(global_object, global_object, *generating_function_prototype_object, move(execution_context)); + auto object = global_object.heap().allocate<GeneratorObject>(global_object, realm, *generating_function_prototype_object, move(execution_context)); object->m_generating_function = generating_function; object->m_frame = move(frame); object->m_previous_value = initial_value; return object; } -GeneratorObject::GeneratorObject(GlobalObject&, Object& prototype, ExecutionContext context) +GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext context) : Object(prototype) , m_execution_context(move(context)) { diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h index 9b164d5319..eff4e881ae 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h @@ -17,7 +17,7 @@ class GeneratorObject final : public Object { public: static ThrowCompletionOr<GeneratorObject*> create(GlobalObject&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow); - GeneratorObject(GlobalObject&, Object& prototype, ExecutionContext); + GeneratorObject(Realm&, Object& prototype, ExecutionContext); virtual void initialize(GlobalObject&) override; virtual ~GeneratorObject() override = default; void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp index e28438200d..81c4de3472 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp @@ -9,8 +9,8 @@ namespace JS { -GeneratorPrototype::GeneratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.iterator_prototype()) +GeneratorPrototype::GeneratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h index b87c8cb3e6..0cc7a4ca85 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h @@ -16,7 +16,7 @@ class GeneratorPrototype final : public PrototypeObject<GeneratorPrototype, Gene JS_PROTOTYPE_OBJECT(GeneratorPrototype, GeneratorObject, Generator); public: - explicit GeneratorPrototype(GlobalObject&); + explicit GeneratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~GeneratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index 4f43d720dc..27d4f1f688 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -155,8 +155,8 @@ void GlobalObject::initialize_global_object() VERIFY(associated_realm()); auto& realm = *associated_realm(); m_empty_object_shape = heap().allocate_without_global_object<Shape>(realm); - m_object_prototype = heap().allocate_without_global_object<ObjectPrototype>(*this); - m_function_prototype = heap().allocate_without_global_object<FunctionPrototype>(*this); + m_object_prototype = heap().allocate_without_global_object<ObjectPrototype>(realm); + m_function_prototype = heap().allocate_without_global_object<FunctionPrototype>(realm); m_new_object_shape = vm.heap().allocate_without_global_object<Shape>(realm); m_new_object_shape->set_prototype_without_transition(m_object_prototype); @@ -174,29 +174,29 @@ void GlobalObject::initialize_global_object() Object::set_prototype(m_object_prototype); // This must be initialized before allocating AggregateErrorPrototype, which uses ErrorPrototype as its prototype. - m_error_prototype = heap().allocate<ErrorPrototype>(*this, *this); + m_error_prototype = heap().allocate<ErrorPrototype>(*this, realm); #define __JS_ENUMERATE(ClassName, snake_name) \ if (!m_##snake_name##_prototype) \ - m_##snake_name##_prototype = heap().allocate<ClassName##Prototype>(*this, *this); + m_##snake_name##_prototype = heap().allocate<ClassName##Prototype>(*this, realm); JS_ENUMERATE_ITERATOR_PROTOTYPES #undef __JS_ENUMERATE // These must be initialized separately as they have no companion constructor - m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(*this, *this); - m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(*this, *this); - m_generator_prototype = heap().allocate<GeneratorPrototype>(*this, *this); - m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(*this, *this); + m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(*this, realm); + m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(*this, realm); + m_generator_prototype = heap().allocate<GeneratorPrototype>(*this, realm); + m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(*this, realm); #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ if (!m_##snake_name##_prototype) \ - m_##snake_name##_prototype = heap().allocate<PrototypeName>(*this, *this); + m_##snake_name##_prototype = heap().allocate<PrototypeName>(*this, realm); JS_ENUMERATE_BUILTIN_TYPES #undef __JS_ENUMERATE #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ if (!m_intl_##snake_name##_prototype) \ - m_intl_##snake_name##_prototype = heap().allocate<Intl::PrototypeName>(*this, *this); + m_intl_##snake_name##_prototype = heap().allocate<Intl::PrototypeName>(*this, realm); JS_ENUMERATE_INTL_OBJECTS #undef __JS_ENUMERATE @@ -208,7 +208,7 @@ void GlobalObject::initialize_global_object() #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ if (!m_temporal_##snake_name##_prototype) \ - m_temporal_##snake_name##_prototype = heap().allocate<Temporal::PrototypeName>(*this, *this); + m_temporal_##snake_name##_prototype = heap().allocate<Temporal::PrototypeName>(*this, realm); JS_ENUMERATE_TEMPORAL_OBJECTS #undef __JS_ENUMERATE @@ -250,13 +250,13 @@ void GlobalObject::initialize_global_object() define_direct_property(vm.names.undefined, js_undefined(), 0); define_direct_property(vm.names.globalThis, this, attr); - define_direct_property(vm.names.console, heap().allocate<ConsoleObject>(*this, *this), attr); - define_direct_property(vm.names.Atomics, heap().allocate<AtomicsObject>(*this, *this), attr); - define_direct_property(vm.names.Math, heap().allocate<MathObject>(*this, *this), attr); - define_direct_property(vm.names.JSON, heap().allocate<JSONObject>(*this, *this), attr); - define_direct_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, *this), attr); - define_direct_property(vm.names.Intl, heap().allocate<Intl::Intl>(*this, *this), attr); - define_direct_property(vm.names.Temporal, heap().allocate<Temporal::Temporal>(*this, *this), attr); + define_direct_property(vm.names.console, heap().allocate<ConsoleObject>(*this, realm), attr); + define_direct_property(vm.names.Atomics, heap().allocate<AtomicsObject>(*this, realm), attr); + define_direct_property(vm.names.Math, heap().allocate<MathObject>(*this, realm), attr); + define_direct_property(vm.names.JSON, heap().allocate<JSONObject>(*this, realm), attr); + define_direct_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, realm), attr); + define_direct_property(vm.names.Intl, heap().allocate<Intl::Intl>(*this, realm), attr); + define_direct_property(vm.names.Temporal, heap().allocate<Temporal::Temporal>(*this, realm), attr); // This must be initialized before allocating AggregateErrorConstructor, which uses ErrorConstructor as its prototype. initialize_constructor(vm.names.Error, m_error_constructor, m_error_prototype); diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h index e07c608985..75bb908fa7 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -177,7 +177,8 @@ template<typename ConstructorType> inline void GlobalObject::initialize_constructor(PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype, PropertyAttributes attributes) { auto& vm = this->vm(); - constructor = heap().allocate<ConstructorType>(*this, *this); + auto& realm = *associated_realm(); + constructor = heap().allocate<ConstructorType>(*this, realm); constructor->define_direct_property(vm.names.name, js_string(heap(), property_key.as_string()), Attribute::Configurable); if (prototype) prototype->define_direct_property(vm.names.constructor, constructor, attributes); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index 5abbab99db..2248aab8cb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp @@ -13,11 +13,12 @@ namespace JS::Intl { CollatorCompareFunction* CollatorCompareFunction::create(GlobalObject& global_object, Collator& collator) { - return global_object.heap().allocate<CollatorCompareFunction>(global_object, global_object, collator); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate<CollatorCompareFunction>(global_object, realm, collator); } -CollatorCompareFunction::CollatorCompareFunction(GlobalObject& global_object, Collator& collator) - : NativeFunction(*global_object.function_prototype()) +CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator) + : NativeFunction(*realm.global_object().function_prototype()) , m_collator(collator) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h index a1540bc92b..c45cb5233a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h @@ -16,7 +16,7 @@ class CollatorCompareFunction : public NativeFunction { public: static CollatorCompareFunction* create(GlobalObject&, Collator&); - explicit CollatorCompareFunction(GlobalObject&, Collator&); + CollatorCompareFunction(Realm&, Collator&); virtual void initialize(GlobalObject&) override; virtual ~CollatorCompareFunction() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp index 76440d657f..eafa195259 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -132,8 +132,8 @@ static ThrowCompletionOr<Collator*> initialize_collator(GlobalObject& global_obj } // 10.1 The Intl.Collator Constructor, https://tc39.es/ecma402/#sec-the-intl-collator-constructor -CollatorConstructor::CollatorConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Collator.as_string(), *global_object.function_prototype()) +CollatorConstructor::CollatorConstructor(Realm& realm) + : NativeFunction(vm().names.Collator.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h index 448b41df8b..2c925ded00 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h @@ -14,7 +14,7 @@ class CollatorConstructor final : public NativeFunction { JS_OBJECT(CollatorConstructor, NativeFunction); public: - explicit CollatorConstructor(GlobalObject&); + explicit CollatorConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~CollatorConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp index 1e35df850a..25f5b81421 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp @@ -12,8 +12,8 @@ namespace JS::Intl { // 10.3 Properties of the Intl.Collator Prototype Object, https://tc39.es/ecma402/#sec-properties-of-the-intl-collator-prototype-object -CollatorPrototype::CollatorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +CollatorPrototype::CollatorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h index 4a9db4bc55..2cb3169107 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h @@ -15,7 +15,7 @@ class CollatorPrototype final : public PrototypeObject<CollatorPrototype, Collat JS_PROTOTYPE_OBJECT(CollatorPrototype, Collator, Collator); public: - explicit CollatorPrototype(GlobalObject&); + explicit CollatorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~CollatorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp index 4fa7b4b51e..497c2449cb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp @@ -17,8 +17,8 @@ namespace JS::Intl { // 11.1 The Intl.DateTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-datetimeformat-constructor -DateTimeFormatConstructor::DateTimeFormatConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.DateTimeFormat.as_string(), *global_object.function_prototype()) +DateTimeFormatConstructor::DateTimeFormatConstructor(Realm& realm) + : NativeFunction(vm().names.DateTimeFormat.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h index af8a21f9d1..cb328b0e5e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h @@ -14,7 +14,7 @@ class DateTimeFormatConstructor final : public NativeFunction { JS_OBJECT(DateTimeFormatConstructor, NativeFunction); public: - explicit DateTimeFormatConstructor(GlobalObject&); + explicit DateTimeFormatConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DateTimeFormatConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp index e1161f80d7..2cc261d0f6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp @@ -14,8 +14,8 @@ namespace JS::Intl { // 11.3 Properties of the Intl.DateTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-prototype-object -DateTimeFormatPrototype::DateTimeFormatPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +DateTimeFormatPrototype::DateTimeFormatPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h index de71cb1652..e504ab390c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h @@ -15,7 +15,7 @@ class DateTimeFormatPrototype final : public PrototypeObject<DateTimeFormatProto JS_PROTOTYPE_OBJECT(DateTimeFormatPrototype, DateTimeFormat, Intl.DateTimeFormat); public: - explicit DateTimeFormatPrototype(GlobalObject&); + explicit DateTimeFormatPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DateTimeFormatPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp index a8bedd21c2..f6d0a4a6aa 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp @@ -16,8 +16,8 @@ namespace JS::Intl { // 12.1 The Intl.DisplayNames Constructor, https://tc39.es/ecma402/#sec-intl-displaynames-constructor -DisplayNamesConstructor::DisplayNamesConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.DisplayNames.as_string(), *global_object.function_prototype()) +DisplayNamesConstructor::DisplayNamesConstructor(Realm& realm) + : NativeFunction(vm().names.DisplayNames.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h index bbad8023ed..06dc7d196e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h @@ -14,7 +14,7 @@ class DisplayNamesConstructor final : public NativeFunction { JS_OBJECT(DisplayNamesConstructor, NativeFunction); public: - explicit DisplayNamesConstructor(GlobalObject&); + explicit DisplayNamesConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DisplayNamesConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 1ce7e148ce..a310f76fbf 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -14,8 +14,8 @@ namespace JS::Intl { // 12.3 Properties of the Intl.DisplayNames Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object -DisplayNamesPrototype::DisplayNamesPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +DisplayNamesPrototype::DisplayNamesPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h index e000058840..049a1d8f75 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h @@ -15,7 +15,7 @@ class DisplayNamesPrototype final : public PrototypeObject<DisplayNamesPrototype JS_PROTOTYPE_OBJECT(DisplayNamesPrototype, DisplayNames, Intl.DisplayNames); public: - explicit DisplayNamesPrototype(GlobalObject&); + explicit DisplayNamesPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DisplayNamesPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index 2028c2871c..4cff0a1c51 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -14,8 +14,8 @@ namespace JS::Intl { // 1.2 The Intl.DurationFormat Constructor, https://tc39.es/proposal-intl-duration-format/#sec-intl-durationformat-constructor -DurationFormatConstructor::DurationFormatConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.DurationFormat.as_string(), *global_object.function_prototype()) +DurationFormatConstructor::DurationFormatConstructor(Realm& realm) + : NativeFunction(vm().names.DurationFormat.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h index 400a32d5d8..fe1aeafcd7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h @@ -14,7 +14,7 @@ class DurationFormatConstructor final : public NativeFunction { JS_OBJECT(DurationFormatConstructor, NativeFunction); public: - explicit DurationFormatConstructor(GlobalObject&); + explicit DurationFormatConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DurationFormatConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp index d01aa9ba07..b32714846a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp @@ -11,8 +11,8 @@ namespace JS::Intl { // 1.4 Properties of the Intl.DurationFormat Prototype Object, https://tc39.es/proposal-intl-duration-format/#sec-properties-of-intl-durationformat-prototype-object -DurationFormatPrototype::DurationFormatPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +DurationFormatPrototype::DurationFormatPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h index 50140b12b7..bce2f475c2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h @@ -15,7 +15,7 @@ class DurationFormatPrototype final : public PrototypeObject<DurationFormatProto JS_PROTOTYPE_OBJECT(DurationFormatPrototype, DurationFormat, Intl.DurationFormat); public: - explicit DurationFormatPrototype(GlobalObject&); + explicit DurationFormatPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DurationFormatPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp index 9c0b397010..f3e3d7f429 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp @@ -28,8 +28,8 @@ namespace JS::Intl { // 8 The Intl Object, https://tc39.es/ecma402/#intl-object -Intl::Intl(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +Intl::Intl(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.h b/Userland/Libraries/LibJS/Runtime/Intl/Intl.h index 603a46ff82..7c7eeea7bb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.h @@ -14,7 +14,7 @@ class Intl final : public Object { JS_OBJECT(Intl, Object); public: - explicit Intl(GlobalObject&); + explicit Intl(Realm&); virtual void initialize(GlobalObject&) override; virtual ~Intl() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index cb449352cf..6938320702 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -15,8 +15,8 @@ namespace JS::Intl { // 13.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor -ListFormatConstructor::ListFormatConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.ListFormat.as_string(), *global_object.function_prototype()) +ListFormatConstructor::ListFormatConstructor(Realm& realm) + : NativeFunction(vm().names.ListFormat.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h index c5ea27c4a7..a7fdfbaa10 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h @@ -14,7 +14,7 @@ class ListFormatConstructor final : public NativeFunction { JS_OBJECT(ListFormatConstructor, NativeFunction); public: - explicit ListFormatConstructor(GlobalObject&); + explicit ListFormatConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ListFormatConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp index bb70267767..bfbde76cbb 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp @@ -13,8 +13,8 @@ namespace JS::Intl { // 13.3 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object -ListFormatPrototype::ListFormatPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +ListFormatPrototype::ListFormatPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h index 910739a053..7306daa40a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h @@ -15,7 +15,7 @@ class ListFormatPrototype final : public PrototypeObject<ListFormatPrototype, Li JS_PROTOTYPE_OBJECT(ListFormatPrototype, ListFormat, Intl.ListFormat); public: - explicit ListFormatPrototype(GlobalObject&); + explicit ListFormatPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ListFormatPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index d959a9c910..cf46baebdc 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -220,8 +220,8 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey } // 14.1 The Intl.Locale Constructor, https://tc39.es/ecma402/#sec-intl-locale-constructor -LocaleConstructor::LocaleConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Locale.as_string(), *global_object.function_prototype()) +LocaleConstructor::LocaleConstructor(Realm& realm) + : NativeFunction(vm().names.Locale.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h index da3c8b7b18..cd3d3a3a81 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h @@ -14,7 +14,7 @@ class LocaleConstructor final : public NativeFunction { JS_OBJECT(LocaleConstructor, NativeFunction); public: - explicit LocaleConstructor(GlobalObject&); + explicit LocaleConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~LocaleConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp index 9fa2c7e734..d667c645ae 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp @@ -14,8 +14,8 @@ namespace JS::Intl { // 14.3 Properties of the Intl.Locale Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-locale-prototype-object -LocalePrototype::LocalePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +LocalePrototype::LocalePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h index 273ec5d563..84771ac6b7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h @@ -15,7 +15,7 @@ class LocalePrototype final : public PrototypeObject<LocalePrototype, Locale> { JS_PROTOTYPE_OBJECT(LocalePrototype, Locale, Intl.Locale); public: - explicit LocalePrototype(GlobalObject&); + explicit LocalePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~LocalePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp index bc7fef857f..bcf7e15ce9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp @@ -14,8 +14,8 @@ namespace JS::Intl { // 15.1 The Intl.NumberFormat Constructor, https://tc39.es/ecma402/#sec-intl-numberformat-constructor -NumberFormatConstructor::NumberFormatConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.NumberFormat.as_string(), *global_object.function_prototype()) +NumberFormatConstructor::NumberFormatConstructor(Realm& realm) + : NativeFunction(vm().names.NumberFormat.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h index 9a4a82ad7f..f329ed301b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h @@ -15,7 +15,7 @@ class NumberFormatConstructor final : public NativeFunction { JS_OBJECT(NumberFormatConstructor, NativeFunction); public: - explicit NumberFormatConstructor(GlobalObject&); + explicit NumberFormatConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~NumberFormatConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index 298fa5ad7c..6c403c36b9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -14,8 +14,8 @@ namespace JS::Intl { // 15.3 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object -NumberFormatPrototype::NumberFormatPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +NumberFormatPrototype::NumberFormatPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h index 0f73bd19a6..f265378dd2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h @@ -15,7 +15,7 @@ class NumberFormatPrototype final : public PrototypeObject<NumberFormatPrototype JS_PROTOTYPE_OBJECT(NumberFormatPrototype, NumberFormat, Intl.NumberFormat); public: - explicit NumberFormatPrototype(GlobalObject&); + explicit NumberFormatPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~NumberFormatPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp index 8d732ecf89..4ec5c32552 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp @@ -16,8 +16,8 @@ namespace JS::Intl { // 16.1 The Intl.PluralRules Constructor, https://tc39.es/ecma402/#sec-intl-pluralrules-constructor -PluralRulesConstructor::PluralRulesConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.PluralRules.as_string(), *global_object.function_prototype()) +PluralRulesConstructor::PluralRulesConstructor(Realm& realm) + : NativeFunction(vm().names.PluralRules.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h index 9884d70a83..eb9316a6d6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h @@ -14,7 +14,7 @@ class PluralRulesConstructor final : public NativeFunction { JS_OBJECT(PluralRulesConstructor, NativeFunction); public: - explicit PluralRulesConstructor(GlobalObject&); + explicit PluralRulesConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PluralRulesConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp index 93114caae1..cae4f804a8 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp @@ -13,8 +13,8 @@ namespace JS::Intl { // 16.3 Properties of the Intl.PluralRules Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-prototype-object -PluralRulesPrototype::PluralRulesPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +PluralRulesPrototype::PluralRulesPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h index 298dbfae8e..ade0b376b9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h @@ -15,7 +15,7 @@ class PluralRulesPrototype final : public PrototypeObject<PluralRulesPrototype, JS_PROTOTYPE_OBJECT(PluralRulesPrototype, PluralRules, Intl.PluralRules); public: - explicit PluralRulesPrototype(GlobalObject&); + explicit PluralRulesPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PluralRulesPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp index 9f6cf2ed7d..0fb398bd69 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp @@ -19,8 +19,8 @@ namespace JS::Intl { // 17.1 The Intl.RelativeTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor -RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.RelativeTimeFormat.as_string(), *global_object.function_prototype()) +RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(Realm& realm) + : NativeFunction(vm().names.RelativeTimeFormat.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h index aceae05a70..eb61caefba 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h @@ -14,7 +14,7 @@ class RelativeTimeFormatConstructor final : public NativeFunction { JS_OBJECT(RelativeTimeFormatConstructor, NativeFunction); public: - explicit RelativeTimeFormatConstructor(GlobalObject&); + explicit RelativeTimeFormatConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~RelativeTimeFormatConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp index d02702ba27..afc46675d5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp @@ -11,8 +11,8 @@ namespace JS::Intl { // 17.3 Properties of the Intl.RelativeTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-prototype-object -RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h index 0f33e9bca3..095f65b28a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h @@ -15,7 +15,7 @@ class RelativeTimeFormatPrototype final : public PrototypeObject<RelativeTimeFor JS_PROTOTYPE_OBJECT(RelativeTimeFormatPrototype, RelativeTimeFormat, Intl.RelativeTimeFormat); public: - explicit RelativeTimeFormatPrototype(GlobalObject&); + explicit RelativeTimeFormatPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~RelativeTimeFormatPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp index 1e9e4f4ebb..2089b5dcdc 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp @@ -13,18 +13,19 @@ namespace JS::Intl { // 18.6.1 CreateSegmentIterator ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject SegmentIterator* SegmentIterator::create(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string, Segments const& segments) { + auto& realm = *global_object.associated_realm(); // 1. Let internalSlotsList be « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ». // 2. Let iterator be OrdinaryObjectCreate(%SegmentIteratorPrototype%, internalSlotsList). // 3. Set iterator.[[IteratingSegmenter]] to segmenter. // 4. Set iterator.[[IteratedString]] to string. // 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0. // 6. Return iterator. - return global_object.heap().allocate<SegmentIterator>(global_object, global_object, segmenter, move(string), segments); + return global_object.heap().allocate<SegmentIterator>(global_object, realm, segmenter, move(string), segments); } // 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects -SegmentIterator::SegmentIterator(GlobalObject& global_object, Segmenter& segmenter, Utf16View const& string, Segments const& segments) - : Object(*global_object.intl_segment_iterator_prototype()) +SegmentIterator::SegmentIterator(Realm& realm, Segmenter& segmenter, Utf16View const& string, Segments const& segments) + : Object(*realm.global_object().intl_segment_iterator_prototype()) , m_iterating_segmenter(segmenter) , m_iterated_string(string) , m_segments(segments) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.h index 6ee75de691..1a4aee5d14 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.h @@ -18,7 +18,7 @@ class SegmentIterator final : public Object { public: static SegmentIterator* create(GlobalObject&, Segmenter&, Utf16View const&, Segments const&); - SegmentIterator(GlobalObject&, Segmenter&, Utf16View const&, Segments const&); + SegmentIterator(Realm&, Segmenter&, Utf16View const&, Segments const&); virtual ~SegmentIterator() override = default; Segmenter const& iterating_segmenter() const { return m_iterating_segmenter; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp index 80bb094283..a97d549679 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp @@ -13,8 +13,8 @@ namespace JS::Intl { // 18.6.2 The %SegmentIteratorPrototype% Object, https://tc39.es/ecma402/#sec-%segmentiteratorprototype%-object -SegmentIteratorPrototype::SegmentIteratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.iterator_prototype()) +SegmentIteratorPrototype::SegmentIteratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h index 333ffc814e..dc5e287de9 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h @@ -15,7 +15,7 @@ class SegmentIteratorPrototype final : public PrototypeObject<SegmentIteratorPro JS_PROTOTYPE_OBJECT(SegmentIteratorPrototype, SegmentIterator, SegmentIterator); public: - explicit SegmentIteratorPrototype(GlobalObject&); + explicit SegmentIteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SegmentIteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp index 1bbaac0f8d..8f967f7267 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp @@ -15,8 +15,8 @@ namespace JS::Intl { // 18.1 The Intl.Segmenter Constructor, https://tc39.es/ecma402/#sec-intl-segmenter-constructor -SegmenterConstructor::SegmenterConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Segmenter.as_string(), *global_object.function_prototype()) +SegmenterConstructor::SegmenterConstructor(Realm& realm) + : NativeFunction(vm().names.Segmenter.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h index 4c27e3908a..6fd27fa26c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h @@ -14,7 +14,7 @@ class SegmenterConstructor final : public NativeFunction { JS_OBJECT(SegmenterConstructor, NativeFunction); public: - explicit SegmenterConstructor(GlobalObject&); + explicit SegmenterConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SegmenterConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp index 9c92823b6d..24a3398f71 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp @@ -12,8 +12,8 @@ namespace JS::Intl { // 18.3 Properties of the Intl.Segmenter Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-prototype-object -SegmenterPrototype::SegmenterPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +SegmenterPrototype::SegmenterPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h index 3898bb4520..71e44f8cec 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h @@ -15,7 +15,7 @@ class SegmenterPrototype final : public PrototypeObject<SegmenterPrototype, Segm JS_PROTOTYPE_OBJECT(SegmenterPrototype, Segmenter, Segmenter); public: - explicit SegmenterPrototype(GlobalObject&); + explicit SegmenterPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SegmenterPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp index 8771718a1c..1eab2f191b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp @@ -13,17 +13,18 @@ namespace JS::Intl { // 18.5.1 CreateSegmentsObject ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject Segments* Segments::create(GlobalObject& global_object, Segmenter& segmenter, Utf16String string) { + auto& realm = *global_object.associated_realm(); // 1. Let internalSlotsList be « [[SegmentsSegmenter]], [[SegmentsString]] ». // 2. Let segments be OrdinaryObjectCreate(%SegmentsPrototype%, internalSlotsList). // 3. Set segments.[[SegmentsSegmenter]] to segmenter. // 4. Set segments.[[SegmentsString]] to string. // 5. Return segments. - return global_object.heap().allocate<Segments>(global_object, global_object, segmenter, move(string)); + return global_object.heap().allocate<Segments>(global_object, realm, segmenter, move(string)); } // 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects -Segments::Segments(GlobalObject& global_object, Segmenter& segmenter, Utf16String string) - : Object(*global_object.intl_segments_prototype()) +Segments::Segments(Realm& realm, Segmenter& segmenter, Utf16String string) + : Object(*realm.global_object().intl_segments_prototype()) , m_segments_segmenter(segmenter) , m_segments_string(move(string)) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segments.h b/Userland/Libraries/LibJS/Runtime/Intl/Segments.h index 1e5a11a610..5696d3089a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Segments.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/Segments.h @@ -18,7 +18,7 @@ class Segments final : public Object { public: static Segments* create(GlobalObject&, Segmenter&, Utf16String); - Segments(GlobalObject&, Segmenter&, Utf16String); + Segments(Realm&, Segmenter&, Utf16String); virtual ~Segments() override = default; Segmenter& segments_segmenter() const { return m_segments_segmenter; } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp index c238c9a924..0964b30e34 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp @@ -12,8 +12,8 @@ namespace JS::Intl { // 18.5.2 The %SegmentsPrototype% Object, https://tc39.es/ecma402/#sec-%segmentsprototype%-object -SegmentsPrototype::SegmentsPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +SegmentsPrototype::SegmentsPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h index f8f749a248..2fe06c10e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h @@ -15,7 +15,7 @@ class SegmentsPrototype final : public PrototypeObject<SegmentsPrototype, Segmen JS_PROTOTYPE_OBJECT(SegmentsPrototype, Segments, Segments); public: - explicit SegmentsPrototype(GlobalObject&); + explicit SegmentsPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SegmentsPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp index 5fbc84e34b..0eb79acfac 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp @@ -11,8 +11,8 @@ namespace JS { // 27.1.2 The %IteratorPrototype% Object, https://tc39.es/ecma262/#sec-%iteratorprototype%-object -IteratorPrototype::IteratorPrototype(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +IteratorPrototype::IteratorPrototype(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h index bd8db2d22f..42f8d883ac 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h @@ -14,7 +14,7 @@ class IteratorPrototype : public Object { JS_OBJECT(IteratorPrototype, Object) public: - IteratorPrototype(GlobalObject&); + IteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~IteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 3eb4d9f21f..58d4ec21c5 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -25,8 +25,8 @@ namespace JS { -JSONObject::JSONObject(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +JSONObject::JSONObject(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.h b/Userland/Libraries/LibJS/Runtime/JSONObject.h index 98c25d9169..1be33caa06 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.h +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.h @@ -14,7 +14,7 @@ class JSONObject final : public Object { JS_OBJECT(JSONObject, Object); public: - explicit JSONObject(GlobalObject&); + explicit JSONObject(Realm&); virtual void initialize(GlobalObject&) override; virtual ~JSONObject() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index 63c2bfa154..fbb5a911ee 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -13,8 +13,8 @@ namespace JS { -MapConstructor::MapConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Map.as_string(), *global_object.function_prototype()) +MapConstructor::MapConstructor(Realm& realm) + : NativeFunction(vm().names.Map.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.h b/Userland/Libraries/LibJS/Runtime/MapConstructor.h index 937abfa9f3..2d24f9815e 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.h @@ -14,7 +14,7 @@ class MapConstructor final : public NativeFunction { JS_OBJECT(MapConstructor, NativeFunction); public: - explicit MapConstructor(GlobalObject&); + explicit MapConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~MapConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp index 2a2548d8e9..1689cd7d2d 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp @@ -13,8 +13,8 @@ namespace JS { -MapIteratorPrototype::MapIteratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.iterator_prototype()) +MapIteratorPrototype::MapIteratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h index 7a0caf58c5..3d3be47cf6 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h @@ -15,7 +15,7 @@ class MapIteratorPrototype final : public PrototypeObject<MapIteratorPrototype, JS_PROTOTYPE_OBJECT(MapIteratorPrototype, MapIterator, MapIterator); public: - MapIteratorPrototype(GlobalObject&); + MapIteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~MapIteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp index d471b7e537..51b7f54eba 100644 --- a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp @@ -12,8 +12,8 @@ namespace JS { -MapPrototype::MapPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +MapPrototype::MapPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.h b/Userland/Libraries/LibJS/Runtime/MapPrototype.h index 50fdfbfcbb..c617ef0ee6 100644 --- a/Userland/Libraries/LibJS/Runtime/MapPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.h @@ -15,7 +15,7 @@ class MapPrototype final : public PrototypeObject<MapPrototype, Map> { JS_PROTOTYPE_OBJECT(MapPrototype, Map, Map); public: - MapPrototype(GlobalObject&); + MapPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~MapPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.cpp b/Userland/Libraries/LibJS/Runtime/MathObject.cpp index 291472e0fd..8e7852062d 100644 --- a/Userland/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/MathObject.cpp @@ -15,8 +15,8 @@ namespace JS { -MathObject::MathObject(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +MathObject::MathObject(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.h b/Userland/Libraries/LibJS/Runtime/MathObject.h index 5738f5f980..4e59aaeb42 100644 --- a/Userland/Libraries/LibJS/Runtime/MathObject.h +++ b/Userland/Libraries/LibJS/Runtime/MathObject.h @@ -14,7 +14,7 @@ class MathObject final : public Object { JS_OBJECT(MathObject, Object); public: - explicit MathObject(GlobalObject&); + explicit MathObject(Realm&); virtual void initialize(GlobalObject&) override; virtual ~MathObject() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp index 8aaff376a2..7a3126c1be 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp @@ -10,8 +10,8 @@ namespace JS { -ModuleNamespaceObject::ModuleNamespaceObject(GlobalObject& global_object, Module* module, Vector<FlyString> exports) - : Object(*global_object.object_prototype()) +ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vector<FlyString> exports) + : Object(*realm.global_object().object_prototype()) , m_module(module) , m_exports(move(exports)) { diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h index 8c8e03d646..0e2254358d 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h @@ -16,7 +16,7 @@ class ModuleNamespaceObject final : public Object { JS_OBJECT(ModuleNamespaceObject, Object); public: - ModuleNamespaceObject(GlobalObject&, Module* module, Vector<FlyString> exports); + ModuleNamespaceObject(Realm&, Module* module, Vector<FlyString> exports); // 10.4.6 Module Namespace Exotic Objects, https://tc39.es/ecma262/#sec-module-namespace-exotic-objects diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index c18831df73..342330a163 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -36,7 +36,7 @@ NativeFunction* NativeFunction::create(GlobalObject& global_object, Function<Thr // 7. Set func.[[Extensible]] to true. // 8. Set func.[[Realm]] to realm. // 9. Set func.[[InitialName]] to null. - auto* function = global_object.heap().allocate<NativeFunction>(global_object, global_object, move(behaviour), prototype.value(), *realm.value()); + auto* function = global_object.heap().allocate<NativeFunction>(global_object, move(behaviour), prototype.value(), *realm.value()); // 10. Perform SetFunctionLength(func, length). function->set_function_length(length); @@ -53,11 +53,12 @@ NativeFunction* NativeFunction::create(GlobalObject& global_object, Function<Thr NativeFunction* NativeFunction::create(GlobalObject& global_object, FlyString const& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> function) { - return global_object.heap().allocate<NativeFunction>(global_object, name, move(function), *global_object.function_prototype()); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate<NativeFunction>(global_object, name, move(function), *realm.global_object().function_prototype()); } -NativeFunction::NativeFunction(GlobalObject& global_object, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> native_function, Object* prototype, Realm& realm) - : FunctionObject(global_object, prototype) +NativeFunction::NativeFunction(Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> native_function, Object* prototype, Realm& realm) + : FunctionObject(realm, prototype) , m_native_function(move(native_function)) , m_realm(&realm) { diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index cc76a46e2b..bbeb25241f 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -23,7 +23,7 @@ public: static NativeFunction* create(GlobalObject&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {}); static NativeFunction* create(GlobalObject&, FlyString const& name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>); - NativeFunction(GlobalObject&, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object* prototype, Realm& realm); + NativeFunction(Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object* prototype, Realm& realm); NativeFunction(FlyString name, Function<ThrowCompletionOr<Value>(VM&, GlobalObject&)>, Object& prototype); virtual void initialize(GlobalObject&) override { } virtual ~NativeFunction() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp index d1392def42..ee96dff10d 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -23,8 +23,8 @@ constexpr double const MIN_SAFE_INTEGER_VALUE { -(__builtin_exp2(53) - 1) }; namespace JS { -NumberConstructor::NumberConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Number.as_string(), *global_object.function_prototype()) +NumberConstructor::NumberConstructor(Realm& realm) + : NativeFunction(vm().names.Number.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h index dc64380aea..cc3ecf24e0 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h @@ -14,7 +14,7 @@ class NumberConstructor final : public NativeFunction { JS_OBJECT(NumberConstructor, NativeFunction); public: - explicit NumberConstructor(GlobalObject&); + explicit NumberConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~NumberConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp index a033c59120..900d7b171e 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -83,8 +83,8 @@ static size_t compute_fraction_digits(double number, int exponent) return fraction_digits; } -NumberPrototype::NumberPrototype(GlobalObject& global_object) - : NumberObject(0, *global_object.object_prototype()) +NumberPrototype::NumberPrototype(Realm& realm) + : NumberObject(0, *realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.h b/Userland/Libraries/LibJS/Runtime/NumberPrototype.h index b7e520de2f..5630cf1bde 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.h @@ -14,7 +14,7 @@ class NumberPrototype final : public NumberObject { JS_OBJECT(NumberPrototype, NumberObject); public: - explicit NumberPrototype(GlobalObject&); + explicit NumberPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~NumberPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index cb5b26e6fa..824ac5e79d 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -45,15 +45,14 @@ Object::Object(GlobalObjectTag, Realm& realm) m_shape = heap().allocate_without_global_object<Shape>(realm); } -Object::Object(ConstructWithoutPrototypeTag, GlobalObject& global_object) +Object::Object(ConstructWithoutPrototypeTag, Realm& realm) { - VERIFY(global_object.associated_realm()); - m_shape = heap().allocate_without_global_object<Shape>(*global_object.associated_realm()); + m_shape = heap().allocate_without_global_object<Shape>(realm); } -Object::Object(GlobalObject& global_object, Object* prototype) +Object::Object(Realm& realm, Object* prototype) { - m_shape = global_object.empty_object_shape(); + m_shape = realm.global_object().empty_object_shape(); if (prototype != nullptr) set_prototype(prototype); } diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index d3ed79b51a..ddeccc45e6 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -49,7 +49,7 @@ class Object : public Cell { public: static Object* create(GlobalObject&, Object* prototype); - Object(GlobalObject&, Object* prototype); + Object(Realm&, Object* prototype); explicit Object(Object& prototype); explicit Object(Shape&); virtual void initialize(GlobalObject&) override; @@ -196,8 +196,8 @@ public: protected: enum class GlobalObjectTag { Tag }; enum class ConstructWithoutPrototypeTag { Tag }; - explicit Object(GlobalObjectTag, Realm&); - Object(ConstructWithoutPrototypeTag, GlobalObject&); + Object(GlobalObjectTag, Realm&); + Object(ConstructWithoutPrototypeTag, Realm&); void set_prototype(Object*); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 92f59c6db1..199d8eeeaf 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -17,8 +17,8 @@ namespace JS { -ObjectConstructor::ObjectConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Object.as_string(), *global_object.function_prototype()) +ObjectConstructor::ObjectConstructor(Realm& realm) + : NativeFunction(vm().names.Object.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h index 0e26783982..843fcd5bf1 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h @@ -15,7 +15,7 @@ class ObjectConstructor final : public NativeFunction { JS_OBJECT(ObjectConstructor, NativeFunction); public: - explicit ObjectConstructor(GlobalObject&); + explicit ObjectConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ObjectConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp index a88031be7d..1f42b36812 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -21,8 +21,8 @@ namespace JS { -ObjectPrototype::ObjectPrototype(GlobalObject& global_object) - : Object(Object::ConstructWithoutPrototypeTag::Tag, global_object) +ObjectPrototype::ObjectPrototype(Realm& realm) + : Object(Object::ConstructWithoutPrototypeTag::Tag, realm) { } diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h index 72d43e3853..700e520166 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h @@ -15,7 +15,7 @@ class ObjectPrototype final : public Object { JS_OBJECT(ObjectPrototype, Object); public: - explicit ObjectPrototype(GlobalObject&); + explicit ObjectPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ObjectPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index 08d66bb54f..f76ec0990e 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -244,8 +244,8 @@ static ThrowCompletionOr<Value> perform_promise_race(GlobalObject& global_object }); } -PromiseConstructor::PromiseConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Promise.as_string(), *global_object.function_prototype()) +PromiseConstructor::PromiseConstructor(Realm& realm) + : NativeFunction(vm().names.Promise.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h index 76b0c27692..d174328358 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h @@ -14,7 +14,7 @@ class PromiseConstructor final : public NativeFunction { JS_OBJECT(PromiseConstructor, NativeFunction); public: - explicit PromiseConstructor(GlobalObject&); + explicit PromiseConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PromiseConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp index 739715e832..91b202ef36 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp @@ -16,8 +16,8 @@ namespace JS { -PromisePrototype::PromisePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +PromisePrototype::PromisePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.h b/Userland/Libraries/LibJS/Runtime/PromisePrototype.h index 102c3443cd..56cf340224 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.h @@ -14,7 +14,7 @@ class PromisePrototype final : public PrototypeObject<PromisePrototype, Promise> JS_PROTOTYPE_OBJECT(PromisePrototype, Promise, Promise); public: - PromisePrototype(GlobalObject&); + PromisePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PromisePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 89c8bd7c1e..6cd280832e 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -24,8 +24,8 @@ static ThrowCompletionOr<ProxyObject*> proxy_create(GlobalObject& global_object, return ProxyObject::create(global_object, target.as_object(), handler.as_object()); } -ProxyConstructor::ProxyConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Proxy.as_string(), *global_object.function_prototype()) +ProxyConstructor::ProxyConstructor(Realm& realm) + : NativeFunction(vm().names.Proxy.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h index 0f183619b7..f6ef26148e 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h @@ -15,7 +15,7 @@ class ProxyConstructor final : public NativeFunction { JS_OBJECT(ProxyConstructor, NativeFunction); public: - explicit ProxyConstructor(GlobalObject&); + explicit ProxyConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ProxyConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index 6646d73e24..a5458f5129 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -15,8 +15,8 @@ namespace JS { -ReflectObject::ReflectObject(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +ReflectObject::ReflectObject(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.h b/Userland/Libraries/LibJS/Runtime/ReflectObject.h index 279be992b7..e705d6d4f2 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.h +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.h @@ -14,7 +14,7 @@ class ReflectObject final : public Object { JS_OBJECT(ReflectObject, Object); public: - explicit ReflectObject(GlobalObject&); + explicit ReflectObject(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ReflectObject() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp index f5b95c78e9..4f07f86155 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -11,8 +11,8 @@ namespace JS { -RegExpConstructor::RegExpConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.RegExp.as_string(), *global_object.function_prototype()) +RegExpConstructor::RegExpConstructor(Realm& realm) + : NativeFunction(vm().names.RegExp.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h index ebce6f3e73..28ee58790c 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h @@ -14,7 +14,7 @@ class RegExpConstructor final : public NativeFunction { JS_OBJECT(RegExpConstructor, NativeFunction); public: - explicit RegExpConstructor(GlobalObject&); + explicit RegExpConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~RegExpConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index 534bcea5cf..3e483ea59c 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -21,8 +21,8 @@ namespace JS { -RegExpPrototype::RegExpPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +RegExpPrototype::RegExpPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h index 027bf8a8ee..defa9981e9 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h @@ -19,7 +19,7 @@ class RegExpPrototype final : public PrototypeObject<RegExpPrototype, RegExpObje JS_PROTOTYPE_OBJECT(RegExpPrototype, RegExpObject, RegExp); public: - explicit RegExpPrototype(GlobalObject&); + explicit RegExpPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~RegExpPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp index 12369ace7a..dc850c7d96 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp @@ -12,8 +12,8 @@ namespace JS { -RegExpStringIteratorPrototype::RegExpStringIteratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.iterator_prototype()) +RegExpStringIteratorPrototype::RegExpStringIteratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h index fea5e50279..ee6c2c1aae 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h @@ -15,7 +15,7 @@ class RegExpStringIteratorPrototype final : public PrototypeObject<RegExpStringI JS_PROTOTYPE_OBJECT(RegExpStringIteratorPrototype, RegExpStringIterator, RegExpStringIterator); public: - explicit RegExpStringIteratorPrototype(GlobalObject&); + explicit RegExpStringIteratorPrototype(Realm&); virtual ~RegExpStringIteratorPrototype() override = default; virtual void initialize(GlobalObject&) override; diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp index 6fed1d8f8e..34a3bccbbd 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp @@ -13,8 +13,8 @@ namespace JS { -SetConstructor::SetConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Set.as_string(), *global_object.function_prototype()) +SetConstructor::SetConstructor(Realm& realm) + : NativeFunction(vm().names.Set.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.h b/Userland/Libraries/LibJS/Runtime/SetConstructor.h index efec809e17..5d6d4ff7c0 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.h @@ -14,7 +14,7 @@ class SetConstructor final : public NativeFunction { JS_OBJECT(SetConstructor, NativeFunction); public: - explicit SetConstructor(GlobalObject&); + explicit SetConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SetConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp index 1e0213d0a6..51216c5c52 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp @@ -13,8 +13,8 @@ namespace JS { -SetIteratorPrototype::SetIteratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.iterator_prototype()) +SetIteratorPrototype::SetIteratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h index 06596f8d17..efcd5e5169 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h @@ -15,7 +15,7 @@ class SetIteratorPrototype final : public PrototypeObject<SetIteratorPrototype, JS_PROTOTYPE_OBJECT(SetIteratorPrototype, SetIterator, SetIterator); public: - SetIteratorPrototype(GlobalObject&); + SetIteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SetIteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp index 665d57ad19..a5e65ab5fc 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp @@ -12,8 +12,8 @@ namespace JS { -SetPrototype::SetPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +SetPrototype::SetPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.h b/Userland/Libraries/LibJS/Runtime/SetPrototype.h index 41bb9b4918..79c0b62463 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.h @@ -15,7 +15,7 @@ class SetPrototype final : public PrototypeObject<SetPrototype, Set> { JS_PROTOTYPE_OBJECT(SetPrototype, Set, Set); public: - SetPrototype(GlobalObject&); + SetPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SetPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp index 8af021d892..ad1da3af2a 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp @@ -11,8 +11,8 @@ namespace JS { // 3.2 The ShadowRealm Constructor, https://tc39.es/proposal-shadowrealm/#sec-shadowrealm-constructor -ShadowRealmConstructor::ShadowRealmConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.ShadowRealm.as_string(), *global_object.function_prototype()) +ShadowRealmConstructor::ShadowRealmConstructor(Realm& realm) + : NativeFunction(vm().names.ShadowRealm.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h index bdbd160bfe..24dde2aeb6 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h @@ -14,7 +14,7 @@ class ShadowRealmConstructor final : public NativeFunction { JS_OBJECT(ShadowRealmConstructor, NativeFunction); public: - explicit ShadowRealmConstructor(GlobalObject&); + explicit ShadowRealmConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ShadowRealmConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp index b20113f421..b261d344ec 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp @@ -11,8 +11,8 @@ namespace JS { // 3.4 Properties of the ShadowRealm Prototype Object, https://tc39.es/proposal-shadowrealm/#sec-properties-of-the-shadowrealm-prototype-object -ShadowRealmPrototype::ShadowRealmPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +ShadowRealmPrototype::ShadowRealmPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h index 74786eb20b..c97dba0fe6 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h @@ -15,7 +15,7 @@ class ShadowRealmPrototype final : public PrototypeObject<ShadowRealmPrototype, JS_PROTOTYPE_OBJECT(ShadowRealmPrototype, ShadowRealm, ShadowRealm); public: - explicit ShadowRealmPrototype(GlobalObject&); + explicit ShadowRealmPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ShadowRealmPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 767161ac96..98feb1719e 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -17,8 +17,8 @@ namespace JS { -StringConstructor::StringConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.String.as_string(), *global_object.function_prototype()) +StringConstructor::StringConstructor(Realm& realm) + : NativeFunction(vm().names.String.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.h b/Userland/Libraries/LibJS/Runtime/StringConstructor.h index 66d43884d1..67c99f0675 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.h @@ -14,7 +14,7 @@ class StringConstructor final : public NativeFunction { JS_OBJECT(StringConstructor, NativeFunction); public: - explicit StringConstructor(GlobalObject&); + explicit StringConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~StringConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp index dec68d8c47..a987f67895 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp @@ -13,8 +13,8 @@ namespace JS { -StringIteratorPrototype::StringIteratorPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.iterator_prototype()) +StringIteratorPrototype::StringIteratorPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h index 2d4ca3b176..69616ea2b6 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h @@ -16,7 +16,7 @@ class StringIteratorPrototype final : public PrototypeObject<StringIteratorProto JS_PROTOTYPE_OBJECT(StringIteratorPrototype, StringIterator, StringIterator); public: - StringIteratorPrototype(GlobalObject&); + StringIteratorPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~StringIteratorPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index 61f598f883..2cbde14500 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -102,8 +102,8 @@ static Optional<size_t> string_index_of(Utf16View const& string, Utf16View const return {}; } -StringPrototype::StringPrototype(GlobalObject& global_object) - : StringObject(*js_string(global_object.heap(), String::empty()), *global_object.object_prototype()) +StringPrototype::StringPrototype(Realm& realm) + : StringObject(*js_string(realm.vm(), String::empty()), *realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.h b/Userland/Libraries/LibJS/Runtime/StringPrototype.h index 2493e47002..9b32f73e67 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.h @@ -24,7 +24,7 @@ class StringPrototype final : public StringObject { JS_OBJECT(StringPrototype, StringObject); public: - explicit StringPrototype(GlobalObject&); + explicit StringPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~StringPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp index 66119673ed..0633cabdfa 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -10,8 +10,8 @@ namespace JS { -SymbolConstructor::SymbolConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Symbol.as_string(), *global_object.function_prototype()) +SymbolConstructor::SymbolConstructor(Realm& realm) + : NativeFunction(vm().names.Symbol.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h index 7919f8886c..88f5ea153b 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h @@ -14,7 +14,7 @@ class SymbolConstructor final : public NativeFunction { JS_OBJECT(SymbolConstructor, NativeFunction); public: - explicit SymbolConstructor(GlobalObject&); + explicit SymbolConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SymbolConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp index ad5dbc572f..2ca00f223f 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp @@ -18,8 +18,8 @@ namespace JS { -SymbolPrototype::SymbolPrototype(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +SymbolPrototype::SymbolPrototype(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h index 57c20cabaf..e8644d0f74 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h @@ -14,7 +14,7 @@ class SymbolPrototype final : public Object { JS_OBJECT(SymbolPrototype, Object); public: - explicit SymbolPrototype(GlobalObject&); + explicit SymbolPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~SymbolPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp index ab0fec5069..a940d86a85 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp @@ -11,8 +11,8 @@ namespace JS::Temporal { // 12.2 The Temporal.Calendar Constructor, https://tc39.es/proposal-temporal/#sec-temporal-calendar-constructor -CalendarConstructor::CalendarConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Calendar.as_string(), *global_object.function_prototype()) +CalendarConstructor::CalendarConstructor(Realm& realm) + : NativeFunction(vm().names.Calendar.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h index 8b31240a36..af3227a880 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h @@ -14,7 +14,7 @@ class CalendarConstructor final : public NativeFunction { JS_OBJECT(CalendarConstructor, NativeFunction); public: - explicit CalendarConstructor(GlobalObject&); + explicit CalendarConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~CalendarConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index a2242afc36..29f67ccc34 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -20,8 +20,8 @@ namespace JS::Temporal { // 12.4 Properties of the Temporal.Calendar Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-calendar-prototype-object -CalendarPrototype::CalendarPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +CalendarPrototype::CalendarPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h index 4c32e4a7d6..8b5092b40f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h @@ -15,7 +15,7 @@ class CalendarPrototype final : public PrototypeObject<CalendarPrototype, Calend JS_PROTOTYPE_OBJECT(CalendarPrototype, Calendar, Temporal.Calendar); public: - explicit CalendarPrototype(GlobalObject&); + explicit CalendarPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~CalendarPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp index d1534bd27a..454b861241 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp @@ -14,8 +14,8 @@ namespace JS::Temporal { // 7.1 The Temporal.Duration Constructor, https://tc39.es/proposal-temporal/#sec-temporal-duration-constructor -DurationConstructor::DurationConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Duration.as_string(), *global_object.function_prototype()) +DurationConstructor::DurationConstructor(Realm& realm) + : NativeFunction(vm().names.Duration.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h index 6c8bfa4ff6..10f1dab59f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h @@ -14,7 +14,7 @@ class DurationConstructor final : public NativeFunction { JS_OBJECT(DurationConstructor, NativeFunction); public: - explicit DurationConstructor(GlobalObject&); + explicit DurationConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DurationConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp index 11c6393d55..7bd757669b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp @@ -15,8 +15,8 @@ namespace JS::Temporal { // 7.3 Properties of the Temporal.Duration Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-duration-prototype-object -DurationPrototype::DurationPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +DurationPrototype::DurationPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h index e29f06ee61..75f156de5d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h @@ -15,7 +15,7 @@ class DurationPrototype final : public PrototypeObject<DurationPrototype, Durati JS_PROTOTYPE_OBJECT(DurationPrototype, Duration, Temporal.Duration); public: - explicit DurationPrototype(GlobalObject&); + explicit DurationPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~DurationPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp index d1af17388b..983d7938a6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp @@ -13,8 +13,8 @@ namespace JS::Temporal { // 8.1 The Temporal.Instant Constructor, https://tc39.es/proposal-temporal/#sec-temporal-instant-constructor -InstantConstructor::InstantConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.Instant.as_string(), *global_object.function_prototype()) +InstantConstructor::InstantConstructor(Realm& realm) + : NativeFunction(vm().names.Instant.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h index 32402d56be..7c414ee383 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h @@ -14,7 +14,7 @@ class InstantConstructor final : public NativeFunction { JS_OBJECT(InstantConstructor, NativeFunction); public: - explicit InstantConstructor(GlobalObject&); + explicit InstantConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~InstantConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 4a398050e5..13707ec818 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -19,8 +19,8 @@ namespace JS::Temporal { // 8.3 Properties of the Temporal.Instant Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-instant-prototype-object -InstantPrototype::InstantPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +InstantPrototype::InstantPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h index 04dfddf9de..3c0a753365 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h @@ -15,7 +15,7 @@ class InstantPrototype final : public PrototypeObject<InstantPrototype, Instant> JS_PROTOTYPE_OBJECT(InstantPrototype, Instant, Temporal.Instant); public: - explicit InstantPrototype(GlobalObject&); + explicit InstantPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~InstantPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp index d680cbc141..bd1b544257 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp @@ -20,8 +20,8 @@ namespace JS::Temporal { // 2 The Temporal.Now Object, https://tc39.es/proposal-temporal/#sec-temporal-now-object -Now::Now(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +Now::Now(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h index c17563432e..5297e0d486 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h @@ -15,7 +15,7 @@ class Now final : public Object { JS_OBJECT(Now, Object); public: - explicit Now(GlobalObject&); + explicit Now(Realm&); virtual void initialize(GlobalObject&) override; virtual ~Now() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp index 1f5ca65149..777f87f283 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp @@ -15,8 +15,8 @@ namespace JS::Temporal { // 3.1 The Temporal.PlainDate Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaindate-constructor -PlainDateConstructor::PlainDateConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.PlainDate.as_string(), *global_object.function_prototype()) +PlainDateConstructor::PlainDateConstructor(Realm& realm) + : NativeFunction(vm().names.PlainDate.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h index 29bf550f60..77fc5ac234 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h @@ -14,7 +14,7 @@ class PlainDateConstructor final : public NativeFunction { JS_OBJECT(PlainDateConstructor, NativeFunction); public: - explicit PlainDateConstructor(GlobalObject&); + explicit PlainDateConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainDateConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp index 0e52907904..b0bcc0129b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp @@ -20,8 +20,8 @@ namespace JS::Temporal { // 3.3 Properties of the Temporal.PlainDate Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaindate-prototype-object -PlainDatePrototype::PlainDatePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +PlainDatePrototype::PlainDatePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h index c38e62614a..04305b561f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h @@ -15,7 +15,7 @@ class PlainDatePrototype final : public PrototypeObject<PlainDatePrototype, Plai JS_PROTOTYPE_OBJECT(PlainDatePrototype, PlainDate, Temporal.PlainDate); public: - explicit PlainDatePrototype(GlobalObject&); + explicit PlainDatePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainDatePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp index 0eb904b404..3dbffaced2 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp @@ -15,8 +15,8 @@ namespace JS::Temporal { // 5.1 The Temporal.PlainDateTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaindatetime-constructor -PlainDateTimeConstructor::PlainDateTimeConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.PlainDateTime.as_string(), *global_object.function_prototype()) +PlainDateTimeConstructor::PlainDateTimeConstructor(Realm& realm) + : NativeFunction(vm().names.PlainDateTime.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h index 67d448ef81..7678a1aaff 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h @@ -14,7 +14,7 @@ class PlainDateTimeConstructor final : public NativeFunction { JS_OBJECT(PlainDateTimeConstructor, NativeFunction); public: - explicit PlainDateTimeConstructor(GlobalObject&); + explicit PlainDateTimeConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainDateTimeConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index a2231e9805..122ea0b8e8 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -21,8 +21,8 @@ namespace JS::Temporal { // 5.3 Properties of the Temporal.PlainDateTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaindatetime-prototype-object -PlainDateTimePrototype::PlainDateTimePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +PlainDateTimePrototype::PlainDateTimePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h index f46af1975e..9689a6d8d7 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h @@ -15,7 +15,7 @@ class PlainDateTimePrototype final : public PrototypeObject<PlainDateTimePrototy JS_PROTOTYPE_OBJECT(PlainDateTimePrototype, PlainDateTime, Temporal.PlainDateTime); public: - explicit PlainDateTimePrototype(GlobalObject&); + explicit PlainDateTimePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainDateTimePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp index 2011c54558..dd1d304871 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp @@ -14,8 +14,8 @@ namespace JS::Temporal { // 10.1 The Temporal.PlainMonthDay Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plainmonthday-constructor -PlainMonthDayConstructor::PlainMonthDayConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.PlainMonthDay.as_string(), *global_object.function_prototype()) +PlainMonthDayConstructor::PlainMonthDayConstructor(Realm& realm) + : NativeFunction(vm().names.PlainMonthDay.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h index f41fc06acb..555ce6585d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h @@ -14,7 +14,7 @@ class PlainMonthDayConstructor final : public NativeFunction { JS_OBJECT(PlainMonthDayConstructor, NativeFunction); public: - explicit PlainMonthDayConstructor(GlobalObject&); + explicit PlainMonthDayConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainMonthDayConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index 8f274343d0..4cf6963717 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -15,8 +15,8 @@ namespace JS::Temporal { // 10.3 Properties of the Temporal.PlainMonthDay Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plainmonthday-prototype-object -PlainMonthDayPrototype::PlainMonthDayPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +PlainMonthDayPrototype::PlainMonthDayPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h index 066faa83c8..d99aa31435 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h @@ -15,7 +15,7 @@ class PlainMonthDayPrototype final : public PrototypeObject<PlainMonthDayPrototy JS_PROTOTYPE_OBJECT(PlainMonthDayPrototype, PlainMonthDay, Temporal.PlainMonthDay); public: - explicit PlainMonthDayPrototype(GlobalObject&); + explicit PlainMonthDayPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainMonthDayPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp index d98c8c0eb1..2d9606c706 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp @@ -13,8 +13,8 @@ namespace JS::Temporal { // 4.1 The Temporal.PlainTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plaintime-constructor -PlainTimeConstructor::PlainTimeConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.PlainTime.as_string(), *global_object.function_prototype()) +PlainTimeConstructor::PlainTimeConstructor(Realm& realm) + : NativeFunction(vm().names.PlainTime.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h index d3b13730e4..66d477111a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h @@ -14,7 +14,7 @@ class PlainTimeConstructor final : public NativeFunction { JS_OBJECT(PlainTimeConstructor, NativeFunction); public: - explicit PlainTimeConstructor(GlobalObject&); + explicit PlainTimeConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainTimeConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index b0508c1791..206a9f25e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -20,8 +20,8 @@ namespace JS::Temporal { // 4.3 Properties of the Temporal.PlainTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plaintime-prototype-object -PlainTimePrototype::PlainTimePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +PlainTimePrototype::PlainTimePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h index 5341989da2..288f245757 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h @@ -15,7 +15,7 @@ class PlainTimePrototype final : public PrototypeObject<PlainTimePrototype, Plai JS_PROTOTYPE_OBJECT(PlainTimePrototype, PlainTime, Temporal.PlainTime); public: - explicit PlainTimePrototype(GlobalObject&); + explicit PlainTimePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainTimePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp index 930b749079..14005deab6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp @@ -15,8 +15,8 @@ namespace JS::Temporal { // 9.1 The Temporal.PlainYearMonth Constructor, https://tc39.es/proposal-temporal/#sec-temporal-plainyearmonth-constructor -PlainYearMonthConstructor::PlainYearMonthConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.PlainYearMonth.as_string(), *global_object.function_prototype()) +PlainYearMonthConstructor::PlainYearMonthConstructor(Realm& realm) + : NativeFunction(vm().names.PlainYearMonth.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h index fbb76d0794..f1b7381b1d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h @@ -14,7 +14,7 @@ class PlainYearMonthConstructor final : public NativeFunction { JS_OBJECT(PlainYearMonthConstructor, NativeFunction); public: - explicit PlainYearMonthConstructor(GlobalObject&); + explicit PlainYearMonthConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainYearMonthConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index cf2abb4d57..f7a9505679 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -17,8 +17,8 @@ namespace JS::Temporal { // 9.3 Properties of the Temporal.PlainYearMonth Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-plainyearmonth-prototype-object -PlainYearMonthPrototype::PlainYearMonthPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +PlainYearMonthPrototype::PlainYearMonthPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h index 216c72638b..9fc89e06cf 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h @@ -15,7 +15,7 @@ class PlainYearMonthPrototype final : public PrototypeObject<PlainYearMonthProto JS_PROTOTYPE_OBJECT(PlainYearMonthPrototype, PlainYearMonth, Temporal.PlainYearMonth); public: - explicit PlainYearMonthPrototype(GlobalObject&); + explicit PlainYearMonthPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~PlainYearMonthPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp index ca919452f4..ec8b94d358 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp @@ -21,8 +21,8 @@ namespace JS::Temporal { // 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects -Temporal::Temporal(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +Temporal::Temporal(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } @@ -31,12 +31,13 @@ void Temporal::initialize(GlobalObject& global_object) Object::initialize(global_object); auto& vm = this->vm(); + auto& realm = *global_object.associated_realm(); // 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal"), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.Now, heap().allocate<Now>(global_object, global_object), attr); + define_direct_property(vm.names.Now, heap().allocate<Now>(global_object, realm), attr); define_direct_property(vm.names.Calendar, global_object.temporal_calendar_constructor(), attr); define_direct_property(vm.names.Duration, global_object.temporal_duration_constructor(), attr); define_direct_property(vm.names.Instant, global_object.temporal_instant_constructor(), attr); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h index f2f34f2d32..2fde1bcd58 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h @@ -14,7 +14,7 @@ class Temporal final : public Object { JS_OBJECT(Temporal, Object); public: - explicit Temporal(GlobalObject&); + explicit Temporal(Realm&); virtual void initialize(GlobalObject&) override; virtual ~Temporal() override = default; }; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp index e66cff3d2e..d5ce0dc26f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp @@ -11,8 +11,8 @@ namespace JS::Temporal { // 11.2 The Temporal.TimeZone Constructor, https://tc39.es/proposal-temporal/#sec-temporal-timezone-constructor -TimeZoneConstructor::TimeZoneConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.TimeZone.as_string(), *global_object.function_prototype()) +TimeZoneConstructor::TimeZoneConstructor(Realm& realm) + : NativeFunction(vm().names.TimeZone.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h index b5b51265ae..282f21e924 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h @@ -14,7 +14,7 @@ class TimeZoneConstructor final : public NativeFunction { JS_OBJECT(TimeZoneConstructor, NativeFunction); public: - explicit TimeZoneConstructor(GlobalObject&); + explicit TimeZoneConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~TimeZoneConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp index 45b61027fd..11849ae640 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp @@ -17,8 +17,8 @@ namespace JS::Temporal { // 11.4 Properties of the Temporal.TimeZone Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-timezone-prototype-object -TimeZonePrototype::TimeZonePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +TimeZonePrototype::TimeZonePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h index a84caad588..48be78acac 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h @@ -15,7 +15,7 @@ class TimeZonePrototype final : public PrototypeObject<TimeZonePrototype, TimeZo JS_PROTOTYPE_OBJECT(TimeZonePrototype, TimeZone, Temporal.TimeZone); public: - explicit TimeZonePrototype(GlobalObject&); + explicit TimeZonePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~TimeZonePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp index 4deead2849..9e0bd19c06 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp @@ -16,8 +16,8 @@ namespace JS::Temporal { // 6.1 The Temporal.ZonedDateTime Constructor, https://tc39.es/proposal-temporal/#sec-temporal-zoneddatetime-constructor -ZonedDateTimeConstructor::ZonedDateTimeConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.ZonedDateTime.as_string(), *global_object.function_prototype()) +ZonedDateTimeConstructor::ZonedDateTimeConstructor(Realm& realm) + : NativeFunction(vm().names.ZonedDateTime.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h index 87ce8ae875..b2d1b5303e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h @@ -14,7 +14,7 @@ class ZonedDateTimeConstructor final : public NativeFunction { JS_OBJECT(ZonedDateTimeConstructor, NativeFunction); public: - explicit ZonedDateTimeConstructor(GlobalObject&); + explicit ZonedDateTimeConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ZonedDateTimeConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index b4745dc092..1154fadba4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -20,8 +20,8 @@ namespace JS::Temporal { // 6.3 Properties of the Temporal.ZonedDateTime Prototype Object, https://tc39.es/proposal-temporal/#sec-properties-of-the-temporal-zoneddatetime-prototype-object -ZonedDateTimePrototype::ZonedDateTimePrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +ZonedDateTimePrototype::ZonedDateTimePrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h index e8be5871d5..9190ed062f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h @@ -15,7 +15,7 @@ class ZonedDateTimePrototype final : public PrototypeObject<ZonedDateTimePrototy JS_PROTOTYPE_OBJECT(ZonedDateTimePrototype, ZonedDateTime, Temporal.ZonedDateTime); public: - explicit ZonedDateTimePrototype(GlobalObject&); + explicit ZonedDateTimePrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~ZonedDateTimePrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index 832f1df2f4..370aa2482f 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -459,19 +459,23 @@ void TypedArrayBase::visit_edges(Visitor& visitor) m_content_type = ContentType::Number; \ } \ \ - ClassName::~ClassName() { } \ + ClassName::~ClassName() \ + { \ + } \ \ FlyString const& ClassName::element_name() const \ { \ return vm().names.ClassName.as_string(); \ } \ \ - PrototypeName::PrototypeName(GlobalObject& global_object) \ - : Object(*global_object.typed_array_prototype()) \ + PrototypeName::PrototypeName(Realm& realm) \ + : Object(*realm.global_object().typed_array_prototype()) \ { \ } \ \ - PrototypeName::~PrototypeName() { } \ + PrototypeName::~PrototypeName() \ + { \ + } \ \ void PrototypeName::initialize(GlobalObject& global_object) \ { \ @@ -480,12 +484,14 @@ void TypedArrayBase::visit_edges(Visitor& visitor) define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \ } \ \ - ConstructorName::ConstructorName(GlobalObject& global_object) \ - : TypedArrayConstructor(vm().names.ClassName.as_string(), *global_object.typed_array_constructor()) \ + ConstructorName::ConstructorName(Realm& realm) \ + : TypedArrayConstructor(vm().names.ClassName.as_string(), *realm.global_object().typed_array_constructor()) \ { \ } \ \ - ConstructorName::~ConstructorName() { } \ + ConstructorName::~ConstructorName() \ + { \ + } \ \ void ConstructorName::initialize(GlobalObject& global_object) \ { \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 515267119d..92fb885652 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -471,7 +471,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(GlobalObject& global_obje JS_OBJECT(PrototypeName, Object); \ \ public: \ - PrototypeName(GlobalObject&); \ + PrototypeName(Realm&); \ virtual void initialize(GlobalObject&) override; \ virtual ~PrototypeName() override; \ }; \ @@ -479,7 +479,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(GlobalObject& global_obje JS_OBJECT(ConstructorName, TypedArrayConstructor); \ \ public: \ - explicit ConstructorName(GlobalObject&); \ + explicit ConstructorName(Realm&); \ virtual void initialize(GlobalObject&) override; \ virtual ~ConstructorName() override; \ \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index 96937dac36..dcb64765b7 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -16,8 +16,8 @@ TypedArrayConstructor::TypedArrayConstructor(FlyString const& name, Object& prot { } -TypedArrayConstructor::TypedArrayConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.TypedArray.as_string(), *global_object.function_prototype()) +TypedArrayConstructor::TypedArrayConstructor(Realm& realm) + : NativeFunction(vm().names.TypedArray.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h index 6d53099685..6d668e6330 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h @@ -15,7 +15,7 @@ class TypedArrayConstructor : public NativeFunction { public: TypedArrayConstructor(FlyString const& name, Object& prototype); - explicit TypedArrayConstructor(GlobalObject&); + explicit TypedArrayConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~TypedArrayConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index 65e4eaead3..5229cedb71 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -15,8 +15,8 @@ namespace JS { -TypedArrayPrototype::TypedArrayPrototype(GlobalObject& global_object) - : Object(*global_object.object_prototype()) +TypedArrayPrototype::TypedArrayPrototype(Realm& realm) + : Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h index 01a7222a39..39b1ffa02d 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h @@ -15,7 +15,7 @@ class TypedArrayPrototype final : public Object { JS_OBJECT(TypedArrayPrototype, Object); public: - explicit TypedArrayPrototype(GlobalObject&); + explicit TypedArrayPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~TypedArrayPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp index 88f3aa6dc9..a2e22b4db0 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp @@ -13,8 +13,8 @@ namespace JS { -WeakMapConstructor::WeakMapConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.WeakMap.as_string(), *global_object.function_prototype()) +WeakMapConstructor::WeakMapConstructor(Realm& realm) + : NativeFunction(vm().names.WeakMap.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h index 58062110cd..19eb0cd345 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h @@ -14,7 +14,7 @@ class WeakMapConstructor final : public NativeFunction { JS_OBJECT(WeakMapConstructor, NativeFunction); public: - explicit WeakMapConstructor(GlobalObject&); + explicit WeakMapConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~WeakMapConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp index c84239e2f2..cd5ee699ed 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp @@ -11,8 +11,8 @@ namespace JS { -WeakMapPrototype::WeakMapPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +WeakMapPrototype::WeakMapPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h index 78ab6f1ad1..af305ca9f2 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h @@ -15,7 +15,7 @@ class WeakMapPrototype final : public PrototypeObject<WeakMapPrototype, WeakMap> JS_PROTOTYPE_OBJECT(WeakMapPrototype, WeakMap, WeakMap); public: - WeakMapPrototype(GlobalObject&); + WeakMapPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~WeakMapPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp index 6dd6241cf2..7fe27eacd3 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp @@ -12,8 +12,8 @@ namespace JS { -WeakRefConstructor::WeakRefConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.WeakRef.as_string(), *global_object.function_prototype()) +WeakRefConstructor::WeakRefConstructor(Realm& realm) + : NativeFunction(vm().names.WeakRef.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h index b850735b4f..24cbbd3d67 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h @@ -14,7 +14,7 @@ class WeakRefConstructor final : public NativeFunction { JS_OBJECT(WeakRefConstructor, NativeFunction); public: - explicit WeakRefConstructor(GlobalObject&); + explicit WeakRefConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~WeakRefConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp index dee76df167..258f33ecc3 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp @@ -9,8 +9,8 @@ namespace JS { -WeakRefPrototype::WeakRefPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +WeakRefPrototype::WeakRefPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h index 8769e8a19d..eca9dff784 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h @@ -15,7 +15,7 @@ class WeakRefPrototype final : public PrototypeObject<WeakRefPrototype, WeakRef> JS_PROTOTYPE_OBJECT(WeakRefPrototype, WeakRef, WeakRef); public: - WeakRefPrototype(GlobalObject&); + WeakRefPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~WeakRefPrototype() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp index c83c1725ba..9297c17d6c 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp @@ -13,8 +13,8 @@ namespace JS { -WeakSetConstructor::WeakSetConstructor(GlobalObject& global_object) - : NativeFunction(vm().names.WeakSet.as_string(), *global_object.function_prototype()) +WeakSetConstructor::WeakSetConstructor(Realm& realm) + : NativeFunction(vm().names.WeakSet.as_string(), *realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h index d9d798d586..5b80fe368a 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h @@ -14,7 +14,7 @@ class WeakSetConstructor final : public NativeFunction { JS_OBJECT(WeakSetConstructor, NativeFunction); public: - explicit WeakSetConstructor(GlobalObject&); + explicit WeakSetConstructor(Realm&); virtual void initialize(GlobalObject&) override; virtual ~WeakSetConstructor() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp index cd6a36655e..d76131eb48 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp @@ -11,8 +11,8 @@ namespace JS { -WeakSetPrototype::WeakSetPrototype(GlobalObject& global_object) - : PrototypeObject(*global_object.object_prototype()) +WeakSetPrototype::WeakSetPrototype(Realm& realm) + : PrototypeObject(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h index ea9e34643f..93d7c16663 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h @@ -15,7 +15,7 @@ class WeakSetPrototype final : public PrototypeObject<WeakSetPrototype, WeakSet> JS_PROTOTYPE_OBJECT(WeakSetPrototype, WeakSet, WeakSet); public: - WeakSetPrototype(GlobalObject&); + WeakSetPrototype(Realm&); virtual void initialize(GlobalObject&) override; virtual ~WeakSetPrototype() override = default; diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp index d735f17660..b881df327d 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp @@ -14,8 +14,8 @@ namespace Web::Bindings { -AudioConstructor::AudioConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +AudioConstructor::AudioConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h index ee9d825b3d..912bef0885 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h @@ -13,7 +13,7 @@ namespace Web::Bindings { class AudioConstructor final : public JS::NativeFunction { public: - explicit AudioConstructor(JS::GlobalObject&); + explicit AudioConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~AudioConstructor() override = default; diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp index d9d7fe62d9..a46ec1998f 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp @@ -13,8 +13,8 @@ namespace Web::Bindings { -CSSNamespace::CSSNamespace(JS::GlobalObject& global_object) - : JS::Object(*global_object.object_prototype()) +CSSNamespace::CSSNamespace(JS::Realm& realm) + : JS::Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h index 1ab81ef776..05d4979a4a 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h +++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h @@ -16,7 +16,7 @@ class CSSNamespace final : public JS::Object { JS_OBJECT(CSSNamespace, JS::Object) public: - explicit CSSNamespace(JS::GlobalObject&); + explicit CSSNamespace(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~CSSNamespace() override = default; diff --git a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp index 87913acdb1..c161fea585 100644 --- a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp +++ b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.cpp @@ -12,8 +12,8 @@ namespace Web { namespace Bindings { -EventListenerWrapper::EventListenerWrapper(JS::GlobalObject& global_object, DOM::IDLEventListener& impl) - : Wrapper(*global_object.object_prototype()) +EventListenerWrapper::EventListenerWrapper(JS::Realm& realm, DOM::IDLEventListener& impl) + : Wrapper(*realm.global_object().object_prototype()) , m_impl(impl) { } diff --git a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.h b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.h index a90a539b74..8c1dbcd216 100644 --- a/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.h +++ b/Userland/Libraries/LibWeb/Bindings/EventListenerWrapper.h @@ -15,7 +15,7 @@ class EventListenerWrapper final : public Wrapper { JS_OBJECT(EventListenerWrapper, Wrapper); public: - EventListenerWrapper(JS::GlobalObject&, DOM::IDLEventListener&); + EventListenerWrapper(JS::Realm& realm, DOM::IDLEventListener&); virtual ~EventListenerWrapper() override = default; DOM::IDLEventListener& impl() { return *m_impl; } diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index 6f839b1acc..ee7aeaaaf6 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -14,8 +14,8 @@ namespace Web::Bindings { -ImageConstructor::ImageConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +ImageConstructor::ImageConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h index a7ecfd75be..3a4a603497 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h @@ -13,7 +13,7 @@ namespace Web::Bindings { class ImageConstructor final : public JS::NativeFunction { public: - explicit ImageConstructor(JS::GlobalObject&); + explicit ImageConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~ImageConstructor() override = default; diff --git a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp index 5517e15b3f..a6be55e5da 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.cpp @@ -11,8 +11,8 @@ namespace Web::Bindings { -LocationConstructor::LocationConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +LocationConstructor::LocationConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h index 4d35774851..dd05c3551e 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationConstructor.h @@ -14,7 +14,7 @@ class LocationConstructor : public JS::NativeFunction { JS_OBJECT(LocationConstructor, JS::NativeFunction); public: - explicit LocationConstructor(JS::GlobalObject&); + explicit LocationConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~LocationConstructor() override; diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index 6bff5f40c3..d51a4e4bea 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -23,8 +23,8 @@ namespace Web::Bindings { // https://html.spec.whatwg.org/multipage/history.html#the-location-interface -LocationObject::LocationObject(JS::GlobalObject& global_object) - : Object(static_cast<WindowObject&>(global_object).ensure_web_prototype<LocationPrototype>("Location")) +LocationObject::LocationObject(JS::Realm& realm) + : Object(static_cast<WindowObject&>(realm.global_object()).ensure_web_prototype<LocationPrototype>("Location")) , m_default_properties(heap()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.h b/Userland/Libraries/LibWeb/Bindings/LocationObject.h index ba2611be91..34c0684d84 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.h @@ -21,7 +21,7 @@ class LocationObject final : public JS::Object { JS_OBJECT(LocationObject, JS::Object); public: - explicit LocationObject(JS::GlobalObject&); + explicit LocationObject(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~LocationObject() override = default; diff --git a/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h b/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h index c4303742ac..cc597d0ac4 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h +++ b/Userland/Libraries/LibWeb/Bindings/LocationPrototype.h @@ -18,8 +18,8 @@ class LocationPrototype final : public JS::Object { JS_OBJECT(LocationPrototype, JS::Object); public: - explicit LocationPrototype(JS::GlobalObject& global_object) - : JS::Object(*global_object.object_prototype()) + explicit LocationPrototype(JS::Realm& realm) + : JS::Object(*realm.global_object().object_prototype()) { } }; diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp index a248df808f..2deb4efef2 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.cpp @@ -11,8 +11,8 @@ namespace Web::Bindings { -NavigatorConstructor::NavigatorConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +NavigatorConstructor::NavigatorConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h index b98347db74..12054f5ebf 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorConstructor.h @@ -14,7 +14,7 @@ class NavigatorConstructor : public JS::NativeFunction { JS_OBJECT(NavigatorConstructor, JS::NativeFunction); public: - explicit NavigatorConstructor(JS::GlobalObject&); + explicit NavigatorConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~NavigatorConstructor() override; diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp index 479467f955..a7f844b80f 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.cpp @@ -13,8 +13,8 @@ namespace Web { namespace Bindings { -NavigatorObject::NavigatorObject(JS::GlobalObject& global_object) - : Object(static_cast<WindowObject&>(global_object).ensure_web_prototype<NavigatorPrototype>("Navigator")) +NavigatorObject::NavigatorObject(JS::Realm& realm) + : Object(static_cast<WindowObject&>(realm.global_object()).ensure_web_prototype<NavigatorPrototype>("Navigator")) { } diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h index 89054a1e40..026f65aab4 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h @@ -16,7 +16,7 @@ class NavigatorObject final : public JS::Object { JS_OBJECT(NavigatorObject, JS::Object); public: - NavigatorObject(JS::GlobalObject&); + NavigatorObject(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~NavigatorObject() override = default; diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h b/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h index b213b77ef3..c94aa13e60 100644 --- a/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h +++ b/Userland/Libraries/LibWeb/Bindings/NavigatorPrototype.h @@ -18,8 +18,8 @@ class NavigatorPrototype final : public JS::Object { JS_OBJECT(NavigatorPrototype, JS::Object); public: - explicit NavigatorPrototype(JS::GlobalObject& global_object) - : JS::Object(*global_object.object_prototype()) + explicit NavigatorPrototype(JS::Realm& realm) + : JS::Object(*realm.global_object().object_prototype()) { } }; diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index e63daebfc3..d8582e8830 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -15,8 +15,8 @@ namespace Web::Bindings { -OptionConstructor::OptionConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +OptionConstructor::OptionConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h index c986d076d0..d485f2859e 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h @@ -13,7 +13,7 @@ namespace Web::Bindings { class OptionConstructor final : public JS::NativeFunction { public: - explicit OptionConstructor(JS::GlobalObject&); + explicit OptionConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~OptionConstructor() override = default; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp index 87ad5904f1..be0d7c5cdb 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp @@ -11,8 +11,8 @@ namespace Web::Bindings { -WindowConstructor::WindowConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +WindowConstructor::WindowConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h index 3a2493e4c3..5b25ee6c92 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h @@ -14,7 +14,7 @@ class WindowConstructor : public JS::NativeFunction { JS_OBJECT(WindowConstructor, JS::NativeFunction); public: - explicit WindowConstructor(JS::GlobalObject&); + explicit WindowConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~WindowConstructor() override; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index 9432b73748..b4ff04a58e 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -63,6 +63,8 @@ void WindowObject::initialize_global_object() Object::set_prototype(&ensure_web_prototype<WindowPrototype>("Window")); + auto& realm = *associated_realm(); + // FIXME: These should be native accessors, not properties define_direct_property("window", this, JS::Attribute::Enumerable); define_direct_property("frames", this, JS::Attribute::Enumerable); @@ -117,7 +119,7 @@ void WindowObject::initialize_global_object() define_native_accessor("screenLeft", screen_left_getter, {}, attr); define_native_accessor("screenTop", screen_top_getter, {}, attr); - define_direct_property("CSS", heap().allocate<CSSNamespace>(*this, *this), 0); + define_direct_property("CSS", heap().allocate<CSSNamespace>(*this, realm), 0); define_native_accessor("localStorage", local_storage_getter, {}, attr); define_native_accessor("sessionStorage", session_storage_getter, {}, attr); @@ -126,9 +128,9 @@ void WindowObject::initialize_global_object() // Legacy define_native_accessor("event", event_getter, event_setter, JS::Attribute::Enumerable); - m_location_object = heap().allocate<LocationObject>(*this, *this); + m_location_object = heap().allocate<LocationObject>(*this, realm); - auto* m_navigator_object = heap().allocate<NavigatorObject>(*this, *this); + auto* m_navigator_object = heap().allocate<NavigatorObject>(*this, realm); define_direct_property("navigator", m_navigator_object, JS::Attribute::Enumerable | JS::Attribute::Configurable); define_direct_property("clientInformation", m_navigator_object, JS::Attribute::Enumerable | JS::Attribute::Configurable); @@ -136,7 +138,7 @@ void WindowObject::initialize_global_object() define_native_accessor("location", location_getter, location_setter, JS::Attribute::Enumerable); // WebAssembly "namespace" - define_direct_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable); + define_direct_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, realm), JS::Attribute::Enumerable | JS::Attribute::Configurable); // HTML::GlobalEventHandlers and HTML::WindowEventHandlers #define __ENUMERATE(attribute, event_name) \ diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.h b/Userland/Libraries/LibWeb/Bindings/WindowObject.h index 524621e069..5d7f3be406 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.h @@ -53,7 +53,8 @@ public: auto it = m_prototypes.find(class_name); if (it != m_prototypes.end()) return *it->value; - auto* prototype = heap().allocate<T>(*this, *this); + auto& realm = *associated_realm(); + auto* prototype = heap().allocate<T>(*this, realm); m_prototypes.set(class_name, prototype); return *prototype; } @@ -64,7 +65,8 @@ public: auto it = m_constructors.find(class_name); if (it != m_constructors.end()) return *it->value; - auto* constructor = heap().allocate<T>(*this, *this); + auto& realm = *associated_realm(); + auto* constructor = heap().allocate<T>(*this, realm); m_constructors.set(class_name, constructor); define_direct_property(class_name, JS::Value(constructor), JS::Attribute::Writable | JS::Attribute::Configurable); return *constructor; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h index ec57ae2e94..9d99573be7 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h @@ -19,8 +19,8 @@ class WindowPrototype final : public JS::Object { JS_OBJECT(WindowPrototype, JS::Object); public: - explicit WindowPrototype(JS::GlobalObject& global_object) - : JS::Object(static_cast<WindowObject&>(global_object).ensure_web_prototype<EventTargetPrototype>("EventTarget")) + explicit WindowPrototype(JS::Realm& realm) + : JS::Object(static_cast<WindowObject&>(realm.global_object()).ensure_web_prototype<EventTargetPrototype>("EventTarget")) { } }; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp b/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp index 82f2f80d60..822b63bff3 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp @@ -22,8 +22,8 @@ namespace Web::Bindings { // 7.4 The WindowProxy exotic object, https://html.spec.whatwg.org/multipage/window-object.html#the-windowproxy-exotic-object -WindowProxy::WindowProxy(JS::GlobalObject& global_object, WindowObject& window) - : JS::Object(global_object, nullptr) +WindowProxy::WindowProxy(JS::Realm& realm, WindowObject& window) + : JS::Object(realm, nullptr) , m_window(&window) { } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowProxy.h b/Userland/Libraries/LibWeb/Bindings/WindowProxy.h index f557d12c9f..42f8c560ac 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowProxy.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowProxy.h @@ -17,7 +17,7 @@ class WindowProxy final : public JS::Object { JS_OBJECT(WindowProxy, JS::Object); public: - WindowProxy(JS::GlobalObject&, WindowObject&); + WindowProxy(JS::Realm&, WindowObject&); virtual ~WindowProxy() override = default; virtual JS::ThrowCompletionOr<JS::Object*> internal_get_prototype_of() const override; diff --git a/Userland/Libraries/LibWeb/Bindings/Wrappable.h b/Userland/Libraries/LibWeb/Bindings/Wrappable.h index 26d2fbcc1d..79c6b75c6b 100644 --- a/Userland/Libraries/LibWeb/Bindings/Wrappable.h +++ b/Userland/Libraries/LibWeb/Bindings/Wrappable.h @@ -28,8 +28,9 @@ private: template<class NativeObject> inline Wrapper* wrap_impl(JS::GlobalObject& global_object, NativeObject& native_object) { + auto& realm = *global_object.associated_realm(); if (!native_object.wrapper()) { - native_object.set_wrapper(*global_object.heap().allocate<typename NativeObject::WrapperType>(global_object, global_object, native_object)); + native_object.set_wrapper(*global_object.heap().allocate<typename NativeObject::WrapperType>(global_object, realm, native_object)); } return native_object.wrapper(); } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp index 6c2517b363..b7441a457c 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp @@ -14,8 +14,8 @@ namespace Web::Bindings { -WebAssemblyInstanceConstructor::WebAssemblyInstanceConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +WebAssemblyInstanceConstructor::WebAssemblyInstanceConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } @@ -30,12 +30,14 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyInstanceConstructor::construct(Fun { auto& vm = this->vm(); auto& global_object = this->global_object(); + auto& realm = *global_object.associated_realm(); + auto* module_argument = TRY(vm.argument(0).to_object(global_object)); if (!is<WebAssemblyModuleObject>(module_argument)) return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::NotAnObjectOfType, "WebAssembly.Module"); auto& module_object = static_cast<WebAssemblyModuleObject&>(*module_argument); auto result = TRY(WebAssemblyObject::instantiate_module(module_object.module(), vm, global_object)); - return heap().allocate<WebAssemblyInstanceObject>(global_object, global_object, result); + return heap().allocate<WebAssemblyInstanceObject>(global_object, realm, result); } void WebAssemblyInstanceConstructor::initialize(JS::GlobalObject& global_object) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h index 90bdcb92a7..f217182b63 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h @@ -14,7 +14,7 @@ class WebAssemblyInstanceConstructor : public JS::NativeFunction { JS_OBJECT(WebAssemblyInstanceConstructor, JS::NativeFunction); public: - explicit WebAssemblyInstanceConstructor(JS::GlobalObject&); + explicit WebAssemblyInstanceConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~WebAssemblyInstanceConstructor() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp index 95c586ce6b..afae00d11a 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp @@ -17,8 +17,8 @@ namespace Web::Bindings { -WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::GlobalObject& global_object, size_t index) - : Object(static_cast<Web::Bindings::WindowObject&>(global_object).ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype")) +WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::Realm& realm, size_t index) + : Object(static_cast<Web::Bindings::WindowObject&>(realm.global_object()).ensure_web_prototype<WebAssemblyInstancePrototype>("WebAssemblyInstancePrototype")) , m_index(index) { } @@ -27,6 +27,8 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) { Object::initialize(global_object); + auto& realm = *global_object.associated_realm(); + VERIFY(!m_exports_object); m_exports_object = create(global_object, nullptr); auto& instance = this->instance(); @@ -44,7 +46,7 @@ void WebAssemblyInstanceObject::initialize(JS::GlobalObject& global_object) [&](Wasm::MemoryAddress const& address) { Optional<WebAssemblyMemoryObject*> object = cache.memory_instances.get(address); if (!object.has_value()) { - object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(global_object, global_object, address); + object = heap().allocate<Web::Bindings::WebAssemblyMemoryObject>(global_object, realm, address); cache.memory_instances.set(address, *object); } m_exports_object->define_direct_property(export_.name(), *object, JS::default_attributes); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h index 4d342603fa..de8cd1381e 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h @@ -19,7 +19,7 @@ class WebAssemblyInstanceObject final : public JS::Object { JS_OBJECT(WebAssemblyInstanceObject, Object); public: - explicit WebAssemblyInstanceObject(JS::GlobalObject&, size_t index); + explicit WebAssemblyInstanceObject(JS::Realm&, size_t index); virtual void initialize(JS::GlobalObject&) override; virtual ~WebAssemblyInstanceObject() override = default; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h index 2fb24d861d..06f51667ba 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h @@ -17,8 +17,8 @@ class WebAssemblyInstancePrototype final : public JS::Object { JS_OBJECT(WebAssemblyInstancePrototype, Object); public: - explicit WebAssemblyInstancePrototype(JS::GlobalObject& global_object) - : JS::Object(*global_object.object_prototype()) + explicit WebAssemblyInstancePrototype(JS::Realm& realm) + : JS::Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp index 76330a251b..d37649efef 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp @@ -12,8 +12,8 @@ namespace Web::Bindings { -WebAssemblyMemoryConstructor::WebAssemblyMemoryConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +WebAssemblyMemoryConstructor::WebAssemblyMemoryConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } @@ -28,6 +28,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyMemoryConstructor::construct(Funct { auto& vm = this->vm(); auto& global_object = this->global_object(); + auto& realm = *global_object.associated_realm(); auto descriptor = TRY(vm.argument(0).to_object(global_object)); auto initial_value = TRY(descriptor->get("initial")); @@ -50,7 +51,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyMemoryConstructor::construct(Funct if (!WebAssemblyObject::s_abstract_machine.store().get(*address)->grow(initial)) return vm.throw_completion<JS::TypeError>(global_object, String::formatted("Wasm Memory grow failed: {}", initial)); - return vm.heap().allocate<WebAssemblyMemoryObject>(global_object, global_object, *address); + return vm.heap().allocate<WebAssemblyMemoryObject>(global_object, realm, *address); } void WebAssemblyMemoryConstructor::initialize(JS::GlobalObject& global_object) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h index 9391ec7b03..f435b0905e 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h @@ -14,7 +14,7 @@ class WebAssemblyMemoryConstructor : public JS::NativeFunction { JS_OBJECT(WebAssemblyMemoryConstructor, JS::NativeFunction); public: - explicit WebAssemblyMemoryConstructor(JS::GlobalObject&); + explicit WebAssemblyMemoryConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~WebAssemblyMemoryConstructor() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h index 4de2a28371..390761f23f 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h @@ -19,8 +19,8 @@ class WebAssemblyMemoryPrototype final : public JS::Object { JS_OBJECT(WebAssemblyMemoryPrototype, JS::Object); public: - explicit WebAssemblyMemoryPrototype(JS::GlobalObject& global_object) - : JS::Object(*global_object.object_prototype()) + explicit WebAssemblyMemoryPrototype(JS::Realm& realm) + : JS::Object(*realm.global_object().object_prototype()) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp index 1df0df1c6f..072f0ab8cd 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp @@ -14,8 +14,8 @@ namespace Web::Bindings { -WebAssemblyModuleConstructor::WebAssemblyModuleConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +WebAssemblyModuleConstructor::WebAssemblyModuleConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } @@ -30,11 +30,12 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyModuleConstructor::construct(Funct { auto& vm = this->vm(); auto& global_object = this->global_object(); + auto& realm = *global_object.associated_realm(); auto* buffer_object = TRY(vm.argument(0).to_object(global_object)); auto result = TRY(parse_module(global_object, buffer_object)); - return heap().allocate<WebAssemblyModuleObject>(global_object, global_object, result); + return heap().allocate<WebAssemblyModuleObject>(global_object, realm, result); } void WebAssemblyModuleConstructor::initialize(JS::GlobalObject& global_object) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h index a77815343d..ac1dfdf8a4 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h @@ -14,7 +14,7 @@ class WebAssemblyModuleConstructor : public JS::NativeFunction { JS_OBJECT(WebAssemblyModuleConstructor, JS::NativeFunction); public: - explicit WebAssemblyModuleConstructor(JS::GlobalObject&); + explicit WebAssemblyModuleConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~WebAssemblyModuleConstructor() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.cpp index 27e5340197..de74c2d31a 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.cpp @@ -9,8 +9,8 @@ namespace Web::Bindings { -WebAssemblyModuleObject::WebAssemblyModuleObject(JS::GlobalObject& global_object, size_t index) - : Object(static_cast<WindowObject&>(global_object).ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype")) +WebAssemblyModuleObject::WebAssemblyModuleObject(JS::Realm& realm, size_t index) + : Object(static_cast<WindowObject&>(realm.global_object()).ensure_web_prototype<WebAssemblyModulePrototype>("WebAssemblyModulePrototype")) , m_index(index) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h index 38911c36bf..77ed857184 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h @@ -18,7 +18,7 @@ class WebAssemblyModuleObject final : public JS::Object { JS_OBJECT(WebAssemblyModuleObject, Object); public: - explicit WebAssemblyModuleObject(JS::GlobalObject&, size_t index); + explicit WebAssemblyModuleObject(JS::Realm&, size_t index); virtual ~WebAssemblyModuleObject() override = default; size_t index() const { return m_index; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h index eaf3c84178..b2177e2e98 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModulePrototype.h @@ -19,8 +19,8 @@ class WebAssemblyModulePrototype final : public JS::Object { JS_OBJECT(WebAssemblyModulePrototype, JS::Object); public: - explicit WebAssemblyModulePrototype(JS::GlobalObject& global_object) - : JS::Object(*global_object.object_prototype()) + explicit WebAssemblyModulePrototype(JS::Realm& realm) + : JS::Object(*realm.global_object().object_prototype()) { } }; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp index 10e57ca3c3..898882e2ee 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp @@ -25,8 +25,8 @@ namespace Web::Bindings { -WebAssemblyObject::WebAssemblyObject(JS::GlobalObject& global_object) - : Object(*global_object.object_prototype()) +WebAssemblyObject::WebAssemblyObject(JS::Realm& realm) + : Object(*realm.global_object().object_prototype()) { s_abstract_machine.enable_instruction_count_limit(); } @@ -156,6 +156,8 @@ JS::ThrowCompletionOr<size_t> parse_module(JS::GlobalObject& global_object, JS:: JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::compile) { + auto& realm = *global_object.associated_realm(); + // FIXME: This shouldn't block! auto buffer_or_error = vm.argument(0).to_object(global_object); JS::Value rejection_value; @@ -172,7 +174,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::compile) if (result.is_error()) promise->reject(*result.release_error().value()); else - promise->fulfill(vm.heap().allocate<WebAssemblyModuleObject>(global_object, global_object, result.release_value())); + promise->fulfill(vm.heap().allocate<WebAssemblyModuleObject>(global_object, realm, result.release_value())); return promise; } @@ -317,6 +319,8 @@ JS::ThrowCompletionOr<size_t> WebAssemblyObject::instantiate_module(Wasm::Module JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::instantiate) { + auto& realm = *global_object.associated_realm(); + // FIXME: This shouldn't block! auto buffer_or_error = vm.argument(0).to_object(global_object); auto promise = JS::Promise::create(global_object); @@ -350,10 +354,10 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyObject::instantiate) if (result.is_error()) { promise->reject(*result.release_error().value()); } else { - auto instance_object = vm.heap().allocate<WebAssemblyInstanceObject>(global_object, global_object, result.release_value()); + auto instance_object = vm.heap().allocate<WebAssemblyInstanceObject>(global_object, realm, result.release_value()); if (should_return_module) { auto object = JS::Object::create(global_object, nullptr); - object->define_direct_property("module", vm.heap().allocate<WebAssemblyModuleObject>(global_object, global_object, s_compiled_modules.size() - 1), JS::default_attributes); + object->define_direct_property("module", vm.heap().allocate<WebAssemblyModuleObject>(global_object, realm, s_compiled_modules.size() - 1), JS::default_attributes); object->define_direct_property("instance", instance_object, JS::default_attributes); promise->fulfill(object); } else { @@ -477,8 +481,8 @@ JS::NativeFunction* create_native_function(JS::GlobalObject& global_object, Wasm return function; } -WebAssemblyMemoryObject::WebAssemblyMemoryObject(JS::GlobalObject& global_object, Wasm::MemoryAddress address) - : Object(static_cast<WindowObject&>(global_object).ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype")) +WebAssemblyMemoryObject::WebAssemblyMemoryObject(JS::Realm& realm, Wasm::MemoryAddress address) + : Object(static_cast<WindowObject&>(realm.global_object()).ensure_web_prototype<WebAssemblyMemoryPrototype>("WebAssemblyMemoryPrototype")) , m_address(address) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h index 481138dd22..6ada19ec3a 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h @@ -23,7 +23,7 @@ class WebAssemblyObject final : public JS::Object { JS_OBJECT(WebAssemblyObject, JS::Object); public: - explicit WebAssemblyObject(JS::GlobalObject&); + explicit WebAssemblyObject(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~WebAssemblyObject() override = default; @@ -69,7 +69,7 @@ class WebAssemblyMemoryObject final : public JS::Object { JS_OBJECT(WebAssemblyMemoryObject, JS::Object); public: - explicit WebAssemblyMemoryObject(JS::GlobalObject&, Wasm::MemoryAddress); + WebAssemblyMemoryObject(JS::Realm&, Wasm::MemoryAddress); virtual ~WebAssemblyMemoryObject() override = default; auto address() const { return m_address; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp index efc366d4fb..1ca586a1ce 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp @@ -14,8 +14,8 @@ namespace Web::Bindings { -WebAssemblyTableConstructor::WebAssemblyTableConstructor(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +WebAssemblyTableConstructor::WebAssemblyTableConstructor(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } @@ -30,6 +30,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyTableConstructor::construct(Functi { auto& vm = this->vm(); auto& global_object = this->global_object(); + auto& realm = *global_object.associated_realm(); auto descriptor = TRY(vm.argument(0).to_object(global_object)); auto element_value = TRY(descriptor->get("element")); @@ -77,7 +78,7 @@ JS::ThrowCompletionOr<JS::Object*> WebAssemblyTableConstructor::construct(Functi for (auto& element : table.elements()) element = reference; - return vm.heap().allocate<WebAssemblyTableObject>(global_object, global_object, *address); + return vm.heap().allocate<WebAssemblyTableObject>(global_object, realm, *address); } void WebAssemblyTableConstructor::initialize(JS::GlobalObject& global_object) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h index c6aad1424a..babf1f5aed 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h @@ -14,7 +14,7 @@ class WebAssemblyTableConstructor : public JS::NativeFunction { JS_OBJECT(WebAssemblyTableConstructor, JS::NativeFunction); public: - explicit WebAssemblyTableConstructor(JS::GlobalObject&); + explicit WebAssemblyTableConstructor(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~WebAssemblyTableConstructor() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.cpp index f01f9e9cd9..e8fe1a3e28 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.cpp @@ -9,8 +9,8 @@ namespace Web::Bindings { -WebAssemblyTableObject::WebAssemblyTableObject(JS::GlobalObject& global_object, Wasm::TableAddress address) - : Object(static_cast<WindowObject&>(global_object).ensure_web_prototype<WebAssemblyTablePrototype>("WebAssemblyTablePrototype")) +WebAssemblyTableObject::WebAssemblyTableObject(JS::Realm& realm, Wasm::TableAddress address) + : Object(static_cast<WindowObject&>(realm.global_object()).ensure_web_prototype<WebAssemblyTablePrototype>("WebAssemblyTablePrototype")) , m_address(address) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.h index bb2bbd2cd9..98472e72f5 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.h @@ -18,7 +18,7 @@ class WebAssemblyTableObject final : public JS::Object { JS_OBJECT(WebAssemblyTableObject, Object); public: - explicit WebAssemblyTableObject(JS::GlobalObject&, Wasm::TableAddress); + WebAssemblyTableObject(JS::Realm&, Wasm::TableAddress); virtual ~WebAssemblyTableObject() override = default; Wasm::TableAddress address() const { return m_address; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h index 18c66c7869..14067840bb 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h @@ -19,8 +19,8 @@ class WebAssemblyTablePrototype final : public JS::Object { JS_OBJECT(WebAssemblyTablePrototype, JS::Object); public: - explicit WebAssemblyTablePrototype(JS::GlobalObject& global_object) - : JS::Object(*global_object.object_prototype()) + explicit WebAssemblyTablePrototype(JS::Realm& realm) + : JS::Object(*realm.global_object().object_prototype()) { } |