diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp index 9edf6f8281a..9df7a9c53e0 100644 --- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp +++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp @@ -122,7 +122,7 @@ public: TestRunnerGlobalObject(JS::Realm&); virtual ~TestRunnerGlobalObject() override; - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; private: JS_DECLARE_NATIVE_FUNCTION(fuzzilli); @@ -168,9 +168,9 @@ JS_DEFINE_NATIVE_FUNCTION(TestRunnerGlobalObject::fuzzilli) return JS::js_undefined(); } -void TestRunnerGlobalObject::initialize_global_object() +void TestRunnerGlobalObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); define_direct_property("global", this, JS::Attribute::Enumerable); define_native_function("fuzzilli", fuzzilli, 2, JS::default_attributes); } diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index 601ae8fcef5..10b5d3d4200 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -144,9 +144,9 @@ JS::ThrowCompletionOr SheetGlobalObject::internal_set(const JS::PropertyKe return Base::internal_set(property_name, value, receiver); } -void SheetGlobalObject::initialize_global_object() +void SheetGlobalObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_function("get_real_cell_contents", get_real_cell_contents, 1, attr); define_native_function("set_real_cell_contents", set_real_cell_contents, 2, attr); diff --git a/Userland/Applications/Spreadsheet/JSIntegration.h b/Userland/Applications/Spreadsheet/JSIntegration.h index ecd1d32d5e2..bf6f007e5e4 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.h +++ b/Userland/Applications/Spreadsheet/JSIntegration.h @@ -30,7 +30,7 @@ public: virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyKey const& name) const override; virtual JS::ThrowCompletionOr internal_get(JS::PropertyKey const&, JS::Value receiver) const override; virtual JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; JS_DECLARE_NATIVE_FUNCTION(get_real_cell_contents); JS_DECLARE_NATIVE_FUNCTION(set_real_cell_contents); diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp index 54a31f7ae8f..74e7568ac7e 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp @@ -23,7 +23,7 @@ $262Object::$262Object(Realm& realm) { } -void $262Object::initialize(JS::Realm& realm) +void $262Object::initialize(Realm& realm) { Base::initialize(realm); @@ -63,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm) VERIFY(realm_global_object); realm->set_global_object(realm_global_object, nullptr); realm_global_object->set_associated_realm(*realm); - realm_global_object->initialize_global_object(); + realm_global_object->initialize_global_object(*realm); return Value(realm_global_object->$262()); } diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp index da196c73daa..4d2e7c08419 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp @@ -14,11 +14,10 @@ namespace JS::Test262 { -void GlobalObject::initialize_global_object() +void GlobalObject::initialize_global_object(Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); - auto& realm = *associated_realm(); m_$262 = vm().heap().allocate<$262Object>(realm, realm); // https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h index 359f5b50368..168467d0b6c 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh + * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -19,7 +19,7 @@ public: : JS::GlobalObject(realm) { } - virtual void initialize_global_object() override; + virtual void initialize_global_object(Realm&) override; virtual ~GlobalObject() override = default; $262Object* $262() const { return m_$262; } diff --git a/Userland/Libraries/LibJS/Interpreter.h b/Userland/Libraries/LibJS/Interpreter.h index 9d939ee8c0c..0a8c1647fde 100644 --- a/Userland/Libraries/LibJS/Interpreter.h +++ b/Userland/Libraries/LibJS/Interpreter.h @@ -44,11 +44,13 @@ public: VM::InterpreterExecutionScope scope(*interpreter); GlobalObject* global_object { nullptr }; + Realm* realm { nullptr }; interpreter->m_global_execution_context = MUST(Realm::initialize_host_defined_realm( vm, - [&](Realm& realm) -> GlobalObject* { - global_object = interpreter->heap().allocate_without_realm(realm, forward(args)...); + [&](Realm& realm_) -> GlobalObject* { + global_object = interpreter->heap().allocate_without_realm(realm_, forward(args)...); + realm = &realm_; return global_object; }, nullptr)); @@ -58,7 +60,7 @@ public: interpreter->m_global_execution_context->function_name = global_execution_context_name; interpreter->m_global_object = make_handle(global_object); - interpreter->m_realm = make_handle(global_object->associated_realm()); + interpreter->m_realm = make_handle(realm); return interpreter; } diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index d0ca61d56ea..ceb9718c934 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -145,15 +145,13 @@ GlobalObject::GlobalObject(Realm& realm) { } -void GlobalObject::initialize_global_object() +void GlobalObject::initialize_global_object(Realm& realm) { auto& vm = this->vm(); ensure_shape_is_unique(); // These are done first since other prototypes depend on their presence. - VERIFY(associated_realm()); - auto& realm = *associated_realm(); m_empty_object_shape = heap().allocate_without_realm(realm); m_object_prototype = heap().allocate_without_realm(realm); m_function_prototype = heap().allocate_without_realm(realm); @@ -200,7 +198,7 @@ void GlobalObject::initialize_global_object() // Must be allocated before `Intl::Intl` below. #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ - initialize_constructor(vm.names.ClassName, m_intl_##snake_name##_constructor, m_intl_##snake_name##_prototype); + initialize_constructor(realm, vm.names.ClassName, m_intl_##snake_name##_constructor, m_intl_##snake_name##_prototype); JS_ENUMERATE_INTL_OBJECTS #undef __JS_ENUMERATE @@ -212,7 +210,7 @@ void GlobalObject::initialize_global_object() // Must be allocated before `Temporal::Temporal` below. #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ - initialize_constructor(vm.names.ClassName, m_temporal_##snake_name##_constructor, m_temporal_##snake_name##_prototype); + initialize_constructor(realm, vm.names.ClassName, m_temporal_##snake_name##_constructor, m_temporal_##snake_name##_prototype); JS_ENUMERATE_TEMPORAL_OBJECTS #undef __JS_ENUMERATE @@ -259,44 +257,44 @@ void GlobalObject::initialize_global_object() define_direct_property(vm.names.Temporal, heap().allocate(realm, 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); + initialize_constructor(realm, vm.names.Error, m_error_constructor, m_error_prototype); - add_constructor(vm.names.AggregateError, m_aggregate_error_constructor, m_aggregate_error_prototype); - add_constructor(vm.names.Array, m_array_constructor, m_array_prototype); - add_constructor(vm.names.ArrayBuffer, m_array_buffer_constructor, m_array_buffer_prototype); - add_constructor(vm.names.BigInt, m_bigint_constructor, m_bigint_prototype); - add_constructor(vm.names.Boolean, m_boolean_constructor, m_boolean_prototype); - add_constructor(vm.names.DataView, m_data_view_constructor, m_data_view_prototype); - add_constructor(vm.names.Date, m_date_constructor, m_date_prototype); - add_constructor(vm.names.Error, m_error_constructor, m_error_prototype); - add_constructor(vm.names.FinalizationRegistry, m_finalization_registry_constructor, m_finalization_registry_prototype); - add_constructor(vm.names.Function, m_function_constructor, m_function_prototype); - add_constructor(vm.names.Map, m_map_constructor, m_map_prototype); - add_constructor(vm.names.Number, m_number_constructor, m_number_prototype); - add_constructor(vm.names.Object, m_object_constructor, m_object_prototype); - add_constructor(vm.names.Promise, m_promise_constructor, m_promise_prototype); - add_constructor(vm.names.Proxy, m_proxy_constructor, nullptr); - add_constructor(vm.names.RegExp, m_regexp_constructor, m_regexp_prototype); - add_constructor(vm.names.Set, m_set_constructor, m_set_prototype); - add_constructor(vm.names.ShadowRealm, m_shadow_realm_constructor, m_shadow_realm_prototype); - add_constructor(vm.names.String, m_string_constructor, m_string_prototype); - add_constructor(vm.names.Symbol, m_symbol_constructor, m_symbol_prototype); - add_constructor(vm.names.WeakMap, m_weak_map_constructor, m_weak_map_prototype); - add_constructor(vm.names.WeakRef, m_weak_ref_constructor, m_weak_ref_prototype); - add_constructor(vm.names.WeakSet, m_weak_set_constructor, m_weak_set_prototype); + add_constructor(realm, vm.names.AggregateError, m_aggregate_error_constructor, m_aggregate_error_prototype); + add_constructor(realm, vm.names.Array, m_array_constructor, m_array_prototype); + add_constructor(realm, vm.names.ArrayBuffer, m_array_buffer_constructor, m_array_buffer_prototype); + add_constructor(realm, vm.names.BigInt, m_bigint_constructor, m_bigint_prototype); + add_constructor(realm, vm.names.Boolean, m_boolean_constructor, m_boolean_prototype); + add_constructor(realm, vm.names.DataView, m_data_view_constructor, m_data_view_prototype); + add_constructor(realm, vm.names.Date, m_date_constructor, m_date_prototype); + add_constructor(realm, vm.names.Error, m_error_constructor, m_error_prototype); + add_constructor(realm, vm.names.FinalizationRegistry, m_finalization_registry_constructor, m_finalization_registry_prototype); + add_constructor(realm, vm.names.Function, m_function_constructor, m_function_prototype); + add_constructor(realm, vm.names.Map, m_map_constructor, m_map_prototype); + add_constructor(realm, vm.names.Number, m_number_constructor, m_number_prototype); + add_constructor(realm, vm.names.Object, m_object_constructor, m_object_prototype); + add_constructor(realm, vm.names.Promise, m_promise_constructor, m_promise_prototype); + add_constructor(realm, vm.names.Proxy, m_proxy_constructor, nullptr); + add_constructor(realm, vm.names.RegExp, m_regexp_constructor, m_regexp_prototype); + add_constructor(realm, vm.names.Set, m_set_constructor, m_set_prototype); + add_constructor(realm, vm.names.ShadowRealm, m_shadow_realm_constructor, m_shadow_realm_prototype); + add_constructor(realm, vm.names.String, m_string_constructor, m_string_prototype); + add_constructor(realm, vm.names.Symbol, m_symbol_constructor, m_symbol_prototype); + add_constructor(realm, vm.names.WeakMap, m_weak_map_constructor, m_weak_map_prototype); + add_constructor(realm, vm.names.WeakRef, m_weak_ref_constructor, m_weak_ref_prototype); + add_constructor(realm, vm.names.WeakSet, m_weak_set_constructor, m_weak_set_prototype); - initialize_constructor(vm.names.TypedArray, m_typed_array_constructor, m_typed_array_prototype); + initialize_constructor(realm, vm.names.TypedArray, m_typed_array_constructor, m_typed_array_prototype); #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - add_constructor(vm.names.ClassName, m_##snake_name##_constructor, m_##snake_name##_prototype); + add_constructor(realm, vm.names.ClassName, m_##snake_name##_constructor, m_##snake_name##_prototype); JS_ENUMERATE_NATIVE_ERRORS JS_ENUMERATE_TYPED_ARRAYS #undef __JS_ENUMERATE // NOTE: These constructors cannot be initialized with add_constructor as they have no global binding. - initialize_constructor(vm.names.GeneratorFunction, m_generator_function_constructor, m_generator_function_prototype, Attribute::Configurable); - initialize_constructor(vm.names.AsyncGeneratorFunction, m_async_generator_function_constructor, m_async_generator_function_prototype, Attribute::Configurable); - initialize_constructor(vm.names.AsyncFunction, m_async_function_constructor, m_async_function_prototype, Attribute::Configurable); + initialize_constructor(realm, vm.names.GeneratorFunction, m_generator_function_constructor, m_generator_function_prototype, Attribute::Configurable); + initialize_constructor(realm, vm.names.AsyncGeneratorFunction, m_async_generator_function_constructor, m_async_generator_function_prototype, Attribute::Configurable); + initialize_constructor(realm, vm.names.AsyncFunction, m_async_function_constructor, m_async_function_prototype, Attribute::Configurable); // 27.5.1.1 Generator.prototype.constructor, https://tc39.es/ecma262/#sec-generator.prototype.constructor m_generator_prototype->define_direct_property(vm.names.constructor, m_generator_function_prototype, Attribute::Configurable); diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h index f013ec8f7ca..ef9a2ae1c25 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -18,7 +18,7 @@ class GlobalObject : public Object { public: explicit GlobalObject(Realm&); - virtual void initialize_global_object(); + virtual void initialize_global_object(Realm&); virtual ~GlobalObject() override; @@ -103,9 +103,9 @@ protected: virtual void visit_edges(Visitor&) override; template - void initialize_constructor(PropertyKey const&, ConstructorType*&, Object* prototype, PropertyAttributes = Attribute::Writable | Attribute::Configurable); + void initialize_constructor(Realm&, PropertyKey const&, ConstructorType*&, Object* prototype, PropertyAttributes = Attribute::Writable | Attribute::Configurable); template - void add_constructor(PropertyKey const&, ConstructorType*&, Object* prototype); + void add_constructor(Realm&, PropertyKey const&, ConstructorType*&, Object* prototype); private: virtual bool is_global_object() const final { return true; } @@ -174,10 +174,9 @@ private: }; template -inline void GlobalObject::initialize_constructor(PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype, PropertyAttributes attributes) +inline void GlobalObject::initialize_constructor(Realm& realm, PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype, PropertyAttributes attributes) { auto& vm = this->vm(); - auto& realm = *associated_realm(); constructor = heap().allocate(realm, realm); constructor->define_direct_property(vm.names.name, js_string(heap(), property_key.as_string()), Attribute::Configurable); if (prototype) @@ -185,11 +184,11 @@ inline void GlobalObject::initialize_constructor(PropertyKey const& property_key } template -inline void GlobalObject::add_constructor(PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype) +inline void GlobalObject::add_constructor(Realm& realm, PropertyKey const& property_key, ConstructorType*& constructor, Object* prototype) { // Some constructors are pre-initialized separately. if (!constructor) - initialize_constructor(property_key, constructor, prototype); + initialize_constructor(realm, property_key, constructor, prototype); define_direct_property(property_key, constructor, Attribute::Writable | Attribute::Configurable); } diff --git a/Userland/Libraries/LibJS/Runtime/Realm.cpp b/Userland/Libraries/LibJS/Runtime/Realm.cpp index 32444af3651..ca9e09b4491 100644 --- a/Userland/Libraries/LibJS/Runtime/Realm.cpp +++ b/Userland/Libraries/LibJS/Runtime/Realm.cpp @@ -64,7 +64,7 @@ ThrowCompletionOr> Realm::initialize_host_define // 10. Let globalObj be ? SetDefaultGlobalBindings(realm). // 11. Create any host-defined global object properties on globalObj. - realm->global_object().initialize_global_object(); + realm->global_object().initialize_global_object(*realm); // 12. Return unused. return new_context; diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp index 9db52daed52..82e7f86259a 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp @@ -64,7 +64,7 @@ ThrowCompletionOr ShadowRealmConstructor::construct(FunctionObject& new // 10. Perform ? SetRealmGlobalObject(realmRec, undefined, undefined). auto* new_global_object = vm.heap().allocate_without_realm(*realm); realm->set_global_object(new_global_object, nullptr); - new_global_object->initialize_global_object(); + new_global_object->initialize_global_object(*realm); // TODO: I don't think we should have these exactly like this, that doesn't work well with how // we create global objects. Still, it should be possible to make a ShadowRealm with a diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h index 31d326dd577..f53c27203db 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h @@ -197,12 +197,12 @@ public: virtual ~TestRunnerGlobalObject() override = default; - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; }; -inline void TestRunnerGlobalObject::initialize_global_object() +inline void TestRunnerGlobalObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); define_direct_property("global", this, JS::Attribute::Enumerable); for (auto& entry : s_exposed_global_functions) { define_native_function( diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index cef091c1e4b..febc8e93a9e 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -57,14 +57,12 @@ WindowObject::WindowObject(JS::Realm& realm, HTML::Window& impl) impl.set_wrapper({}, *this); } -void WindowObject::initialize_global_object() +void WindowObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); 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); diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.h b/Userland/Libraries/LibWeb/Bindings/WindowObject.h index 5d7f187b465..d65673aa331 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.h @@ -33,7 +33,7 @@ class WindowObject public: explicit WindowObject(JS::Realm&, HTML::Window&); - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; virtual ~WindowObject() override = default; HTML::Window& impl() { return *m_impl; } diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp index d4adda9bd91..0b2479b2875 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp @@ -20,9 +20,9 @@ ConsoleGlobalObject::ConsoleGlobalObject(JS::Realm& realm, Web::Bindings::Window { } -void ConsoleGlobalObject::initialize_global_object() +void ConsoleGlobalObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); // $0 magic variable define_native_accessor("$0", inspected_node_getter, nullptr, 0); diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.h b/Userland/Services/WebContent/ConsoleGlobalObject.h index 9f024c1859f..884ca4b4c78 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.h +++ b/Userland/Services/WebContent/ConsoleGlobalObject.h @@ -35,7 +35,7 @@ public: virtual JS::ThrowCompletionOr internal_delete(JS::PropertyKey const& name) override; virtual JS::ThrowCompletionOr> internal_own_property_keys() const override; - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; private: virtual void visit_edges(Visitor&) override; diff --git a/Userland/Services/WebContent/WebContentConsoleClient.cpp b/Userland/Services/WebContent/WebContentConsoleClient.cpp index 6c4a2171a6a..9e3922e97a1 100644 --- a/Userland/Services/WebContent/WebContentConsoleClient.cpp +++ b/Userland/Services/WebContent/WebContentConsoleClient.cpp @@ -24,7 +24,8 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, WeakPtrheap()); auto& vm = m_interpreter->vm(); - auto& global_object = m_interpreter->global_object(); + auto& realm = m_interpreter->realm(); + auto& global_object = realm.global_object(); auto console_global_object = m_interpreter->heap().allocate_without_realm(m_interpreter->realm(), static_cast(global_object)); @@ -32,8 +33,8 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, WeakPtr(*m_interpreter->realm().host_defined()); vm.push_execution_context(eso.realm_execution_context()); - console_global_object->set_associated_realm(m_interpreter->realm()); - console_global_object->initialize_global_object(); + console_global_object->set_associated_realm(realm); + console_global_object->initialize_global_object(realm); vm.pop_execution_context(); m_console_global_object = JS::make_handle(console_global_object); diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 2639206c84d..4b19b8094d2 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -96,7 +96,7 @@ public: : GlobalObject(realm) { } - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; virtual ~ReplObject() override = default; private: @@ -117,7 +117,7 @@ public: : JS::GlobalObject(realm) { } - virtual void initialize_global_object() override; + virtual void initialize_global_object(JS::Realm&) override; virtual ~ScriptObject() override = default; private: @@ -1297,9 +1297,9 @@ static JS::ThrowCompletionOr load_json_impl(JS::VM& vm) return JS::JSONObject::parse_json_value(vm, json.value()); } -void ReplObject::initialize_global_object() +void ReplObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); define_direct_property("global", this, JS::Attribute::Enumerable); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_function("exit", exit_interpreter, 0, attr); @@ -1375,9 +1375,9 @@ JS_DEFINE_NATIVE_FUNCTION(ReplObject::print) return JS::js_undefined(); } -void ScriptObject::initialize_global_object() +void ScriptObject::initialize_global_object(JS::Realm& realm) { - Base::initialize_global_object(); + Base::initialize_global_object(realm); define_direct_property("global", this, JS::Attribute::Enumerable); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_function("loadINI", load_ini, 1, attr);