From 22089436edec780e03960ecaa74bfc4930126534 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 14 Dec 2022 17:40:33 +0000 Subject: [PATCH] LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr --- .../BindingsGenerator/IDLGenerators.cpp | 6 +- Tests/LibWasm/test-wasm.cpp | 4 +- Userland/Libraries/LibJS/Bytecode/Op.cpp | 2 +- .../LibJS/Contrib/Test262/$262Object.cpp | 2 +- Userland/Libraries/LibJS/Heap/Heap.h | 8 +- Userland/Libraries/LibJS/Module.cpp | 2 +- .../LibJS/Runtime/AbstractOperations.cpp | 4 +- .../LibJS/Runtime/AbstractOperations.h | 2 +- Userland/Libraries/LibJS/Runtime/Accessor.h | 2 +- .../LibJS/Runtime/AggregateError.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Array.cpp | 4 +- .../Libraries/LibJS/Runtime/ArrayBuffer.cpp | 6 +- .../Libraries/LibJS/Runtime/ArrayIterator.cpp | 2 +- .../LibJS/Runtime/AsyncFromSyncIterator.cpp | 2 +- Userland/Libraries/LibJS/Runtime/BigInt.cpp | 2 +- .../Libraries/LibJS/Runtime/BigIntObject.cpp | 2 +- .../Libraries/LibJS/Runtime/BooleanObject.cpp | 2 +- .../Libraries/LibJS/Runtime/BoundFunction.cpp | 4 +- Userland/Libraries/LibJS/Runtime/DataView.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Date.cpp | 2 +- .../Runtime/ECMAScriptFunctionObject.cpp | 4 +- Userland/Libraries/LibJS/Runtime/Error.cpp | 38 ++-- .../LibJS/Runtime/GeneratorObject.cpp | 2 +- .../Runtime/Intl/CollatorCompareFunction.cpp | 2 +- .../Runtime/Intl/DateTimeFormatFunction.cpp | 2 +- .../Libraries/LibJS/Runtime/Intl/Locale.cpp | 2 +- .../Runtime/Intl/NumberFormatFunction.cpp | 2 +- .../LibJS/Runtime/Intl/SegmentIterator.cpp | 2 +- .../Libraries/LibJS/Runtime/Intl/Segments.cpp | 2 +- .../Libraries/LibJS/Runtime/Intrinsics.cpp | 4 +- Userland/Libraries/LibJS/Runtime/Map.cpp | 2 +- .../Libraries/LibJS/Runtime/MapIterator.cpp | 2 +- .../LibJS/Runtime/NativeFunction.cpp | 6 +- .../Libraries/LibJS/Runtime/NumberObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Object.cpp | 6 +- .../LibJS/Runtime/PrimitiveString.cpp | 6 +- Userland/Libraries/LibJS/Runtime/Promise.cpp | 4 +- .../LibJS/Runtime/PromiseCapability.cpp | 2 +- .../LibJS/Runtime/PromiseConstructor.cpp | 4 +- .../LibJS/Runtime/PromiseReaction.cpp | 2 +- .../PromiseResolvingElementFunctions.cpp | 8 +- .../Runtime/PromiseResolvingFunction.cpp | 2 +- .../Libraries/LibJS/Runtime/ProxyObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Realm.cpp | 4 +- .../Libraries/LibJS/Runtime/RegExpObject.cpp | 4 +- .../LibJS/Runtime/RegExpStringIterator.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Set.cpp | 2 +- .../Libraries/LibJS/Runtime/SetIterator.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Shape.cpp | 14 +- .../LibJS/Runtime/StringIterator.cpp | 2 +- .../Libraries/LibJS/Runtime/StringObject.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Symbol.cpp | 2 +- .../Libraries/LibJS/Runtime/SymbolObject.cpp | 2 +- .../Libraries/LibJS/Runtime/TypedArray.cpp | 4 +- Userland/Libraries/LibJS/Runtime/WeakMap.cpp | 2 +- Userland/Libraries/LibJS/Runtime/WeakRef.cpp | 4 +- Userland/Libraries/LibJS/Runtime/WeakSet.cpp | 2 +- .../LibJS/Runtime/WrappedFunction.cpp | 4 +- Userland/Libraries/LibJS/Script.cpp | 2 +- Userland/Libraries/LibJS/SourceTextModule.cpp | 6 +- Userland/Libraries/LibJS/SyntheticModule.cpp | 4 +- .../Libraries/LibWeb/Bindings/Intrinsics.h | 8 +- .../LibWeb/Bindings/MainThreadVM.cpp | 4 +- Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp | 2 +- .../Libraries/LibWeb/CSS/MediaQueryList.cpp | 2 +- Userland/Libraries/LibWeb/CSS/Screen.cpp | 4 +- Userland/Libraries/LibWeb/Crypto/Crypto.cpp | 2 +- .../Libraries/LibWeb/Crypto/SubtleCrypto.cpp | 2 +- .../Libraries/LibWeb/DOM/AbortController.cpp | 2 +- Userland/Libraries/LibWeb/DOM/AbortSignal.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Attr.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Comment.cpp | 2 +- .../LibWeb/DOM/DOMImplementation.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Document.cpp | 10 +- .../Libraries/LibWeb/DOM/DocumentFragment.cpp | 2 +- .../Libraries/LibWeb/DOM/DocumentType.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 4 +- .../Libraries/LibWeb/DOM/ElementFactory.cpp | 168 +++++++++--------- Userland/Libraries/LibWeb/DOM/Event.cpp | 2 +- Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 12 +- .../Libraries/LibWeb/DOM/HTMLCollection.cpp | 2 +- .../Libraries/LibWeb/DOM/IDLEventListener.cpp | 2 +- .../Libraries/LibWeb/DOM/LiveNodeList.cpp | 2 +- .../Libraries/LibWeb/DOM/MutationObserver.cpp | 6 +- .../Libraries/LibWeb/DOM/MutationRecord.cpp | 2 +- .../Libraries/LibWeb/DOM/NamedNodeMap.cpp | 2 +- Userland/Libraries/LibWeb/DOM/NodeFilter.cpp | 2 +- .../Libraries/LibWeb/DOM/NodeIterator.cpp | 4 +- .../Libraries/LibWeb/DOM/NodeOperations.cpp | 5 +- Userland/Libraries/LibWeb/DOM/Range.cpp | 24 +-- .../Libraries/LibWeb/DOM/StaticNodeList.cpp | 2 +- Userland/Libraries/LibWeb/DOM/StaticRange.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Text.cpp | 4 +- Userland/Libraries/LibWeb/DOM/TreeWalker.cpp | 4 +- .../Libraries/LibWeb/DOMParsing/InnerHTML.cpp | 2 +- .../LibWeb/DOMParsing/XMLSerializer.cpp | 2 +- .../Libraries/LibWeb/Encoding/TextDecoder.cpp | 2 +- .../Libraries/LibWeb/Encoding/TextEncoder.cpp | 2 +- .../LibWeb/Fetch/Fetching/PendingResponse.cpp | 4 +- Userland/Libraries/LibWeb/Fetch/Headers.cpp | 4 +- .../LibWeb/Fetch/HeadersIterator.cpp | 2 +- .../Infrastructure/ConnectionTimingInfo.cpp | 2 +- .../Fetch/Infrastructure/FetchAlgorithms.cpp | 2 +- .../Fetch/Infrastructure/FetchController.cpp | 2 +- .../Fetch/Infrastructure/FetchParams.cpp | 2 +- .../Fetch/Infrastructure/FetchTimingInfo.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Bodies.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Headers.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Requests.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Responses.cpp | 10 +- Userland/Libraries/LibWeb/Fetch/Request.cpp | 6 +- Userland/Libraries/LibWeb/Fetch/Response.cpp | 6 +- Userland/Libraries/LibWeb/FileAPI/Blob.cpp | 8 +- Userland/Libraries/LibWeb/FileAPI/File.cpp | 2 +- .../Libraries/LibWeb/FileAPI/FileList.cpp | 2 +- .../Libraries/LibWeb/Geometry/DOMPoint.cpp | 2 +- .../LibWeb/Geometry/DOMPointReadOnly.cpp | 2 +- .../Libraries/LibWeb/Geometry/DOMRect.cpp | 2 +- .../Libraries/LibWeb/Geometry/DOMRectList.cpp | 2 +- .../LibWeb/Geometry/DOMRectReadOnly.cpp | 2 +- .../Libraries/LibWeb/HTML/CanvasGradient.cpp | 6 +- .../LibWeb/HTML/CanvasRenderingContext2D.cpp | 2 +- Userland/Libraries/LibWeb/HTML/DOMParser.cpp | 2 +- .../Libraries/LibWeb/HTML/DOMStringMap.cpp | 2 +- .../LibWeb/HTML/HTMLInputElement.cpp | 6 +- .../LibWeb/HTML/HTMLOptionsCollection.cpp | 2 +- Userland/Libraries/LibWeb/HTML/History.cpp | 2 +- .../Libraries/LibWeb/HTML/MessageChannel.cpp | 2 +- .../Libraries/LibWeb/HTML/MessagePort.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Navigator.cpp | 2 +- .../LibWeb/HTML/Parser/HTMLParser.cpp | 16 +- Userland/Libraries/LibWeb/HTML/Path2D.cpp | 2 +- .../LibWeb/HTML/Scripting/ClassicScript.cpp | 4 +- .../LibWeb/HTML/Scripting/ModuleScript.cpp | 2 +- .../WindowEnvironmentSettingsObject.cpp | 6 +- .../WorkerEnvironmentSettingsObject.h | 6 +- Userland/Libraries/LibWeb/HTML/Storage.cpp | 2 +- .../Libraries/LibWeb/HTML/TextMetrics.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Timer.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Window.cpp | 8 +- Userland/Libraries/LibWeb/HTML/Worker.cpp | 2 +- .../Libraries/LibWeb/HTML/WorkerNavigator.cpp | 2 +- .../IntersectionObserver.cpp | 2 +- .../Libraries/LibWeb/Layout/TreeBuilder.cpp | 6 +- .../RequestIdleCallback/IdleDeadline.cpp | 2 +- .../LibWeb/ResizeObserver/ResizeObserver.cpp | 2 +- .../LibWeb/SVG/SVGAnimatedLength.cpp | 2 +- Userland/Libraries/LibWeb/SVG/SVGLength.cpp | 2 +- .../Libraries/LibWeb/Selection/Selection.cpp | 2 +- .../LibWeb/Streams/ReadableStream.cpp | 4 +- Userland/Libraries/LibWeb/URL/URL.cpp | 2 +- .../Libraries/LibWeb/URL/URLSearchParams.cpp | 2 +- .../LibWeb/URL/URLSearchParamsIterator.cpp | 2 +- .../WebAssemblyInstanceConstructor.cpp | 2 +- .../WebAssemblyMemoryConstructor.cpp | 2 +- .../WebAssemblyModuleConstructor.cpp | 2 +- .../WebAssemblyTableConstructor.cpp | 2 +- .../Libraries/LibWeb/WebIDL/DOMException.cpp | 4 +- .../Libraries/LibWeb/WebSockets/WebSocket.cpp | 2 +- .../Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 2 +- .../WebContent/WebContentConsoleClient.cpp | 2 +- 161 files changed, 367 insertions(+), 370 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index eceaf92654c..7ee5ea8ec51 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -321,7 +321,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (!@js_name@@js_suffix@.is_object()) return vm.throw_completion(JS::ErrorType::NotAnObject, @js_name@@js_suffix@.to_string_without_side_effects()); - auto* callback_type = vm.heap().allocate_without_realm(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object()); + auto callback_type = vm.heap().allocate_without_realm(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object()); @cpp_name@ = @cpp_type@::create(realm, *callback_type).ptr(); } )~~~"); @@ -330,8 +330,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (!@js_name@@js_suffix@.is_object()) return vm.throw_completion(JS::ErrorType::NotAnObject, @js_name@@js_suffix@.to_string_without_side_effects()); - auto* callback_type = vm.heap().allocate_without_realm(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object()); - auto @cpp_name@ = adopt_ref(*new @cpp_type@(move(callback_type))); + auto callback_type = vm.heap().allocate_without_realm(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object()); + auto @cpp_name@ = adopt_ref(*new @cpp_type@(callback_type)); )~~~"); } } else if (IDL::is_platform_object(*parameter.type)) { diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 372cf53281c..122d2cbdf7f 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -50,7 +50,7 @@ public: static JS::ThrowCompletionOr create(JS::Realm& realm, Wasm::Module module, HashMap const& imports) { auto& vm = realm.vm(); - auto* instance = realm.heap().allocate(realm, *realm.intrinsics().object_prototype()); + auto instance = realm.heap().allocate(realm, *realm.intrinsics().object_prototype()); instance->m_module = move(module); Wasm::Linker linker(*instance->m_module); linker.link(imports); @@ -62,7 +62,7 @@ public: if (result.is_error()) return vm.throw_completion(result.release_error().error); instance->m_module_instance = result.release_value(); - return instance; + return instance.ptr(); } void initialize(JS::Realm&) override; diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index a8ab19f3981..413413d7a3b 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -816,7 +816,7 @@ void ContinuePendingUnwind::replace_references_impl(BasicBlock const& from, Basi ThrowCompletionOr PushDeclarativeEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const { - auto* environment = interpreter.vm().heap().allocate_without_realm(interpreter.vm().lexical_environment()); + auto environment = interpreter.vm().heap().allocate_without_realm(interpreter.vm().lexical_environment()); interpreter.vm().running_execution_context().lexical_environment = environment; interpreter.vm().running_execution_context().variable_environment = environment; return {}; diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp index 671126e0abb..4c7a2f91318 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp @@ -59,7 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::clear_kept_objects) JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm) { auto realm = Realm::create(vm); - auto* realm_global_object = vm.heap().allocate_without_realm(*realm); + auto realm_global_object = vm.heap().allocate_without_realm(*realm); VERIFY(realm_global_object); realm->set_global_object(realm_global_object, nullptr); set_default_global_bindings(*realm); diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index da894067d1d..aa58a11ccee 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -33,21 +33,21 @@ public: ~Heap(); template - T* allocate_without_realm(Args&&... args) + NonnullGCPtr allocate_without_realm(Args&&... args) { auto* memory = allocate_cell(sizeof(T)); new (memory) T(forward(args)...); - return static_cast(memory); + return *static_cast(memory); } template - T* allocate(Realm& realm, Args&&... args) + NonnullGCPtr allocate(Realm& realm, Args&&... args) { auto* memory = allocate_cell(sizeof(T)); new (memory) T(forward(args)...); auto* cell = static_cast(memory); memory->initialize(realm); - return cell; + return *cell; } enum class CollectionType { diff --git a/Userland/Libraries/LibJS/Module.cpp b/Userland/Libraries/LibJS/Module.cpp index 986c070d790..bba073a044c 100644 --- a/Userland/Libraries/LibJS/Module.cpp +++ b/Userland/Libraries/LibJS/Module.cpp @@ -114,7 +114,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, realm, this, move(unambiguous_names)); + auto module_namespace = vm.heap().allocate(realm, 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 76e33d4e792..181bcf5e97a 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -412,7 +412,7 @@ FunctionEnvironment* new_function_environment(ECMAScriptFunctionObject& function auto& heap = function.heap(); // 1. Let env be a new function Environment Record containing no bindings. - auto* env = heap.allocate_without_realm(function.environment()); + auto env = heap.allocate_without_realm(function.environment()); // 2. Set env.[[FunctionObject]] to F. env->set_function_object(function); @@ -1101,7 +1101,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector< // 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(realm, realm, environment); + auto object = vm.heap().allocate(realm, realm, environment); // 14. Let index be 0. // 15. Repeat, while index < len, diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h index 896484d5f85..ab16d30c347 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h @@ -135,7 +135,7 @@ ThrowCompletionOr ordinary_create_from_constructor(VM& vm, FunctionObject co { auto& realm = *vm.current_realm(); auto* prototype = TRY(get_prototype_from_constructor(vm, constructor, intrinsic_default_prototype)); - return realm.heap().allocate(realm, forward(args)..., *prototype); + return realm.heap().allocate(realm, forward(args)..., *prototype).ptr(); } // 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists diff --git a/Userland/Libraries/LibJS/Runtime/Accessor.h b/Userland/Libraries/LibJS/Runtime/Accessor.h index 213627541c7..740e53701e2 100644 --- a/Userland/Libraries/LibJS/Runtime/Accessor.h +++ b/Userland/Libraries/LibJS/Runtime/Accessor.h @@ -19,7 +19,7 @@ class Accessor final : public Cell { public: static NonnullGCPtr create(VM& vm, FunctionObject* getter, FunctionObject* setter) { - return *vm.heap().allocate_without_realm(getter, setter); + return vm.heap().allocate_without_realm(getter, setter); } FunctionObject* getter() const { return m_getter; } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp index 8ad7773c5b3..7780e464cfa 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateError.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateError.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr AggregateError::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().aggregate_error_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().aggregate_error_prototype()); } AggregateError::AggregateError(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index 3a8c6ae8fea..b651b31f1b4 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -32,13 +32,13 @@ ThrowCompletionOr> Array::create(Realm& realm, u64 length, O // 3. Let A be MakeBasicObject(« [[Prototype]], [[Extensible]] »). // 4. Set A.[[Prototype]] to proto. // 5. Set A.[[DefineOwnProperty]] as specified in 10.4.2.1. - auto* array = realm.heap().allocate(realm, *prototype); + auto array = realm.heap().allocate(realm, *prototype); // 6. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }). MUST(array->internal_define_own_property(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = false })); // 7. Return A. - return NonnullGCPtr { *array }; + return array; } // 7.3.18 CreateArrayFromList ( elements ), https://tc39.es/ecma262/#sec-createarrayfromlist diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp index 772fc285ce2..b4f4ba09b72 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp @@ -17,17 +17,17 @@ ThrowCompletionOr> ArrayBuffer::create(Realm& realm, s if (buffer.is_error()) return realm.vm().throw_completion(ErrorType::NotEnoughMemoryToAllocate, byte_length); - return NonnullGCPtr { *realm.heap().allocate(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype()) }; + return realm.heap().allocate(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype()); } NonnullGCPtr ArrayBuffer::create(Realm& realm, ByteBuffer buffer) { - return *realm.heap().allocate(realm, move(buffer), *realm.intrinsics().array_buffer_prototype()); + return realm.heap().allocate(realm, move(buffer), *realm.intrinsics().array_buffer_prototype()); } NonnullGCPtr ArrayBuffer::create(Realm& realm, ByteBuffer* buffer) { - return *realm.heap().allocate(realm, buffer, *realm.intrinsics().array_buffer_prototype()); + return realm.heap().allocate(realm, buffer, *realm.intrinsics().array_buffer_prototype()); } ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp index eca16e41087..4b23b3c3c90 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind) { - return *realm.heap().allocate(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype()); + return realm.heap().allocate(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype()); } ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp index 9459ccc1d2b..61daf95fd6f 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr AsyncFromSyncIterator::create(Realm& realm, Iterator sync_iterator_record) { - return *realm.heap().allocate(realm, realm, sync_iterator_record); + return realm.heap().allocate(realm, realm, sync_iterator_record); } AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record) diff --git a/Userland/Libraries/LibJS/Runtime/BigInt.cpp b/Userland/Libraries/LibJS/Runtime/BigInt.cpp index 86691727e2c..8c0b8a443fc 100644 --- a/Userland/Libraries/LibJS/Runtime/BigInt.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigInt.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr BigInt::create(VM& vm, Crypto::SignedBigInteger big_integer) { - return *vm.heap().allocate_without_realm(move(big_integer)); + return vm.heap().allocate_without_realm(move(big_integer)); } BigInt::BigInt(Crypto::SignedBigInteger big_integer) diff --git a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp index 686f7902009..25ffe5b4fd1 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr BigIntObject::create(Realm& realm, BigInt& bigint) { - return *realm.heap().allocate(realm, bigint, *realm.intrinsics().bigint_prototype()); + return realm.heap().allocate(realm, bigint, *realm.intrinsics().bigint_prototype()); } BigIntObject::BigIntObject(BigInt& bigint, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp index 21decbc74bc..95121a47f66 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr BooleanObject::create(Realm& realm, bool value) { - return *realm.heap().allocate(realm, value, *realm.intrinsics().boolean_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().boolean_prototype()); } BooleanObject::BooleanObject(bool value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index e2871b05a10..96032afa867 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -26,10 +26,10 @@ ThrowCompletionOr> BoundFunction::create(Realm& real // 7. Set obj.[[BoundTargetFunction]] to targetFunction. // 8. Set obj.[[BoundThis]] to boundThis. // 9. Set obj.[[BoundArguments]] to boundArgs. - auto* object = realm.heap().allocate(realm, realm, target_function, bound_this, move(bound_arguments), prototype); + auto object = realm.heap().allocate(realm, realm, target_function, bound_this, move(bound_arguments), prototype); // 10. Return obj. - return NonnullGCPtr { *object }; + return object; } BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function, Value bound_this, Vector bound_arguments, Object* prototype) diff --git a/Userland/Libraries/LibJS/Runtime/DataView.cpp b/Userland/Libraries/LibJS/Runtime/DataView.cpp index bf4ac736803..8abf686c46f 100644 --- a/Userland/Libraries/LibJS/Runtime/DataView.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataView.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset) { - return *realm.heap().allocate(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype()); + return realm.heap().allocate(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype()); } DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index 0c553da8acb..4c4db3ee144 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -23,7 +23,7 @@ static Crypto::SignedBigInteger const s_one_thousand_bigint { 1'000 }; NonnullGCPtr Date::create(Realm& realm, double date_value) { - return *realm.heap().allocate(realm, date_value, *realm.intrinsics().date_prototype()); + return realm.heap().allocate(realm, date_value, *realm.intrinsics().date_prototype()); } Date::Date(double date_value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index e9ca7280727..b77de62ad0d 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -45,12 +45,12 @@ NonnullGCPtr ECMAScriptFunctionObject::create(Realm& r prototype = realm.intrinsics().async_generator_function_prototype(); break; } - return *realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); + return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); } NonnullGCPtr ECMAScriptFunctionObject::create(Realm& realm, FlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name) { - return *realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); + return realm.heap().allocate(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name)); } ECMAScriptFunctionObject::ECMAScriptFunctionObject(FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector formal_parameters, i32 function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant class_field_initializer_name) diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp index ca3960899a8..ea377a5565a 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.cpp +++ b/Userland/Libraries/LibJS/Runtime/Error.cpp @@ -16,7 +16,7 @@ namespace JS { NonnullGCPtr Error::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().error_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().error_prototype()); } NonnullGCPtr Error::create(Realm& realm, DeprecatedString const& message) @@ -98,24 +98,24 @@ DeprecatedString Error::stack_string() const return stack_string_builder.build(); } -#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - NonnullGCPtr ClassName::create(Realm& realm) \ - { \ - return *realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype()); \ - } \ - \ - NonnullGCPtr ClassName::create(Realm& realm, DeprecatedString const& message) \ - { \ - auto& vm = realm.vm(); \ - auto error = ClassName::create(realm); \ - u8 attr = Attribute::Writable | Attribute::Configurable; \ - error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \ - return error; \ - } \ - \ - ClassName::ClassName(Object& prototype) \ - : Error(prototype) \ - { \ +#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ + NonnullGCPtr ClassName::create(Realm& realm) \ + { \ + return realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype()); \ + } \ + \ + NonnullGCPtr ClassName::create(Realm& realm, DeprecatedString const& message) \ + { \ + auto& vm = realm.vm(); \ + auto error = ClassName::create(realm); \ + u8 attr = Attribute::Writable | Attribute::Configurable; \ + error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \ + return error; \ + } \ + \ + ClassName::ClassName(Object& prototype) \ + : Error(prototype) \ + { \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 206ecc25970..99016bbb66d 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -32,7 +32,7 @@ ThrowCompletionOr> GeneratorObject::create(Realm& object->m_generating_function = generating_function; object->m_frame = move(frame); object->m_previous_value = initial_value; - return NonnullGCPtr { *object }; + return object; } GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext context) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index 7da460de038..a12ce9ced6d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp @@ -13,7 +13,7 @@ namespace JS::Intl { NonnullGCPtr CollatorCompareFunction::create(Realm& realm, Collator& collator) { - return *realm.heap().allocate(realm, realm, collator); + return realm.heap().allocate(realm, realm, collator); } CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp index 3b8be4d42a7..5fc0912b764 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp @@ -16,7 +16,7 @@ namespace JS::Intl { // 11.5.5 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions NonnullGCPtr DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format) { - return *realm.heap().allocate(realm, date_time_format, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, date_time_format, *realm.intrinsics().function_prototype()); } DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp index 3907cbf695c..5dfa3ee110a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -16,7 +16,7 @@ namespace JS::Intl { NonnullGCPtr Locale::create(Realm& realm, ::Locale::LocaleID const& locale_id) { - return *realm.heap().allocate(realm, locale_id, *realm.intrinsics().intl_locale_prototype()); + return realm.heap().allocate(realm, locale_id, *realm.intrinsics().intl_locale_prototype()); } // 14 Locale Objects, https://tc39.es/ecma402/#locale-objects diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index ea4377ec3bb..f3581ff3b38 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -14,7 +14,7 @@ namespace JS::Intl { // 1.1.4 Number Format Functions, https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-number-format-functions NonnullGCPtr NumberFormatFunction::create(Realm& realm, NumberFormat& number_format) { - return *realm.heap().allocate(realm, number_format, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, number_format, *realm.intrinsics().function_prototype()); } NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp index 0fbdf3c6d8f..1fb4f32d735 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp @@ -19,7 +19,7 @@ NonnullGCPtr SegmentIterator::create(Realm& realm, Segmenter& s // 4. Set iterator.[[IteratedString]] to string. // 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0. // 6. Return iterator. - return *realm.heap().allocate(realm, realm, segmenter, move(string), segments); + return realm.heap().allocate(realm, realm, segmenter, move(string), segments); } // 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp index 2572fcf6d7d..585b3b72294 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Segments.cpp @@ -18,7 +18,7 @@ NonnullGCPtr Segments::create(Realm& realm, Segmenter& segmenter, Utf1 // 3. Set segments.[[SegmentsSegmenter]] to segmenter. // 4. Set segments.[[SegmentsString]] to string. // 5. Return segments. - return *realm.heap().allocate(realm, realm, segmenter, move(string)); + return realm.heap().allocate(realm, realm, segmenter, move(string)); } // 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp index 1380e1a25cd..1ab3d197283 100644 --- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -137,8 +137,8 @@ NonnullGCPtr Intrinsics::create(Realm& realm) auto& vm = realm.vm(); // 1. Set realmRec.[[Intrinsics]] to a new Record. - auto* intrinsics = vm.heap().allocate_without_realm(realm); - realm.set_intrinsics({}, *intrinsics); + auto intrinsics = vm.heap().allocate_without_realm(realm); + realm.set_intrinsics({}, intrinsics); // 2. Set fields of realmRec.[[Intrinsics]] with the values listed in Table 6. // The field names are the names listed in column one of the table. diff --git a/Userland/Libraries/LibJS/Runtime/Map.cpp b/Userland/Libraries/LibJS/Runtime/Map.cpp index e65dde2e04e..bc29064bf63 100644 --- a/Userland/Libraries/LibJS/Runtime/Map.cpp +++ b/Userland/Libraries/LibJS/Runtime/Map.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr Map::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().map_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().map_prototype()); } Map::Map(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp index 7685bcee828..ef66637bd57 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind) { - return *realm.heap().allocate(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype()); + return realm.heap().allocate(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype()); } MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp index 8a50e3ad3c7..31df52b1b42 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -36,7 +36,7 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Saf // 7. Set func.[[Extensible]] to true. // 8. Set func.[[Realm]] to realm. // 9. Set func.[[InitialName]] to null. - auto* function = allocating_realm.heap().allocate(allocating_realm, move(behaviour), prototype.value(), *realm.value()); + auto function = allocating_realm.heap().allocate(allocating_realm, move(behaviour), prototype.value(), *realm.value()); // 10. Perform SetFunctionLength(func, length). function->set_function_length(length); @@ -48,12 +48,12 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Saf function->set_function_name(name, prefix); // 13. Return func. - return *function; + return function; } NonnullGCPtr NativeFunction::create(Realm& realm, FlyString const& name, SafeFunction(VM&)> function) { - return *realm.heap().allocate(realm, name, move(function), *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, name, move(function), *realm.intrinsics().function_prototype()); } NativeFunction::NativeFunction(SafeFunction(VM&)> native_function, Object* prototype, Realm& realm) diff --git a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp index 0086a454ae5..72cfc01548c 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberObject.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr NumberObject::create(Realm& realm, double value) { - return *realm.heap().allocate(realm, value, *realm.intrinsics().number_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().number_prototype()); } NumberObject::NumberObject(double value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 1de34675bad..4869c69318c 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -30,11 +30,11 @@ static HashMap> s_i NonnullGCPtr Object::create(Realm& realm, Object* prototype) { if (!prototype) - return *realm.heap().allocate(realm, *realm.intrinsics().empty_object_shape()); + return realm.heap().allocate(realm, *realm.intrinsics().empty_object_shape()); else if (prototype == realm.intrinsics().object_prototype()) - return *realm.heap().allocate(realm, *realm.intrinsics().new_object_shape()); + return realm.heap().allocate(realm, *realm.intrinsics().new_object_shape()); else - return *realm.heap().allocate(realm, ConstructWithPrototypeTag::Tag, *prototype); + return realm.heap().allocate(realm, ConstructWithPrototypeTag::Tag, *prototype); } Object::Object(GlobalObjectTag, Realm& realm) diff --git a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp index 2b0a3ed4d6b..cecc841b6e9 100644 --- a/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Userland/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -125,7 +125,7 @@ NonnullGCPtr PrimitiveString::create(VM& vm, Utf16String string return vm.single_ascii_character_string(static_cast(code_unit)); } - return *vm.heap().allocate_without_realm(move(string)); + return vm.heap().allocate_without_realm(move(string)); } NonnullGCPtr PrimitiveString::create(VM& vm, DeprecatedString string) @@ -142,7 +142,7 @@ NonnullGCPtr PrimitiveString::create(VM& vm, DeprecatedString s auto& string_cache = vm.string_cache(); auto it = string_cache.find(string); if (it == string_cache.end()) { - auto* new_string = vm.heap().allocate_without_realm(string); + auto new_string = vm.heap().allocate_without_realm(string); string_cache.set(move(string), new_string); return *new_string; } @@ -166,7 +166,7 @@ NonnullGCPtr PrimitiveString::create(VM& vm, PrimitiveString& l if (rhs_empty) return lhs; - return *vm.heap().allocate_without_realm(lhs, rhs); + return vm.heap().allocate_without_realm(lhs, rhs); } void PrimitiveString::resolve_rope_if_needed() const diff --git a/Userland/Libraries/LibJS/Runtime/Promise.cpp b/Userland/Libraries/LibJS/Runtime/Promise.cpp index 658fe85a332..40a721ce22b 100644 --- a/Userland/Libraries/LibJS/Runtime/Promise.cpp +++ b/Userland/Libraries/LibJS/Runtime/Promise.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr promise_resolve(VM& vm, Object& constructor, Value va NonnullGCPtr Promise::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().promise_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().promise_prototype()); } // 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects @@ -62,7 +62,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions() auto& realm = *vm.current_realm(); // 1. Let alreadyResolved be the Record { [[Value]]: false }. - auto* already_resolved = vm.heap().allocate_without_realm(); + auto already_resolved = vm.heap().allocate_without_realm(); // 2. Let stepsResolve be the algorithm steps defined in Promise Resolve Functions. // 3. Let lengthResolve be the number of non-optional parameters of the function definition in Promise Resolve Functions. diff --git a/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp b/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp index 7a4f1565c54..e3715ce70d1 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseCapability.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr PromiseCapability::create(VM& vm, GCPtr promise, GCPtr resolve, GCPtr reject) { - return NonnullGCPtr { *vm.heap().allocate_without_realm(promise, resolve, reject) }; + return vm.heap().allocate_without_realm(promise, resolve, reject); } PromiseCapability::PromiseCapability(GCPtr promise, GCPtr resolve, GCPtr reject) diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index c01564c9282..3215f78f960 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -45,10 +45,10 @@ static ThrowCompletionOr perform_promise_common(VM& vm, Iterator& iterato VERIFY(promise_resolve.is_function()); // 1. Let values be a new empty List. - auto* values = vm.heap().allocate_without_realm(); + auto values = vm.heap().allocate_without_realm(); // 2. Let remainingElementsCount be the Record { [[Value]]: 1 }. - auto* remaining_elements_count = vm.heap().allocate_without_realm(1); + auto remaining_elements_count = vm.heap().allocate_without_realm(1); // 3. Let index be 0. size_t index = 0; diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp index e6e7fb3997a..9de245875af 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr PromiseReaction::create(VM& vm, Type type, GCPtr capability, Optional handler) { - return *vm.heap().allocate_without_realm(type, capability, move(handler)); + return vm.heap().allocate_without_realm(type, capability, move(handler)); } PromiseReaction::PromiseReaction(Type type, GCPtr capability, Optional handler) diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 53f7c47cdcb..4354e59aef3 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -55,7 +55,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor) NonnullGCPtr PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return *realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); } PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -87,7 +87,7 @@ ThrowCompletionOr PromiseAllResolveElementFunction::resolve_element() NonnullGCPtr PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return *realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); } PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -128,7 +128,7 @@ ThrowCompletionOr PromiseAllSettledResolveElementFunction::resolve_elemen NonnullGCPtr PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return *realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype()); } PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -169,7 +169,7 @@ ThrowCompletionOr PromiseAllSettledRejectElementFunction::resolve_element NonnullGCPtr PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr capability, RemainingElements& remaining_elements) { - return *realm.heap().allocate(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype()); } PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp index fe0b4d9cb97..c79e9e1f3bb 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp @@ -13,7 +13,7 @@ namespace JS { NonnullGCPtr PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function) { - return *realm.heap().allocate(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype()); + return realm.heap().allocate(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype()); } PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index c8e79102afa..e25197715a6 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -17,7 +17,7 @@ namespace JS { NonnullGCPtr ProxyObject::create(Realm& realm, Object& target, Object& handler) { - return *realm.heap().allocate(realm, target, handler, *realm.intrinsics().object_prototype()); + return realm.heap().allocate(realm, target, handler, *realm.intrinsics().object_prototype()); } ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Realm.cpp b/Userland/Libraries/LibJS/Runtime/Realm.cpp index ff7206219fe..a75aec04e4a 100644 --- a/Userland/Libraries/LibJS/Runtime/Realm.cpp +++ b/Userland/Libraries/LibJS/Runtime/Realm.cpp @@ -18,7 +18,7 @@ namespace JS { NonnullGCPtr Realm::create(VM& vm) { // 1. Let realmRec be a new Realm Record. - auto* realm = vm.heap().allocate_without_realm(); + auto realm = vm.heap().allocate_without_realm(); // 2. Perform CreateIntrinsics(realmRec). Intrinsics::create(*realm); @@ -28,7 +28,7 @@ NonnullGCPtr Realm::create(VM& vm) // 5. Set realmRec.[[TemplateMap]] to a new empty List. // 6. Return realmRec. - return *realm; + return realm; } // 9.6 InitializeHostDefinedRealm ( ), https://tc39.es/ecma262/#sec-initializehostdefinedrealm diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp index 7c0f49e25a1..041de097ca9 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -126,12 +126,12 @@ ThrowCompletionOr parse_regex_pattern(VM& vm, StringView patte NonnullGCPtr RegExpObject::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().regexp_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().regexp_prototype()); } NonnullGCPtr RegExpObject::create(Realm& realm, Regex regex, DeprecatedString pattern, DeprecatedString flags) { - return *realm.heap().allocate(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()); + return realm.heap().allocate(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype()); } RegExpObject::RegExpObject(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp index 284462e69f8..0419110055f 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIterator.cpp @@ -12,7 +12,7 @@ namespace JS { // 22.2.7.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator NonnullGCPtr RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode) { - return *realm.heap().allocate(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode); + return realm.heap().allocate(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode); } RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode) diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp index 9a6dec409b9..4f1966dc2c0 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.cpp +++ b/Userland/Libraries/LibJS/Runtime/Set.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr Set::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().set_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().set_prototype()); } Set::Set(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp index c951e67d5bf..f75f17e626f 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIterator.cpp @@ -11,7 +11,7 @@ namespace JS { NonnullGCPtr SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind) { - return *realm.heap().allocate(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype()); + return realm.heap().allocate(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype()); } SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Shape.cpp b/Userland/Libraries/LibJS/Runtime/Shape.cpp index a4243d4a299..11423b931d6 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.cpp +++ b/Userland/Libraries/LibJS/Runtime/Shape.cpp @@ -12,7 +12,7 @@ namespace JS { Shape* Shape::create_unique_clone() const { - auto* new_shape = heap().allocate_without_realm(m_realm); + auto new_shape = heap().allocate_without_realm(m_realm); new_shape->m_unique = true; new_shape->m_prototype = m_prototype; ensure_property_table(); @@ -57,10 +57,10 @@ Shape* Shape::create_put_transition(StringOrSymbol const& property_key, Property TransitionKey key { property_key, attributes }; if (auto* existing_shape = get_or_prune_cached_forward_transition(key)) return existing_shape; - auto* new_shape = heap().allocate_without_realm(*this, property_key, attributes, TransitionType::Put); + auto new_shape = heap().allocate_without_realm(*this, property_key, attributes, TransitionType::Put); if (!m_forward_transitions) m_forward_transitions = make>>(); - m_forward_transitions->set(key, new_shape); + m_forward_transitions->set(key, new_shape.ptr()); return new_shape; } @@ -69,10 +69,10 @@ Shape* Shape::create_configure_transition(StringOrSymbol const& property_key, Pr TransitionKey key { property_key, attributes }; if (auto* existing_shape = get_or_prune_cached_forward_transition(key)) return existing_shape; - auto* new_shape = heap().allocate_without_realm(*this, property_key, attributes, TransitionType::Configure); + auto new_shape = heap().allocate_without_realm(*this, property_key, attributes, TransitionType::Configure); if (!m_forward_transitions) m_forward_transitions = make>>(); - m_forward_transitions->set(key, new_shape); + m_forward_transitions->set(key, new_shape.ptr()); return new_shape; } @@ -80,10 +80,10 @@ Shape* Shape::create_prototype_transition(Object* new_prototype) { if (auto* existing_shape = get_or_prune_cached_prototype_transition(new_prototype)) return existing_shape; - auto* new_shape = heap().allocate_without_realm(*this, new_prototype); + auto new_shape = heap().allocate_without_realm(*this, new_prototype); if (!m_prototype_transitions) m_prototype_transitions = make>>(); - m_prototype_transitions->set(new_prototype, new_shape); + m_prototype_transitions->set(new_prototype, new_shape.ptr()); return new_shape; } diff --git a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp index 6d8255976d4..5b3a92131de 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIterator.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr StringIterator::create(Realm& realm, DeprecatedString string) { - return *realm.heap().allocate(realm, move(string), *realm.intrinsics().string_iterator_prototype()); + return realm.heap().allocate(realm, move(string), *realm.intrinsics().string_iterator_prototype()); } StringIterator::StringIterator(DeprecatedString string, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index 1c451d7446b..51da264983c 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -17,7 +17,7 @@ namespace JS { // 10.4.3.4 StringCreate ( value, prototype ), https://tc39.es/ecma262/#sec-stringcreate NonnullGCPtr StringObject::create(Realm& realm, PrimitiveString& primitive_string, Object& prototype) { - return *realm.heap().allocate(realm, primitive_string, prototype); + return realm.heap().allocate(realm, primitive_string, prototype); } StringObject::StringObject(PrimitiveString& string, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/Symbol.cpp b/Userland/Libraries/LibJS/Runtime/Symbol.cpp index 9dd6b3f237b..eabb625b241 100644 --- a/Userland/Libraries/LibJS/Runtime/Symbol.cpp +++ b/Userland/Libraries/LibJS/Runtime/Symbol.cpp @@ -19,7 +19,7 @@ Symbol::Symbol(Optional description, bool is_global) NonnullGCPtr Symbol::create(VM& vm, Optional description, bool is_global) { - return *vm.heap().allocate_without_realm(move(description), is_global); + return vm.heap().allocate_without_realm(move(description), is_global); } } diff --git a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp index 84260209553..b59a83401b9 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolObject.cpp @@ -12,7 +12,7 @@ namespace JS { NonnullGCPtr SymbolObject::create(Realm& realm, Symbol& primitive_symbol) { - return *realm.heap().allocate(realm, primitive_symbol, *realm.intrinsics().symbol_prototype()); + return realm.heap().allocate(realm, primitive_symbol, *realm.intrinsics().symbol_prototype()); } SymbolObject::SymbolObject(Symbol& symbol, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index 42746970de2..d5e327f31cd 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -425,7 +425,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor) { \ auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \ auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \ - return NonnullGCPtr { *realm.heap().allocate(realm, *prototype, length, *array_buffer) }; \ + return realm.heap().allocate(realm, *prototype, length, *array_buffer); \ } \ \ ThrowCompletionOr> ClassName::create(Realm& realm, u32 length) \ @@ -436,7 +436,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor) \ NonnullGCPtr ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \ { \ - return *realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer); \ + return realm.heap().allocate(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer); \ } \ \ ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \ diff --git a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp index eb5e0bd906d..8bcb04ade37 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMap.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMap.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr WeakMap::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().weak_map_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().weak_map_prototype()); } WeakMap::WeakMap(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp index 546f58bbf27..9f80170eb52 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRef.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRef.cpp @@ -10,12 +10,12 @@ namespace JS { NonnullGCPtr WeakRef::create(Realm& realm, Object& value) { - return *realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()); } NonnullGCPtr WeakRef::create(Realm& realm, Symbol& value) { - return *realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()); + return realm.heap().allocate(realm, value, *realm.intrinsics().weak_ref_prototype()); } WeakRef::WeakRef(Object& value, Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp index 89b1e9e0f24..ceaf10f6cf2 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp @@ -10,7 +10,7 @@ namespace JS { NonnullGCPtr WeakSet::create(Realm& realm) { - return *realm.heap().allocate(realm, *realm.intrinsics().weak_set_prototype()); + return realm.heap().allocate(realm, *realm.intrinsics().weak_set_prototype()); } WeakSet::WeakSet(Object& prototype) diff --git a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp index 3400c5a4891..8c220ba39d9 100644 --- a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp @@ -22,7 +22,7 @@ ThrowCompletionOr> WrappedFunction::create(Realm& // 5. Set wrapped.[[WrappedTargetFunction]] to Target. // 6. Set wrapped.[[Realm]] to callerRealm. auto& prototype = *caller_realm.intrinsics().function_prototype(); - auto* wrapped = vm.heap().allocate(realm, caller_realm, target, prototype); + auto wrapped = vm.heap().allocate(realm, caller_realm, target, prototype); // 7. Let result be CopyNameAndLength(wrapped, Target). auto result = copy_name_and_length(vm, *wrapped, target); @@ -32,7 +32,7 @@ ThrowCompletionOr> WrappedFunction::create(Realm& return vm.throw_completion(ErrorType::WrappedFunctionCopyNameAndLengthThrowCompletion); // 9. Return wrapped. - return NonnullGCPtr { *wrapped }; + return wrapped; } // 2 Wrapped Function Exotic Objects, https://tc39.es/proposal-shadowrealm/#sec-wrapped-function-exotic-objects diff --git a/Userland/Libraries/LibJS/Script.cpp b/Userland/Libraries/LibJS/Script.cpp index 80bb3193ce6..56fa37807fb 100644 --- a/Userland/Libraries/LibJS/Script.cpp +++ b/Userland/Libraries/LibJS/Script.cpp @@ -24,7 +24,7 @@ Result, Vector> Script::parse(StringView sourc return parser.errors(); // 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }. - return NonnullGCPtr(*realm.heap().allocate_without_realm