diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index 667683a75e8..59a9843dcc6 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -1837,7 +1837,7 @@ class @wrapper_class@ : public @wrapper_base_class@ { public: static @wrapper_class@* create(JS::GlobalObject&, @fully_qualified_name@&); - @wrapper_class@(JS::GlobalObject&, @fully_qualified_name@&); + @wrapper_class@(JS::Realm&, @fully_qualified_name@&); virtual void initialize(JS::GlobalObject&) override; virtual ~@wrapper_class@() override; )~~~"); @@ -2004,25 +2004,26 @@ namespace Web::Bindings { @wrapper_class@* @wrapper_class@::create(JS::GlobalObject& global_object, @fully_qualified_name@& impl) { - return global_object.heap().allocate<@wrapper_class@>(global_object, global_object, impl); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate<@wrapper_class@>(global_object, realm, impl); } )~~~"); if (interface.wrapper_base_class == "Wrapper") { generator.append(R"~~~( -@wrapper_class@::@wrapper_class@(JS::GlobalObject& global_object, @fully_qualified_name@& impl) - : Wrapper(static_cast(global_object).ensure_web_prototype<@prototype_class@>("@name@")) +@wrapper_class@::@wrapper_class@(JS::Realm& realm, @fully_qualified_name@& impl) + : Wrapper(static_cast(realm.global_object()).ensure_web_prototype<@prototype_class@>("@name@")) , m_impl(impl) { } )~~~"); } else { generator.append(R"~~~( -@wrapper_class@::@wrapper_class@(JS::GlobalObject& global_object, @fully_qualified_name@& impl) - : @wrapper_base_class@(global_object, impl) +@wrapper_class@::@wrapper_class@(JS::Realm& realm, @fully_qualified_name@& impl) + : @wrapper_base_class@(realm, impl) { - set_prototype(&static_cast(global_object).ensure_web_prototype<@prototype_class@>("@name@")); + set_prototype(&static_cast(realm.global_object()).ensure_web_prototype<@prototype_class@>("@name@")); } )~~~"); } @@ -2798,7 +2799,7 @@ namespace Web::Bindings { class @constructor_class@ : public JS::NativeFunction { JS_OBJECT(@constructor_class@, JS::NativeFunction); public: - explicit @constructor_class@(JS::GlobalObject&); + explicit @constructor_class@(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~@constructor_class@() override; @@ -2927,8 +2928,8 @@ using namespace Web::WebGL; namespace Web::Bindings { -@constructor_class@::@constructor_class@(JS::GlobalObject& global_object) - : NativeFunction(*global_object.function_prototype()) +@constructor_class@::@constructor_class@(JS::Realm& realm) + : NativeFunction(*realm.global_object().function_prototype()) { } @@ -3065,7 +3066,7 @@ namespace Web::Bindings { class @prototype_class@ : public JS::Object { JS_OBJECT(@prototype_class@, JS::Object); public: - explicit @prototype_class@(JS::GlobalObject&); + explicit @prototype_class@(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~@prototype_class@() override; private: @@ -3210,20 +3211,20 @@ using namespace Web::WebGL; namespace Web::Bindings { -@prototype_class@::@prototype_class@([[maybe_unused]] JS::GlobalObject& global_object))~~~"); +@prototype_class@::@prototype_class@([[maybe_unused]] JS::Realm& realm))~~~"); if (interface.name == "DOMException") { // https://webidl.spec.whatwg.org/#es-DOMException-specialness // Object.getPrototypeOf(DOMException.prototype) === Error.prototype generator.append(R"~~~( - : Object(*global_object.error_prototype()) + : Object(*realm.global_object().error_prototype()) )~~~"); } else if (!interface.parent_name.is_empty()) { generator.append(R"~~~( - : Object(static_cast(global_object).ensure_web_prototype<@prototype_base_class@>("@parent_name@")) + : Object(static_cast(realm.global_object()).ensure_web_prototype<@prototype_base_class@>("@parent_name@")) )~~~"); } else { generator.append(R"~~~( - : Object(*global_object.object_prototype()) + : Object(*realm.global_object().object_prototype()) )~~~"); } @@ -3587,7 +3588,7 @@ class @wrapper_class@ : public Wrapper { public: static @wrapper_class@* create(JS::GlobalObject&, @fully_qualified_name@&); - @wrapper_class@(JS::GlobalObject&, @fully_qualified_name@&); + @wrapper_class@(JS::Realm&, @fully_qualified_name@&); virtual void initialize(JS::GlobalObject&) override; virtual ~@wrapper_class@() override; @@ -3659,11 +3660,12 @@ namespace Web::Bindings { @wrapper_class@* @wrapper_class@::create(JS::GlobalObject& global_object, @fully_qualified_name@& impl) { - return global_object.heap().allocate<@wrapper_class@>(global_object, global_object, impl); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate<@wrapper_class@>(global_object, realm, impl); } -@wrapper_class@::@wrapper_class@(JS::GlobalObject& global_object, @fully_qualified_name@& impl) - : Wrapper(static_cast(global_object).ensure_web_prototype<@prototype_class@>("@name@")) +@wrapper_class@::@wrapper_class@(JS::Realm& realm, @fully_qualified_name@& impl) + : Wrapper(static_cast(realm.global_object()).ensure_web_prototype<@prototype_class@>("@name@")) , m_impl(impl) { } @@ -3712,7 +3714,7 @@ namespace Web::Bindings { class @prototype_class@ : public JS::Object { JS_OBJECT(@prototype_class@, JS::Object); public: - explicit @prototype_class@(JS::GlobalObject&); + explicit @prototype_class@(JS::Realm&); virtual void initialize(JS::GlobalObject&) override; virtual ~@prototype_class@() override; @@ -3776,8 +3778,8 @@ using namespace Web::WebGL; namespace Web::Bindings { -@prototype_class@::@prototype_class@(JS::GlobalObject& global_object) - : Object(*global_object.iterator_prototype()) +@prototype_class@::@prototype_class@(JS::Realm& realm) + : Object(*realm.global_object().iterator_prototype()) { } diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index dcd67770e57..95b924ec32e 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 f879c998801..78433d0f5bf 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 b418c49cbe8..aae822b2e80 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -29,7 +29,7 @@ Workbook::Workbook(NonnullRefPtrVector&& sheets, GUI::Window& parent_wind , m_main_execution_context(m_vm->heap()) , m_parent_window(parent_window) { - m_workbook_object = m_vm->heap().allocate(m_interpreter->global_object(), *this, m_interpreter->global_object()); + m_workbook_object = m_vm->heap().allocate(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 23b2e206a35..ef3fdc30e0d 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(global_object, global_object); - m_is_htmldda = vm().heap().allocate(global_object, global_object); + auto& realm = *global_object.associated_realm(); + m_agent = vm().heap().allocate(global_object, realm); + m_is_htmldda = vm().heap().allocate(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 08caddd6bb6..79445dee1ce 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 c801485b5bd..fbc8ef4b148 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 2a961305d81..eeed225a89c 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 1a7bf5e2126..fe6d29f7d44 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 8c60c99b2b2..68b6a37398f 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 a08d09a2b85..f34322e4eaa 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 call() override; diff --git a/Userland/Libraries/LibJS/Module.cpp b/Userland/Libraries/LibJS/Module.cpp index 92d5db9b21a..ef3d315a056 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 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(realm().global_object(), realm().global_object(), this, move(unambiguous_names)); + Object* module_namespace = vm.heap().allocate(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 3c13c0f3f03..a26fe25f39f 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 const& formals, Span 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(global_object, global_object, environment); + auto* object = vm.heap().allocate(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 73c364744ce..8562f99df75 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(global_object.error_constructor())) +AggregateErrorConstructor::AggregateErrorConstructor(Realm& realm) + : NativeFunction(static_cast(*realm.global_object().error_constructor())) { } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h index 94d272a6538..42ddad01212 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 ae37c8bea87..33e09e4c812 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 2820175dfcd..a2f4d56b9be 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 f9b6d0eb904..ddbbdaa778a 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 b8a9c3b2e24..895592325ed 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 2b9c6e2f55f..a4e1ead4a25 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 10d7b41de25..38030304127 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 463d944c48e..bdd0425965d 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 2baae73737b..d2515d6c7e2 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h @@ -15,7 +15,7 @@ class ArrayBufferPrototype final : public PrototypeObject 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 dac104540ff..d6318610695 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 05446dcc743..2e8793350be 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(global_object, global_object, sync_iterator_record); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate(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 69c6cdb4488..66e361c9d2d 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 09832934a28..fff5f98f805 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 fa4fada97b9..f91fcaf5b76 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h @@ -19,7 +19,7 @@ class AsyncFromSyncIteratorPrototype final : public PrototypeObject AsyncFunctionDriverWrapper::create(GlobalObject& global_object, GeneratorObject* generator_object) { - auto wrapper = global_object.heap().allocate(global_object, global_object, generator_object); + auto& realm = *global_object.associated_realm(); + auto wrapper = global_object.heap().allocate(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 5ef0d49ba82..27e533858f6 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 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 ad3a7ba896a..09cb59e1a03 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 ac8d91654ef..b0a3df47019 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 6ba69c2f360..0341bd33130 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 4395ced16e8..6434aaf9f56 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 a2afd60eca0..14096ab6f09 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 23179d585bd..78ee0e29826 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h @@ -14,7 +14,7 @@ class AsyncGeneratorFunctionPrototype final : public PrototypeObject 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 00e89c5c83e..8fb1df29e34 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 98eae0460e4..7a07eda17db 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 31d1844368e..fc81ada21e8 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 f4c2b92c62c..5c0ffd86891 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 94990c2e52d..62f171da562 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 b8f08479665..90a56f184cf 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 8eaf5575406..8c6e22e88b0 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 4d36bcbba9d..bdf4daaa10c 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 b3e55e74665..48f5672286b 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 d4862d17832..a9fa1822170 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::create(GlobalObject& global_object, FunctionObject& target_function, Value bound_this, Vector 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::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(global_object, global_object, target_function, bound_this, move(bound_arguments), prototype); + auto* object = global_object.heap().allocate(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 bound_arguments, Object* prototype) - : FunctionObject(global_object, prototype) +BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function, Value bound_this, Vector 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 9993ffcc4a2..b7dabe66f57 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 create(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector bound_arguments); - BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector bound_arguments, Object* prototype); + BoundFunction(Realm&, FunctionObject& target_function, Value bound_this, Vector bound_arguments, Object* prototype); virtual ~BoundFunction() override = default; virtual ThrowCompletionOr internal_call(Value this_argument, MarkedVector arguments_list) override; diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp index 99dc11f333a..8d82aa5492d 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 76a0e4c8ba0..2749cc8ae1e 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 20e59c5528e..975c5716263 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 16c50976949..d00c222a3fe 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 739144f0ecc..a7c198f726f 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 1b754b4396b..41a9bec2f33 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h @@ -15,7 +15,7 @@ class DataViewPrototype final : public PrototypeObject { 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 900c8c4a2d1..7b9ceb3e3df 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 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(global_object.error_constructor())) \ + ConstructorName::ConstructorName(Realm& realm) \ + : NativeFunction(vm().names.ClassName.as_string(), *static_cast(realm.global_object().error_constructor())) \ { \ } \ \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h index 4226c6107f3..534cf62e594 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 call() override; \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 1167e37de1c..4c5a51d12df 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 5a7ce94e01b..c3e3566531d 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h @@ -16,7 +16,7 @@ class ErrorPrototype final : public PrototypeObject { 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 b438282cf92..dfd681e48ed 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 c09a01e1c61..9516e4f102d 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 03f59b1538e..d9aa36ed08e 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 d7e81ab2f0d..a530fb482fb 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h @@ -15,7 +15,7 @@ class FinalizationRegistryPrototype final : public PrototypeObject create_dynamic_function(GlobalObject& global_object, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector 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 c7f2d2999b0..af428297df9 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 38b1b6fe9f1..38b7689fa8b 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 771a4e3f8d1..ab45ad95dfc 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 ffaa42a0edb..e7aef3b3890 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 950a413778f..6fae3b8ad2b 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(global_object.function_constructor())) +GeneratorFunctionConstructor::GeneratorFunctionConstructor(Realm& realm) + : NativeFunction(static_cast(*realm.global_object().function_constructor())) { } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h index 41005469b1d..90ce4bccb9f 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 aff916cd6f7..00d0e5ca93c 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 ed528874b66..65d2798975d 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 843becbb122..b274677292c 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -15,6 +15,8 @@ namespace JS { ThrowCompletionOr 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::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(global_object, global_object, *generating_function_prototype_object, move(execution_context)); + auto object = global_object.heap().allocate(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 9b164d5319b..eff4e881ae2 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 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 e28438200db..81c4de3472b 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 b87c8cb3e61..0cc7a4ca855 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h @@ -16,7 +16,7 @@ class GeneratorPrototype final : public PrototypeObject(realm); - m_object_prototype = heap().allocate_without_global_object(*this); - m_function_prototype = heap().allocate_without_global_object(*this); + m_object_prototype = heap().allocate_without_global_object(realm); + m_function_prototype = heap().allocate_without_global_object(realm); m_new_object_shape = vm.heap().allocate_without_global_object(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(*this, *this); + m_error_prototype = heap().allocate(*this, realm); #define __JS_ENUMERATE(ClassName, snake_name) \ if (!m_##snake_name##_prototype) \ - m_##snake_name##_prototype = heap().allocate(*this, *this); + m_##snake_name##_prototype = heap().allocate(*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(*this, *this); - m_async_generator_prototype = heap().allocate(*this, *this); - m_generator_prototype = heap().allocate(*this, *this); - m_intl_segments_prototype = heap().allocate(*this, *this); + m_async_from_sync_iterator_prototype = heap().allocate(*this, realm); + m_async_generator_prototype = heap().allocate(*this, realm); + m_generator_prototype = heap().allocate(*this, realm); + m_intl_segments_prototype = heap().allocate(*this, realm); #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ if (!m_##snake_name##_prototype) \ - m_##snake_name##_prototype = heap().allocate(*this, *this); + m_##snake_name##_prototype = heap().allocate(*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(*this, *this); + m_intl_##snake_name##_prototype = heap().allocate(*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(*this, *this); + m_temporal_##snake_name##_prototype = heap().allocate(*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(*this, *this), attr); - define_direct_property(vm.names.Atomics, heap().allocate(*this, *this), attr); - define_direct_property(vm.names.Math, heap().allocate(*this, *this), attr); - define_direct_property(vm.names.JSON, heap().allocate(*this, *this), attr); - define_direct_property(vm.names.Reflect, heap().allocate(*this, *this), attr); - define_direct_property(vm.names.Intl, heap().allocate(*this, *this), attr); - define_direct_property(vm.names.Temporal, heap().allocate(*this, *this), attr); + define_direct_property(vm.names.console, heap().allocate(*this, realm), attr); + define_direct_property(vm.names.Atomics, heap().allocate(*this, realm), attr); + define_direct_property(vm.names.Math, heap().allocate(*this, realm), attr); + define_direct_property(vm.names.JSON, heap().allocate(*this, realm), attr); + define_direct_property(vm.names.Reflect, heap().allocate(*this, realm), attr); + define_direct_property(vm.names.Intl, heap().allocate(*this, realm), attr); + define_direct_property(vm.names.Temporal, heap().allocate(*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 e07c608985c..75bb908fa73 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -177,7 +177,8 @@ template inline void GlobalObject::initialize_constructor(PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype, PropertyAttributes attributes) { auto& vm = this->vm(); - constructor = heap().allocate(*this, *this); + auto& realm = *associated_realm(); + constructor = heap().allocate(*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 5abbab99dbc..2248aab8cb7 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(global_object, global_object, collator); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate(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 a1540bc92b0..c45cb5233ac 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 76440d657f0..eafa195259b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -132,8 +132,8 @@ static ThrowCompletionOr 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 448b41df8b0..2c925ded008 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 1e35df850af..25f5b814212 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 4a9db4bc55b..2cb3169107f 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 { 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 bc7fef857f4..bcf7e15ce9c 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 9a4a82ad7fb..f329ed301bf 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 298fa5ad7c5..6c403c36b9e 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 0f73bd19a6c..f265378dd23 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(global_object, global_object, segmenter, move(string), segments); + return global_object.heap().allocate(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 6ee75de6918..1a4aee5d14d 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 80bb0942839..a97d549679d 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 333ffc814e8..dc5e287de96 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(global_object, global_object, segmenter, move(string)); + return global_object.heap().allocate(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 1e5a11a610a..5696d3089af 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 c238c9a9246..0964b30e345 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 f8f749a2488..2fe06c10e59 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 { 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 291472e0fd2..8e7852062d9 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 5738f5f9808..4e59aaeb42f 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 8aaff376a24..7a3126c1be3 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 exports) - : Object(*global_object.object_prototype()) +ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vector 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 8c8e03d6465..0e2254358d7 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 exports); + ModuleNamespaceObject(Realm&, Module* module, Vector 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 c18831df733..342330a1635 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(global_object, global_object, move(behaviour), prototype.value(), *realm.value()); + auto* function = global_object.heap().allocate(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(VM&, GlobalObject&)> function) { - return global_object.heap().allocate(global_object, name, move(function), *global_object.function_prototype()); + auto& realm = *global_object.associated_realm(); + return global_object.heap().allocate(global_object, name, move(function), *realm.global_object().function_prototype()); } -NativeFunction::NativeFunction(GlobalObject& global_object, Function(VM&, GlobalObject&)> native_function, Object* prototype, Realm& realm) - : FunctionObject(global_object, prototype) +NativeFunction::NativeFunction(Function(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 cc76a46e2b6..bbeb25241f4 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(VM&, GlobalObject&)> behaviour, i32 length, PropertyKey const& name, Optional = {}, Optional prototype = {}, Optional const& prefix = {}); static NativeFunction* create(GlobalObject&, FlyString const& name, Function(VM&, GlobalObject&)>); - NativeFunction(GlobalObject&, Function(VM&, GlobalObject&)>, Object* prototype, Realm& realm); + NativeFunction(Function(VM&, GlobalObject&)>, Object* prototype, Realm& realm); NativeFunction(FlyString name, Function(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 d1392def42e..ee96dff10d5 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 dc64380aeaf..cc3ecf24e0f 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 a033c591204..900d7b171ee 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 b7e520de2f3..5630cf1bde3 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 cb5b26e6fa8..824ac5e79dc 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(realm); } -Object::Object(ConstructWithoutPrototypeTag, GlobalObject& global_object) +Object::Object(ConstructWithoutPrototypeTag, Realm& realm) { - VERIFY(global_object.associated_realm()); - m_shape = heap().allocate_without_global_object(*global_object.associated_realm()); + m_shape = heap().allocate_without_global_object(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 d3ed79b51af..ddeccc45e6c 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 92f59c6db18..199d8eeeafd 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 0e267839823..843fcd5bf1e 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 a88031be7da..1f42b368125 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 72d43e38534..700e5201661 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 08d66bb54fb..f76ec0990ec 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -244,8 +244,8 @@ static ThrowCompletionOr 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 76b0c276925..d174328358b 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 739715e8320..91b202ef36a 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 102c3443cdd..56cf3402248 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.h @@ -14,7 +14,7 @@ class PromisePrototype final : public PrototypeObject 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 89c8bd7c1ea..6cd280832e3 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -24,8 +24,8 @@ static ThrowCompletionOr 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 0f183619b74..f6ef26148e1 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 6646d73e245..a5458f51290 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 279be992b74..e705d6d4f26 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 f5b95c78e90..4f07f861552 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 ebce6f3e734..28ee58790ce 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 534bcea5cfb..3e483ea59cd 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 027bf8a8ee9..defa9981e93 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h @@ -19,7 +19,7 @@ class RegExpPrototype final : public PrototypeObject { 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 8af021d8920..ad1da3af2ab 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 bdbd160bfe6..24dde2aeb6d 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 b20113f4214..b261d344ec6 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 74786eb20b3..c97dba0fe63 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h @@ -15,7 +15,7 @@ class ShadowRealmPrototype final : public PrototypeObject 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 2493e47002b..9b32f73e672 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 66119673edd..0633cabdfa1 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 7919f8886c7..88f5ea153b4 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 ad5dbc572f9..2ca00f223fd 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 57c20cabafd..e8644d0f74d 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 ab0fec50693..a940d86a855 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 8b31240a36d..af3227a8807 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 a2242afc367..29f67ccc346 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 4c32e4a7d68..8b5092b40f8 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 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 d680cbc141e..bd1b5442579 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 c17563432e8..5297e0d486a 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 1f5ca651490..777f87f2837 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 29bf550f604..77fc5ac234e 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 0e529079045..b0bcc0129bf 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 c38e62614ab..04305b561fd 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 PrototypeObjectvm(); + 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(global_object, global_object), attr); + define_direct_property(vm.names.Now, heap().allocate(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 f2f34f2d32c..2fde1bcd580 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 e66cff3d2ee..d5ce0dc26fe 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 b5b51265aeb..282f21e9243 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 45b61027fd1..11849ae640e 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 a84caad5881..48be78acacb 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 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 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 96937dac367..dcb64765b79 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 6d530996850..6d668e63300 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 65e4eaead36..5229cedb71e 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 01a7222a39c..39b1ffa02dc 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 88f3aa6dc94..a2e22b4db0a 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 58062110cdb..19eb0cd3452 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 c84239e2f20..cd5ee699eda 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 78ab6f1ad1e..af305ca9f28 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h @@ -15,7 +15,7 @@ class WeakMapPrototype final : public PrototypeObject 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 6dd6241cf27..7fe27eacd3a 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 b850735b4ff..24cbbd3d67e 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 dee76df1677..258f33ecc37 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 8769e8a19dc..eca9dff7849 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h @@ -15,7 +15,7 @@ class WeakRefPrototype final : public PrototypeObject 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 c83c1725ba9..9297c17d6c8 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 d9d798d5864..5b80fe368a7 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 cd6a36655e5..d76131eb480 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 ea9e34643fe..93d7c16663c 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h @@ -15,7 +15,7 @@ class WeakSetPrototype final : public PrototypeObject 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 d735f176601..b881df327d2 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 ee9d825b3d8..912bef0885d 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 d9d7fe62d9f..a46ec1998f8 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 1ab81ef7767..05d4979a4ac 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 87913acdb16..c161fea5857 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 a90a539b74e..8c1dbcd216a 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 6f839b1accd..ee7aeaaaf67 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 a7ecfd75be6..3a4a603497d 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 5517e15b3f8..a6be55e5da7 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 4d357748519..dd05c3551ec 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 6bff5f40c3b..d51a4e4bea5 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(global_object).ensure_web_prototype("Location")) +LocationObject::LocationObject(JS::Realm& realm) + : Object(static_cast(realm.global_object()).ensure_web_prototype("Location")) , m_default_properties(heap()) { } diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.h b/Userland/Libraries/LibWeb/Bindings/LocationObject.h index ba2611be916..34c0684d840 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 c4303742acb..cc597d0ac42 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 a248df808f7..2deb4efef2e 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 b98347db744..12054f5ebff 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 479467f955c..a7f844b80f7 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(global_object).ensure_web_prototype("Navigator")) +NavigatorObject::NavigatorObject(JS::Realm& realm) + : Object(static_cast(realm.global_object()).ensure_web_prototype("Navigator")) { } diff --git a/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h b/Userland/Libraries/LibWeb/Bindings/NavigatorObject.h index 89054a1e409..026f65aab4c 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 b213b77ef3f..c94aa13e607 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 e63daebfc32..d8582e88308 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 c986d076d0f..d485f2859e2 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 87ad5904f14..be0d7c5cdba 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 3a2493e4c38..5b25ee6c926 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 9432b73748a..b4ff04a58ee 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("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(*this, *this), 0); + define_direct_property("CSS", heap().allocate(*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(*this, *this); + m_location_object = heap().allocate(*this, realm); - auto* m_navigator_object = heap().allocate(*this, *this); + auto* m_navigator_object = heap().allocate(*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(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable); + define_direct_property("WebAssembly", heap().allocate(*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 524621e0699..5d7f3be406e 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(*this, *this); + auto& realm = *associated_realm(); + auto* prototype = heap().allocate(*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(*this, *this); + auto& realm = *associated_realm(); + auto* constructor = heap().allocate(*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 ec57ae2e948..9d99573be7b 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(global_object).ensure_web_prototype("EventTarget")) + explicit WindowPrototype(JS::Realm& realm) + : JS::Object(static_cast(realm.global_object()).ensure_web_prototype("EventTarget")) { } }; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp b/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp index 82f2f80d60f..822b63bff3d 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 f557d12c9f7..42f8c560aca 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 internal_get_prototype_of() const override; diff --git a/Userland/Libraries/LibWeb/Bindings/Wrappable.h b/Userland/Libraries/LibWeb/Bindings/Wrappable.h index 26d2fbcc1d4..79c6b75c6b0 100644 --- a/Userland/Libraries/LibWeb/Bindings/Wrappable.h +++ b/Userland/Libraries/LibWeb/Bindings/Wrappable.h @@ -28,8 +28,9 @@ private: template 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(global_object, global_object, native_object)); + native_object.set_wrapper(*global_object.heap().allocate(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 6c2517b3632..b7441a457cc 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 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(module_argument)) return vm.throw_completion(global_object, JS::ErrorType::NotAnObjectOfType, "WebAssembly.Module"); auto& module_object = static_cast(*module_argument); auto result = TRY(WebAssemblyObject::instantiate_module(module_object.module(), vm, global_object)); - return heap().allocate(global_object, global_object, result); + return heap().allocate(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 90bdcb92a7b..f217182b638 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 95c586ce6b1..afae00d11a3 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(global_object).ensure_web_prototype("WebAssemblyInstancePrototype")) +WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::Realm& realm, size_t index) + : Object(static_cast(realm.global_object()).ensure_web_prototype("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 object = cache.memory_instances.get(address); if (!object.has_value()) { - object = heap().allocate(global_object, global_object, address); + object = heap().allocate(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 4d342603fad..de8cd1381ef 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 2fb24d861d6..06f51667bae 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 76330a251b2..d37649efef9 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 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 WebAssemblyMemoryConstructor::construct(Funct if (!WebAssemblyObject::s_abstract_machine.store().get(*address)->grow(initial)) return vm.throw_completion(global_object, String::formatted("Wasm Memory grow failed: {}", initial)); - return vm.heap().allocate(global_object, global_object, *address); + return vm.heap().allocate(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 9391ec7b038..f435b0905ef 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 4de2a283718..390761f23fd 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 1df0df1c6f3..072f0ab8cd7 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 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(global_object, global_object, result); + return heap().allocate(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 a77815343da..ac1dfdf8a46 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 27e5340197c..de74c2d31a4 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(global_object).ensure_web_prototype("WebAssemblyModulePrototype")) +WebAssemblyModuleObject::WebAssemblyModuleObject(JS::Realm& realm, size_t index) + : Object(static_cast(realm.global_object()).ensure_web_prototype("WebAssemblyModulePrototype")) , m_index(index) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleObject.h index 38911c36bf4..77ed8571841 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 eaf3c841781..b2177e2e982 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 10e57ca3c35..898882e2ee0 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 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(global_object, global_object, result.release_value())); + promise->fulfill(vm.heap().allocate(global_object, realm, result.release_value())); return promise; } @@ -317,6 +319,8 @@ JS::ThrowCompletionOr 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(global_object, global_object, result.release_value()); + auto instance_object = vm.heap().allocate(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(global_object, global_object, s_compiled_modules.size() - 1), JS::default_attributes); + object->define_direct_property("module", vm.heap().allocate(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(global_object).ensure_web_prototype("WebAssemblyMemoryPrototype")) +WebAssemblyMemoryObject::WebAssemblyMemoryObject(JS::Realm& realm, Wasm::MemoryAddress address) + : Object(static_cast(realm.global_object()).ensure_web_prototype("WebAssemblyMemoryPrototype")) , m_address(address) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h index 481138dd22b..6ada19ec3a0 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 efc366d4fb4..1ca586a1cea 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 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 WebAssemblyTableConstructor::construct(Functi for (auto& element : table.elements()) element = reference; - return vm.heap().allocate(global_object, global_object, *address); + return vm.heap().allocate(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 c6aad1424a8..babf1f5aedd 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 f01f9e9cd94..e8fe1a3e289 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(global_object).ensure_web_prototype("WebAssemblyTablePrototype")) +WebAssemblyTableObject::WebAssemblyTableObject(JS::Realm& realm, Wasm::TableAddress address) + : Object(static_cast(realm.global_object()).ensure_web_prototype("WebAssemblyTablePrototype")) , m_address(address) { } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableObject.h index bb2bbd2cd96..98472e72f5d 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 18c66c78696..14067840bb8 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()) { }