From 9b79a686eb14bc615ba63d37f3fc417f47cee0d4 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Thu, 14 Nov 2024 05:50:17 +1300 Subject: [PATCH] LibJS+LibWeb: Use realm.create instead of heap.allocate The main motivation behind this is to remove JS specifics of the Realm from the implementation of the Heap. As a side effect of this change, this is a bit nicer to read than the previous approach, and in my opinion, also makes it a little more clear that this method is specific to a JavaScript Realm. --- Libraries/LibJS/Bytecode/Interpreter.cpp | 2 +- Libraries/LibJS/Contrib/Test262/262Object.cpp | 4 +- .../LibJS/Contrib/Test262/GlobalObject.cpp | 2 +- Libraries/LibJS/Heap/Heap.h | 12 - Libraries/LibJS/Module.cpp | 6 +- Libraries/LibJS/Module.h | 2 +- .../LibJS/Runtime/AbstractOperations.cpp | 2 +- Libraries/LibJS/Runtime/AbstractOperations.h | 2 +- Libraries/LibJS/Runtime/AggregateError.cpp | 2 +- Libraries/LibJS/Runtime/Array.cpp | 2 +- Libraries/LibJS/Runtime/ArrayBuffer.cpp | 6 +- Libraries/LibJS/Runtime/ArrayIterator.cpp | 2 +- .../LibJS/Runtime/AsyncFromSyncIterator.cpp | 2 +- .../AsyncFromSyncIteratorPrototype.cpp | 2 +- .../Runtime/AsyncFunctionDriverWrapper.cpp | 2 +- Libraries/LibJS/Runtime/AsyncGenerator.cpp | 2 +- Libraries/LibJS/Runtime/BigIntObject.cpp | 2 +- Libraries/LibJS/Runtime/BooleanObject.cpp | 2 +- Libraries/LibJS/Runtime/BoundFunction.cpp | 2 +- Libraries/LibJS/Runtime/ConsoleObject.cpp | 4 +- Libraries/LibJS/Runtime/DataView.cpp | 2 +- Libraries/LibJS/Runtime/Date.cpp | 2 +- .../Runtime/ECMAScriptFunctionObject.cpp | 4 +- Libraries/LibJS/Runtime/Error.cpp | 4 +- Libraries/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 | 44 ++-- Libraries/LibJS/Runtime/Iterator.cpp | 8 +- Libraries/LibJS/Runtime/IteratorHelper.cpp | 2 +- Libraries/LibJS/Runtime/IteratorPrototype.cpp | 2 +- Libraries/LibJS/Runtime/Map.cpp | 2 +- Libraries/LibJS/Runtime/MapIterator.cpp | 2 +- Libraries/LibJS/Runtime/NativeFunction.cpp | 4 +- Libraries/LibJS/Runtime/NumberObject.cpp | 2 +- Libraries/LibJS/Runtime/Object.cpp | 10 +- Libraries/LibJS/Runtime/Promise.cpp | 2 +- Libraries/LibJS/Runtime/PromiseCapability.cpp | 2 +- .../PromiseResolvingElementFunctions.cpp | 8 +- .../Runtime/PromiseResolvingFunction.cpp | 2 +- Libraries/LibJS/Runtime/ProxyObject.cpp | 2 +- Libraries/LibJS/Runtime/Realm.h | 9 + Libraries/LibJS/Runtime/RegExpObject.cpp | 4 +- .../LibJS/Runtime/RegExpStringIterator.cpp | 2 +- Libraries/LibJS/Runtime/Set.cpp | 2 +- Libraries/LibJS/Runtime/SetIterator.cpp | 2 +- Libraries/LibJS/Runtime/StringIterator.cpp | 2 +- Libraries/LibJS/Runtime/StringObject.cpp | 2 +- Libraries/LibJS/Runtime/SuppressedError.cpp | 2 +- Libraries/LibJS/Runtime/SymbolObject.cpp | 2 +- Libraries/LibJS/Runtime/Temporal/Temporal.cpp | 2 +- Libraries/LibJS/Runtime/TypedArray.cpp | 4 +- Libraries/LibJS/Runtime/WeakMap.cpp | 2 +- Libraries/LibJS/Runtime/WeakRef.cpp | 4 +- Libraries/LibJS/Runtime/WeakSet.cpp | 2 +- Libraries/LibJS/Runtime/WrappedFunction.cpp | 2 +- Libraries/LibTest/JavaScriptTestRunner.h | 2 +- Libraries/LibWeb/Animations/Animation.cpp | 2 +- .../Animations/AnimationPlaybackEvent.cpp | 2 +- .../LibWeb/Animations/DocumentTimeline.cpp | 2 +- .../LibWeb/Animations/KeyframeEffect.cpp | 10 +- Libraries/LibWeb/Bindings/MainThreadVM.cpp | 4 +- .../LibWeb/Bindings/OptionConstructor.cpp | 2 +- Libraries/LibWeb/CSS/AnimationEvent.cpp | 2 +- Libraries/LibWeb/CSS/CSSAnimation.cpp | 2 +- Libraries/LibWeb/CSS/CSSFontFaceRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSImportRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSKeyframeRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSKeyframesRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSLayerBlockRule.cpp | 2 +- .../LibWeb/CSS/CSSLayerStatementRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSMediaRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSNamespaceRule.cpp | 2 +- .../LibWeb/CSS/CSSNestedDeclarations.cpp | 2 +- Libraries/LibWeb/CSS/CSSPropertyRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSRuleList.cpp | 4 +- Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp | 4 +- Libraries/LibWeb/CSS/CSSStyleRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSStyleSheet.cpp | 2 +- Libraries/LibWeb/CSS/CSSSupportsRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSTransition.cpp | 2 +- Libraries/LibWeb/CSS/FontFace.cpp | 2 +- Libraries/LibWeb/CSS/FontFaceSet.cpp | 2 +- Libraries/LibWeb/CSS/MediaList.cpp | 2 +- Libraries/LibWeb/CSS/MediaQueryList.cpp | 2 +- Libraries/LibWeb/CSS/MediaQueryListEvent.cpp | 2 +- .../CSS/ResolvedCSSStyleDeclaration.cpp | 2 +- Libraries/LibWeb/CSS/Screen.cpp | 2 +- Libraries/LibWeb/CSS/ScreenOrientation.cpp | 2 +- Libraries/LibWeb/CSS/StyleSheetList.cpp | 2 +- Libraries/LibWeb/CSS/VisualViewport.cpp | 2 +- Libraries/LibWeb/Clipboard/Clipboard.cpp | 2 +- Libraries/LibWeb/Clipboard/ClipboardEvent.cpp | 2 +- Libraries/LibWeb/Crypto/Crypto.cpp | 2 +- Libraries/LibWeb/Crypto/CryptoKey.cpp | 6 +- Libraries/LibWeb/Crypto/KeyAlgorithms.cpp | 10 +- Libraries/LibWeb/Crypto/SubtleCrypto.cpp | 2 +- Libraries/LibWeb/DOM/AbortController.cpp | 2 +- Libraries/LibWeb/DOM/AbortSignal.cpp | 2 +- .../LibWeb/DOM/AccessibilityTreeNode.cpp | 2 +- Libraries/LibWeb/DOM/Attr.cpp | 6 +- Libraries/LibWeb/DOM/Comment.cpp | 2 +- Libraries/LibWeb/DOM/CustomEvent.cpp | 2 +- Libraries/LibWeb/DOM/DOMImplementation.cpp | 6 +- Libraries/LibWeb/DOM/DOMTokenList.cpp | 2 +- Libraries/LibWeb/DOM/Document.cpp | 20 +- Libraries/LibWeb/DOM/DocumentFragment.cpp | 2 +- Libraries/LibWeb/DOM/DocumentLoading.cpp | 6 +- Libraries/LibWeb/DOM/DocumentType.cpp | 2 +- Libraries/LibWeb/DOM/EditingHostManager.cpp | 4 +- Libraries/LibWeb/DOM/Element.cpp | 6 +- Libraries/LibWeb/DOM/ElementFactory.cpp | 210 +++++++++--------- Libraries/LibWeb/DOM/Event.cpp | 4 +- Libraries/LibWeb/DOM/EventTarget.cpp | 2 +- Libraries/LibWeb/DOM/HTMLCollection.cpp | 2 +- Libraries/LibWeb/DOM/IDLEventListener.cpp | 2 +- Libraries/LibWeb/DOM/LiveNodeList.cpp | 2 +- Libraries/LibWeb/DOM/MutationObserver.cpp | 2 +- Libraries/LibWeb/DOM/MutationRecord.cpp | 2 +- Libraries/LibWeb/DOM/NamedNodeMap.cpp | 2 +- Libraries/LibWeb/DOM/Node.cpp | 14 +- Libraries/LibWeb/DOM/NodeFilter.cpp | 2 +- Libraries/LibWeb/DOM/NodeIterator.cpp | 2 +- Libraries/LibWeb/DOM/NodeOperations.cpp | 4 +- Libraries/LibWeb/DOM/Position.h | 2 +- Libraries/LibWeb/DOM/Range.cpp | 12 +- Libraries/LibWeb/DOM/StaticNodeList.cpp | 2 +- Libraries/LibWeb/DOM/StaticRange.cpp | 2 +- Libraries/LibWeb/DOM/Text.cpp | 4 +- Libraries/LibWeb/DOM/TreeWalker.cpp | 2 +- Libraries/LibWeb/DOM/XMLDocument.cpp | 2 +- Libraries/LibWeb/DOMParsing/XMLSerializer.cpp | 2 +- Libraries/LibWeb/DOMURL/DOMURL.cpp | 2 +- Libraries/LibWeb/DOMURL/URLSearchParams.cpp | 2 +- .../LibWeb/DOMURL/URLSearchParamsIterator.cpp | 4 +- Libraries/LibWeb/Encoding/TextDecoder.cpp | 2 +- Libraries/LibWeb/Encoding/TextEncoder.cpp | 2 +- .../LibWeb/EntriesAPI/FileSystemEntry.cpp | 2 +- Libraries/LibWeb/Fetch/BodyInit.cpp | 2 +- Libraries/LibWeb/Fetch/Fetching/Fetching.cpp | 6 +- Libraries/LibWeb/Fetch/Headers.cpp | 2 +- Libraries/LibWeb/Fetch/HeadersIterator.cpp | 4 +- .../Fetch/Infrastructure/HTTP/Bodies.cpp | 2 +- Libraries/LibWeb/Fetch/Request.cpp | 8 +- Libraries/LibWeb/Fetch/Response.cpp | 8 +- Libraries/LibWeb/FileAPI/Blob.cpp | 10 +- Libraries/LibWeb/FileAPI/File.cpp | 4 +- Libraries/LibWeb/FileAPI/FileList.cpp | 2 +- Libraries/LibWeb/FileAPI/FileReader.cpp | 2 +- Libraries/LibWeb/Geometry/DOMMatrix.cpp | 28 +-- .../LibWeb/Geometry/DOMMatrixReadOnly.cpp | 26 +-- Libraries/LibWeb/Geometry/DOMPoint.cpp | 4 +- .../LibWeb/Geometry/DOMPointReadOnly.cpp | 4 +- Libraries/LibWeb/Geometry/DOMQuad.cpp | 4 +- Libraries/LibWeb/Geometry/DOMRect.cpp | 6 +- Libraries/LibWeb/Geometry/DOMRectList.cpp | 2 +- Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp | 6 +- .../HTML/AnimatedBitmapDecodedImageData.cpp | 2 +- Libraries/LibWeb/HTML/BeforeUnloadEvent.cpp | 2 +- Libraries/LibWeb/HTML/BroadcastChannel.cpp | 2 +- Libraries/LibWeb/HTML/BrowsingContext.cpp | 2 +- Libraries/LibWeb/HTML/CanvasGradient.cpp | 6 +- Libraries/LibWeb/HTML/CanvasPattern.cpp | 2 +- .../LibWeb/HTML/CanvasRenderingContext2D.cpp | 2 +- Libraries/LibWeb/HTML/CloseEvent.cpp | 2 +- Libraries/LibWeb/HTML/CloseWatcher.cpp | 2 +- Libraries/LibWeb/HTML/CloseWatcherManager.cpp | 2 +- .../CustomElements/CustomElementDefinition.h | 2 +- Libraries/LibWeb/HTML/DOMParser.cpp | 2 +- Libraries/LibWeb/HTML/DOMStringList.cpp | 2 +- Libraries/LibWeb/HTML/DOMStringMap.cpp | 2 +- Libraries/LibWeb/HTML/DataTransfer.cpp | 4 +- Libraries/LibWeb/HTML/DataTransferItem.cpp | 2 +- .../LibWeb/HTML/DataTransferItemList.cpp | 2 +- Libraries/LibWeb/HTML/DragEvent.cpp | 2 +- Libraries/LibWeb/HTML/ElementInternals.cpp | 2 +- Libraries/LibWeb/HTML/ErrorEvent.cpp | 2 +- Libraries/LibWeb/HTML/EventSource.cpp | 2 +- Libraries/LibWeb/HTML/FormDataEvent.cpp | 2 +- Libraries/LibWeb/HTML/HTMLAllCollection.cpp | 2 +- Libraries/LibWeb/HTML/HTMLDetailsElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLDocument.cpp | 2 +- Libraries/LibWeb/HTML/HTMLElement.cpp | 2 +- .../HTML/HTMLFormControlsCollection.cpp | 2 +- Libraries/LibWeb/HTML/HTMLInputElement.cpp | 19 +- Libraries/LibWeb/HTML/HTMLMediaElement.cpp | 25 +-- Libraries/LibWeb/HTML/HTMLMeterElement.cpp | 2 +- .../LibWeb/HTML/HTMLOptionsCollection.cpp | 2 +- Libraries/LibWeb/HTML/HTMLProgressElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLTemplateElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp | 6 +- Libraries/LibWeb/HTML/HashChangeEvent.cpp | 4 +- Libraries/LibWeb/HTML/History.cpp | 2 +- Libraries/LibWeb/HTML/ImageBitmap.cpp | 2 +- Libraries/LibWeb/HTML/ImageData.cpp | 4 +- Libraries/LibWeb/HTML/ImageRequest.cpp | 2 +- Libraries/LibWeb/HTML/MessageChannel.cpp | 2 +- Libraries/LibWeb/HTML/MessageEvent.cpp | 2 +- Libraries/LibWeb/HTML/MessagePort.cpp | 2 +- Libraries/LibWeb/HTML/NavigateEvent.cpp | 2 +- Libraries/LibWeb/HTML/Navigation.cpp | 2 +- .../NavigationCurrentEntryChangeEvent.cpp | 2 +- .../LibWeb/HTML/NavigationDestination.cpp | 2 +- .../LibWeb/HTML/NavigationHistoryEntry.cpp | 2 +- .../LibWeb/HTML/NavigationTransition.cpp | 2 +- Libraries/LibWeb/HTML/Navigator.cpp | 14 +- Libraries/LibWeb/HTML/PageTransitionEvent.cpp | 2 +- Libraries/LibWeb/HTML/Parser/HTMLParser.cpp | 20 +- Libraries/LibWeb/HTML/Path2D.cpp | 2 +- Libraries/LibWeb/HTML/PopStateEvent.cpp | 4 +- .../LibWeb/HTML/PromiseRejectionEvent.cpp | 2 +- Libraries/LibWeb/HTML/RadioNodeList.cpp | 2 +- .../LibWeb/HTML/Scripting/Environments.cpp | 2 +- .../HTML/Scripting/ImportMapParseResult.cpp | 2 +- .../LibWeb/HTML/Scripting/ModuleScript.cpp | 2 +- .../WindowEnvironmentSettingsObject.cpp | 4 +- .../WorkerEnvironmentSettingsObject.cpp | 4 +- Libraries/LibWeb/HTML/ServiceWorker.cpp | 2 +- .../LibWeb/HTML/ServiceWorkerContainer.cpp | 2 +- .../LibWeb/HTML/ServiceWorkerRegistration.cpp | 2 +- .../LibWeb/HTML/ShadowRealmGlobalScope.cpp | 2 +- .../LibWeb/HTML/SharedResourceRequest.cpp | 2 +- Libraries/LibWeb/HTML/Storage.cpp | 2 +- Libraries/LibWeb/HTML/SubmitEvent.cpp | 2 +- Libraries/LibWeb/HTML/TextMetrics.cpp | 2 +- Libraries/LibWeb/HTML/TextTrack.cpp | 2 +- Libraries/LibWeb/HTML/ToggleEvent.cpp | 2 +- Libraries/LibWeb/HTML/TrackEvent.cpp | 2 +- Libraries/LibWeb/HTML/UserActivation.cpp | 2 +- Libraries/LibWeb/HTML/Window.cpp | 42 ++-- .../LibWeb/HTML/WindowOrWorkerGlobalScope.cpp | 9 +- Libraries/LibWeb/HTML/Worker.cpp | 4 +- Libraries/LibWeb/HTML/WorkerNavigator.cpp | 6 +- .../LibWeb/HighResolutionTime/Performance.cpp | 6 +- Libraries/LibWeb/IndexedDB/IDBDatabase.cpp | 2 +- .../LibWeb/IndexedDB/IDBOpenDBRequest.cpp | 2 +- .../IndexedDB/IDBVersionChangeEvent.cpp | 2 +- .../LibWeb/IndexedDB/Internal/Database.cpp | 2 +- Libraries/LibWeb/Internals/Internals.cpp | 2 +- .../IntersectionObserver.cpp | 2 +- .../IntersectionObserverEntry.cpp | 2 +- Libraries/LibWeb/Layout/TreeBuilder.cpp | 2 +- .../MediaCapabilities.cpp | 2 +- .../BufferedChangeEvent.cpp | 2 +- .../ManagedMediaSource.cpp | 2 +- .../MediaSourceExtensions/MediaSource.cpp | 2 +- .../PerformanceObserver.cpp | 2 +- .../RequestIdleCallback/IdleDeadline.cpp | 2 +- .../ResizeObserver/ResizeObservation.cpp | 4 +- .../LibWeb/ResizeObserver/ResizeObserver.cpp | 2 +- .../ResizeObserver/ResizeObserverEntry.cpp | 2 +- .../ResizeObserver/ResizeObserverSize.cpp | 2 +- Libraries/LibWeb/SVG/SVGAnimatedLength.cpp | 2 +- Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp | 2 +- Libraries/LibWeb/SVG/SVGAnimatedString.cpp | 2 +- .../LibWeb/SVG/SVGAnimatedTransformList.cpp | 2 +- Libraries/LibWeb/SVG/SVGDecodedImageData.cpp | 2 +- Libraries/LibWeb/SVG/SVGLength.cpp | 2 +- Libraries/LibWeb/SVG/SVGSVGElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGSymbolElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGTransform.cpp | 2 +- Libraries/LibWeb/SVG/SVGTransformList.cpp | 2 +- Libraries/LibWeb/SVG/SVGUseElement.cpp | 4 +- Libraries/LibWeb/Selection/Selection.cpp | 2 +- .../LibWeb/StorageAPI/StorageManager.cpp | 2 +- .../LibWeb/Streams/AbstractOperations.cpp | 50 ++--- .../Streams/ByteLengthQueuingStrategy.cpp | 2 +- .../LibWeb/Streams/CountQueuingStrategy.cpp | 2 +- Libraries/LibWeb/Streams/ReadableStream.cpp | 2 +- .../Streams/ReadableStreamBYOBReader.cpp | 2 +- .../Streams/ReadableStreamDefaultReader.cpp | 2 +- Libraries/LibWeb/Streams/TransformStream.cpp | 2 +- Libraries/LibWeb/Streams/WritableStream.cpp | 2 +- .../Streams/WritableStreamDefaultWriter.cpp | 2 +- .../LibWeb/UIEvents/CompositionEvent.cpp | 4 +- Libraries/LibWeb/UIEvents/FocusEvent.cpp | 2 +- Libraries/LibWeb/UIEvents/InputEvent.cpp | 4 +- Libraries/LibWeb/UIEvents/KeyboardEvent.cpp | 2 +- Libraries/LibWeb/UIEvents/MouseEvent.cpp | 2 +- Libraries/LibWeb/UIEvents/PointerEvent.cpp | 2 +- Libraries/LibWeb/UIEvents/TextEvent.cpp | 2 +- Libraries/LibWeb/UIEvents/UIEvent.cpp | 4 +- Libraries/LibWeb/UIEvents/WheelEvent.cpp | 2 +- .../LibWeb/UserTiming/PerformanceMark.cpp | 2 +- .../LibWeb/UserTiming/PerformanceMeasure.cpp | 2 +- Libraries/LibWeb/WebAssembly/Instance.cpp | 6 +- Libraries/LibWeb/WebAssembly/Memory.cpp | 2 +- Libraries/LibWeb/WebAssembly/Module.cpp | 2 +- Libraries/LibWeb/WebAssembly/Table.cpp | 2 +- Libraries/LibWeb/WebAssembly/WebAssembly.cpp | 10 +- Libraries/LibWeb/WebAudio/AudioBuffer.cpp | 4 +- .../LibWeb/WebAudio/AudioBufferSourceNode.cpp | 2 +- Libraries/LibWeb/WebAudio/AudioContext.cpp | 2 +- .../LibWeb/WebAudio/AudioDestinationNode.cpp | 2 +- Libraries/LibWeb/WebAudio/AudioListener.cpp | 2 +- Libraries/LibWeb/WebAudio/AudioParam.cpp | 2 +- .../LibWeb/WebAudio/BiquadFilterNode.cpp | 3 +- .../WebAudio/DynamicsCompressorNode.cpp | 2 +- Libraries/LibWeb/WebAudio/GainNode.cpp | 2 +- .../LibWeb/WebAudio/OfflineAudioContext.cpp | 2 +- Libraries/LibWeb/WebAudio/OscillatorNode.cpp | 2 +- Libraries/LibWeb/WebDriver/ExecuteScript.cpp | 4 +- Libraries/LibWeb/WebGL/WebGLContextEvent.cpp | 2 +- .../LibWeb/WebGL/WebGLRenderingContext.cpp | 2 +- Libraries/LibWeb/WebIDL/DOMException.cpp | 4 +- Libraries/LibWeb/WebIDL/ObservableArray.cpp | 2 +- Libraries/LibWeb/WebIDL/Promise.cpp | 2 +- Libraries/LibWeb/WebSockets/WebSocket.cpp | 2 +- Libraries/LibWeb/WebVTT/VTTCue.cpp | 2 +- Libraries/LibWeb/WebVTT/VTTRegion.cpp | 2 +- Libraries/LibWeb/XHR/FormData.cpp | 2 +- Libraries/LibWeb/XHR/FormDataIterator.cpp | 4 +- Libraries/LibWeb/XHR/ProgressEvent.cpp | 2 +- Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 4 +- .../BindingsGenerator/IDLGenerators.cpp | 8 +- .../GenerateWindowOrWorkerInterfaces.cpp | 10 +- Services/WebContent/ConnectionFromClient.cpp | 2 +- .../WebContent/WebContentConsoleClient.cpp | 2 +- Services/WebContent/WebDriverConnection.cpp | 22 +- Services/WebWorker/DedicatedWorkerHost.cpp | 4 +- Tests/LibWasm/test-wasm.cpp | 2 +- 326 files changed, 697 insertions(+), 714 deletions(-) diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index bbf67490750..ff3d2304f5e 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -1742,7 +1742,7 @@ inline ThrowCompletionOr get_object_property_iterator(VM& vm, Value val } }, 1, vm.names.next); - return vm.heap().allocate(realm, realm, object, callback, false).ptr(); + return realm.create(realm, object, callback, false).ptr(); } ByteString Instruction::to_byte_string(Bytecode::Executable const& executable) const diff --git a/Libraries/LibJS/Contrib/Test262/262Object.cpp b/Libraries/LibJS/Contrib/Test262/262Object.cpp index c8d01eeba76..5b1a1c477f9 100644 --- a/Libraries/LibJS/Contrib/Test262/262Object.cpp +++ b/Libraries/LibJS/Contrib/Test262/262Object.cpp @@ -32,8 +32,8 @@ void $262Object::initialize(Realm& realm) { Base::initialize(realm); - m_agent = vm().heap().allocate(realm, realm); - m_is_htmldda = vm().heap().allocate(realm, realm); + m_agent = realm.create(realm); + m_is_htmldda = realm.create(realm); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr); diff --git a/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp index 4bb637c18dd..3755a5d335d 100644 --- a/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp +++ b/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp @@ -20,7 +20,7 @@ void GlobalObject::initialize(Realm& realm) { Base::initialize(realm); - m_$262 = vm().heap().allocate<$262Object>(realm, realm); + m_$262 = realm.create<$262Object>(realm); // https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions u8 attr = Attribute::Writable | Attribute::Configurable; diff --git a/Libraries/LibJS/Heap/Heap.h b/Libraries/LibJS/Heap/Heap.h index ac1f08520fb..7e75d0eac64 100644 --- a/Libraries/LibJS/Heap/Heap.h +++ b/Libraries/LibJS/Heap/Heap.h @@ -45,18 +45,6 @@ public: return *static_cast(memory); } - template - NonnullGCPtr allocate(Realm& realm, Args&&... args) - { - auto* memory = allocate_cell(); - defer_gc(); - new (memory) T(forward(args)...); - undefer_gc(); - auto* cell = static_cast(memory); - memory->initialize(realm); - return *cell; - } - enum class CollectionType { CollectGarbage, CollectEverything, diff --git a/Libraries/LibJS/Module.cpp b/Libraries/LibJS/Module.cpp index 2523f56aeec..b4d7e6fdc13 100644 --- a/Libraries/LibJS/Module.cpp +++ b/Libraries/LibJS/Module.cpp @@ -147,7 +147,7 @@ ThrowCompletionOr Module::get_module_namespace(VM& vm) } // d. Set namespace to ModuleNamespaceCreate(module, unambiguousNames). - namespace_ = module_namespace_create(vm, unambiguous_names); + namespace_ = module_namespace_create(unambiguous_names); VERIFY(m_namespace); // Note: This set the local variable 'namespace' and not the member variable which is done by ModuleNamespaceCreate } @@ -157,7 +157,7 @@ ThrowCompletionOr Module::get_module_namespace(VM& vm) } // 10.4.6.12 ModuleNamespaceCreate ( module, exports ), https://tc39.es/ecma262/#sec-modulenamespacecreate -Object* Module::module_namespace_create(VM& vm, Vector unambiguous_names) +Object* Module::module_namespace_create(Vector unambiguous_names) { auto& realm = this->realm(); @@ -171,7 +171,7 @@ Object* Module::module_namespace_create(VM& vm, Vector unam // 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. - auto module_namespace = vm.heap().allocate(realm, realm, this, move(unambiguous_names)); + auto module_namespace = realm.create(realm, this, move(unambiguous_names)); // 9. Set module.[[Namespace]] to M. m_namespace = make_handle(module_namespace); diff --git a/Libraries/LibJS/Module.h b/Libraries/LibJS/Module.h index 2758fb19243..8a4119dd6ca 100644 --- a/Libraries/LibJS/Module.h +++ b/Libraries/LibJS/Module.h @@ -128,7 +128,7 @@ protected: } private: - Object* module_namespace_create(VM& vm, Vector unambiguous_names); + Object* module_namespace_create(Vector unambiguous_names); // These handles are only safe as long as the VM they live in is valid. // But evaluated modules SHOULD be stored in the VM so unless you intentionally diff --git a/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Libraries/LibJS/Runtime/AbstractOperations.cpp index 44be8debd4b..83dbf6021c8 100644 --- a/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -1087,7 +1087,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 = realm.create(realm, environment); // 14. Let index be 0. // 15. Repeat, while index < len, diff --git a/Libraries/LibJS/Runtime/AbstractOperations.h b/Libraries/LibJS/Runtime/AbstractOperations.h index 63ad0c8bd2b..ebcb044a67a 100644 --- a/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Libraries/LibJS/Runtime/AbstractOperations.h @@ -147,7 +147,7 @@ ThrowCompletionOr> ordinary_create_from_constructor(VM& vm, Func { 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.create(forward(args)..., *prototype); } // 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists diff --git a/Libraries/LibJS/Runtime/AggregateError.cpp b/Libraries/LibJS/Runtime/AggregateError.cpp index 1ad94ba7f50..752b238b67d 100644 --- a/Libraries/LibJS/Runtime/AggregateError.cpp +++ b/Libraries/LibJS/Runtime/AggregateError.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(AggregateError); NonnullGCPtr AggregateError::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().aggregate_error_prototype()); + return realm.create(realm.intrinsics().aggregate_error_prototype()); } AggregateError::AggregateError(Object& prototype) diff --git a/Libraries/LibJS/Runtime/Array.cpp b/Libraries/LibJS/Runtime/Array.cpp index d5409a1edb1..fed5cb8bbc4 100644 --- a/Libraries/LibJS/Runtime/Array.cpp +++ b/Libraries/LibJS/Runtime/Array.cpp @@ -35,7 +35,7 @@ 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.create(*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 })); diff --git a/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Libraries/LibJS/Runtime/ArrayBuffer.cpp index 8629dbf8c36..853e00b8c41 100644 --- a/Libraries/LibJS/Runtime/ArrayBuffer.cpp +++ b/Libraries/LibJS/Runtime/ArrayBuffer.cpp @@ -19,17 +19,17 @@ ThrowCompletionOr> ArrayBuffer::create(Realm& realm, s if (buffer.is_error()) return realm.vm().throw_completion(ErrorType::NotEnoughMemoryToAllocate, byte_length); - return realm.heap().allocate(realm, buffer.release_value(), realm.intrinsics().array_buffer_prototype()); + return realm.create(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.create(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.create(buffer, realm.intrinsics().array_buffer_prototype()); } ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype) diff --git a/Libraries/LibJS/Runtime/ArrayIterator.cpp b/Libraries/LibJS/Runtime/ArrayIterator.cpp index fa58eef5c56..27db58465c7 100644 --- a/Libraries/LibJS/Runtime/ArrayIterator.cpp +++ b/Libraries/LibJS/Runtime/ArrayIterator.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(ArrayIterator); 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.create(array, iteration_kind, realm.intrinsics().array_iterator_prototype()); } ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp index aaf49e68488..aa0773a33f7 100644 --- a/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp +++ b/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(AsyncFromSyncIterator); NonnullGCPtr AsyncFromSyncIterator::create(Realm& realm, NonnullGCPtr sync_iterator_record) { - return realm.heap().allocate(realm, realm, sync_iterator_record); + return realm.create(realm, sync_iterator_record); } AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, NonnullGCPtr sync_iterator_record) diff --git a/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp b/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp index e334ce66de4..e80231f8ed0 100644 --- a/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp +++ b/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp @@ -211,7 +211,7 @@ NonnullGCPtr create_async_from_sync_iterator(VM& vm, NonnullGCPt auto next_method = MUST(async_iterator->get(vm.names.next)); // 4. Let iteratorRecord be the Iterator Record { [[Iterator]]: asyncIterator, [[NextMethod]]: nextMethod, [[Done]]: false }. - auto iterator_record = vm.heap().allocate(realm, realm, async_iterator, next_method, false); + auto iterator_record = realm.create(realm, async_iterator, next_method, false); // 5. Return iteratorRecord. return iterator_record; diff --git a/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp b/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp index d5dd9ef1c9d..45fc34caac1 100644 --- a/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp +++ b/Libraries/LibJS/Runtime/AsyncFunctionDriverWrapper.cpp @@ -21,7 +21,7 @@ NonnullGCPtr AsyncFunctionDriverWrapper::create(Realm& realm, Generator { auto top_level_promise = Promise::create(realm); // Note: The top_level_promise is also kept alive by this Wrapper - auto wrapper = realm.heap().allocate(realm, realm, *generator_object, *top_level_promise); + auto wrapper = realm.create(realm, *generator_object, *top_level_promise); // Prime the generator: // This runs until the first `await value;` wrapper->continue_async_execution(realm.vm(), js_undefined(), true, IsInitialExecution::Yes); diff --git a/Libraries/LibJS/Runtime/AsyncGenerator.cpp b/Libraries/LibJS/Runtime/AsyncGenerator.cpp index 74e8e985f83..3e2cf55e97b 100644 --- a/Libraries/LibJS/Runtime/AsyncGenerator.cpp +++ b/Libraries/LibJS/Runtime/AsyncGenerator.cpp @@ -22,7 +22,7 @@ ThrowCompletionOr> AsyncGenerator::create(Realm& re // This is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png) auto generating_function_prototype = TRY(generating_function->get(vm.names.prototype)); auto generating_function_prototype_object = TRY(generating_function_prototype.to_object(vm)); - auto object = realm.heap().allocate(realm, realm, generating_function_prototype_object, move(execution_context)); + auto object = realm.create(realm, generating_function_prototype_object, move(execution_context)); object->m_generating_function = generating_function; object->m_previous_value = initial_value; return object; diff --git a/Libraries/LibJS/Runtime/BigIntObject.cpp b/Libraries/LibJS/Runtime/BigIntObject.cpp index 233e0c7329f..8857efc9ede 100644 --- a/Libraries/LibJS/Runtime/BigIntObject.cpp +++ b/Libraries/LibJS/Runtime/BigIntObject.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(BigIntObject); NonnullGCPtr BigIntObject::create(Realm& realm, BigInt& bigint) { - return realm.heap().allocate(realm, bigint, realm.intrinsics().bigint_prototype()); + return realm.create(bigint, realm.intrinsics().bigint_prototype()); } BigIntObject::BigIntObject(BigInt& bigint, Object& prototype) diff --git a/Libraries/LibJS/Runtime/BooleanObject.cpp b/Libraries/LibJS/Runtime/BooleanObject.cpp index a357c94c062..5df3cf39e1c 100644 --- a/Libraries/LibJS/Runtime/BooleanObject.cpp +++ b/Libraries/LibJS/Runtime/BooleanObject.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(BooleanObject); NonnullGCPtr BooleanObject::create(Realm& realm, bool value) { - return realm.heap().allocate(realm, value, realm.intrinsics().boolean_prototype()); + return realm.create(value, realm.intrinsics().boolean_prototype()); } BooleanObject::BooleanObject(bool value, Object& prototype) diff --git a/Libraries/LibJS/Runtime/BoundFunction.cpp b/Libraries/LibJS/Runtime/BoundFunction.cpp index ca1c9c4b331..7b416092c19 100644 --- a/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -28,7 +28,7 @@ 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.create(realm, target_function, bound_this, move(bound_arguments), prototype); // 10. Return obj. return object; diff --git a/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Libraries/LibJS/Runtime/ConsoleObject.cpp index 98fee368fa9..ba27247212a 100644 --- a/Libraries/LibJS/Runtime/ConsoleObject.cpp +++ b/Libraries/LibJS/Runtime/ConsoleObject.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(ConsoleObject); static NonnullGCPtr create_console_prototype(Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } ConsoleObject::ConsoleObject(Realm& realm) @@ -37,7 +37,7 @@ void ConsoleObject::initialize(Realm& realm) { auto& vm = this->vm(); Base::initialize(realm); - m_console = vm.heap().allocate(realm, realm); + m_console = realm.create(realm); u8 attr = Attribute::Writable | Attribute::Enumerable | Attribute::Configurable; define_native_function(realm, vm.names.assert, assert_, 0, attr); define_native_function(realm, vm.names.clear, clear, 0, attr); diff --git a/Libraries/LibJS/Runtime/DataView.cpp b/Libraries/LibJS/Runtime/DataView.cpp index 760b054d3a0..232eed3df42 100644 --- a/Libraries/LibJS/Runtime/DataView.cpp +++ b/Libraries/LibJS/Runtime/DataView.cpp @@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(DataView); NonnullGCPtr DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, ByteLength byte_length, size_t byte_offset) { - return realm.heap().allocate(realm, viewed_buffer, move(byte_length), byte_offset, realm.intrinsics().data_view_prototype()); + return realm.create(viewed_buffer, move(byte_length), byte_offset, realm.intrinsics().data_view_prototype()); } DataView::DataView(ArrayBuffer* viewed_buffer, ByteLength byte_length, size_t byte_offset, Object& prototype) diff --git a/Libraries/LibJS/Runtime/Date.cpp b/Libraries/LibJS/Runtime/Date.cpp index 1623c48a356..0334ad3168e 100644 --- a/Libraries/LibJS/Runtime/Date.cpp +++ b/Libraries/LibJS/Runtime/Date.cpp @@ -27,7 +27,7 @@ Crypto::SignedBigInteger const ns_per_day_bigint { static_cast(ns_per_day) NonnullGCPtr Date::create(Realm& realm, double date_value) { - return realm.heap().allocate(realm, date_value, realm.intrinsics().date_prototype()); + return realm.create(date_value, realm.intrinsics().date_prototype()); } Date::Date(double date_value, Object& prototype) diff --git a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 793f5f6a1b0..8508c78d0ec 100644 --- a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -50,12 +50,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, move(local_variables_names), parent_environment, private_environment, *prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name)); + return realm.create(move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, *prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name)); } NonnullGCPtr ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, ByteString source_text, Statement const& ecmascript_code, Vector parameters, i32 m_function_length, Vector local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, FunctionParsingInsights parsing_insights, 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, move(local_variables_names), parent_environment, private_environment, prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name)); + return realm.create(move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, prototype, kind, is_strict, parsing_insights, is_arrow_function, move(class_field_initializer_name)); } ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector formal_parameters, i32 function_length, Vector local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, FunctionParsingInsights parsing_insights, bool is_arrow_function, Variant class_field_initializer_name) diff --git a/Libraries/LibJS/Runtime/Error.cpp b/Libraries/LibJS/Runtime/Error.cpp index eee4d9c55d5..4198a7f4ef6 100644 --- a/Libraries/LibJS/Runtime/Error.cpp +++ b/Libraries/LibJS/Runtime/Error.cpp @@ -36,7 +36,7 @@ SourceRange const& TracebackFrame::source_range() const NonnullGCPtr Error::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().error_prototype()); + return realm.create(realm.intrinsics().error_prototype()); } NonnullGCPtr Error::create(Realm& realm, String message) @@ -160,7 +160,7 @@ String Error::stack_string(CompactTraceback compact) const JS_DEFINE_ALLOCATOR(ClassName); \ NonnullGCPtr ClassName::create(Realm& realm) \ { \ - return realm.heap().allocate(realm, realm.intrinsics().snake_name##_prototype()); \ + return realm.create(realm.intrinsics().snake_name##_prototype()); \ } \ \ NonnullGCPtr ClassName::create(Realm& realm, String message) \ diff --git a/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Libraries/LibJS/Runtime/GeneratorObject.cpp index b724bf4cd34..75798ce6fce 100644 --- a/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -30,7 +30,7 @@ ThrowCompletionOr> GeneratorObject::create(Realm& generating_function_prototype = TRY(generating_function->get(vm.names.prototype)); } auto generating_function_prototype_object = TRY(generating_function_prototype.to_object(vm)); - auto object = realm.heap().allocate(realm, realm, generating_function_prototype_object, move(execution_context)); + auto object = realm.create(realm, generating_function_prototype_object, move(execution_context)); object->m_generating_function = generating_function; object->m_previous_value = initial_value; return object; diff --git a/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index 7246cb3601f..ea986787bd9 100644 --- a/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CollatorCompareFunction); NonnullGCPtr CollatorCompareFunction::create(Realm& realm, Collator& collator) { - return realm.heap().allocate(realm, realm, collator); + return realm.create(realm, collator); } CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator) diff --git a/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp index ffc12808b9b..abb869d468f 100644 --- a/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp +++ b/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(DateTimeFormatFunction); // 11.5.4 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.create(date_time_format, realm.intrinsics().function_prototype()); } DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype) diff --git a/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Libraries/LibJS/Runtime/Intl/Locale.cpp index c10f3ec6d5c..83a7cb25646 100644 --- a/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(Locale); NonnullGCPtr Locale::create(Realm& realm, NonnullGCPtr source_locale, String locale_tag) { - auto locale = realm.heap().allocate(realm, realm.intrinsics().intl_locale_prototype()); + auto locale = realm.create(realm.intrinsics().intl_locale_prototype()); locale->set_locale(move(locale_tag)); locale->m_calendar = source_locale->m_calendar; diff --git a/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index 737a50c0b6a..488a35ec69b 100644 --- a/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(NumberFormatFunction); // 15.5.2 Number Format Functions, https://tc39.es/ecma402/#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.create(number_format, realm.intrinsics().function_prototype()); } NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype) diff --git a/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp index b509beafaa3..3ea77f5e882 100644 --- a/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp +++ b/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp @@ -21,7 +21,7 @@ NonnullGCPtr SegmentIterator::create(Realm& realm, Unicode::Seg // 4. Set iterator.[[IteratedString]] to string. // 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0. // 6. Return iterator. - return realm.heap().allocate(realm, realm, segmenter, string, segments); + return realm.create(realm, segmenter, string, segments); } // 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects diff --git a/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Libraries/LibJS/Runtime/Intl/Segments.cpp index 7b7db25e0cc..51d7f6001c7 100644 --- a/Libraries/LibJS/Runtime/Intl/Segments.cpp +++ b/Libraries/LibJS/Runtime/Intl/Segments.cpp @@ -20,7 +20,7 @@ NonnullGCPtr Segments::create(Realm& realm, Unicode::Segmenter const& // 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.create(realm, segmenter, move(string)); } // 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects diff --git a/Libraries/LibJS/Runtime/Intrinsics.cpp b/Libraries/LibJS/Runtime/Intrinsics.cpp index 9016dc4075c..75f9570f783 100644 --- a/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -198,33 +198,33 @@ ThrowCompletionOr Intrinsics::initialize_intrinsics(Realm& realm) m_iterator_result_object_value_offset = m_iterator_result_object_shape->lookup(vm.names.value.to_string_or_symbol()).value().offset; m_iterator_result_object_done_offset = m_iterator_result_object_shape->lookup(vm.names.done.to_string_or_symbol()).value().offset; - // Normally Heap::allocate() takes care of this, but these are allocated via allocate_without_realm(). + // Normally Realm::create() takes care of this, but these are allocated via Heap::allocate_without_realm(). m_function_prototype->initialize(realm); m_object_prototype->initialize(realm); #define __JS_ENUMERATE(ClassName, snake_name) \ VERIFY(!m_##snake_name##_prototype); \ - m_##snake_name##_prototype = heap().allocate(realm, realm); + m_##snake_name##_prototype = realm.create(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(realm, realm); - m_async_generator_prototype = heap().allocate(realm, realm); - m_generator_prototype = heap().allocate(realm, realm); - m_intl_segments_prototype = heap().allocate(realm, realm); - m_wrap_for_valid_iterator_prototype = heap().allocate(realm, realm); + m_async_from_sync_iterator_prototype = realm.create(realm); + m_async_generator_prototype = realm.create(realm); + m_generator_prototype = realm.create(realm); + m_intl_segments_prototype = realm.create(realm); + m_wrap_for_valid_iterator_prototype = realm.create(realm); // These must be initialized before allocating... // - AggregateErrorPrototype, which uses ErrorPrototype as its prototype // - AggregateErrorConstructor, which uses ErrorConstructor as its prototype // - AsyncFunctionConstructor, which uses FunctionConstructor as its prototype - m_error_prototype = heap().allocate(realm, realm); - m_error_constructor = heap().allocate(realm, realm); - m_function_constructor = heap().allocate(realm, realm); + m_error_prototype = realm.create(realm); + m_error_constructor = realm.create(realm); + m_function_constructor = realm.create(realm); // Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype - m_proxy_constructor = heap().allocate(realm, realm); + m_proxy_constructor = realm.create(realm); // Global object functions m_eval_function = NativeFunction::create(realm, GlobalObject::eval, 1, vm.names.eval, &realm); @@ -239,7 +239,7 @@ ThrowCompletionOr Intrinsics::initialize_intrinsics(Realm& realm) m_escape_function = NativeFunction::create(realm, GlobalObject::escape, 1, vm.names.escape, &realm); m_unescape_function = NativeFunction::create(realm, GlobalObject::unescape, 1, vm.names.unescape, &realm); - m_object_constructor = heap().allocate(realm, realm); + m_object_constructor = realm.create(realm); // 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror% m_throw_type_error_function = NativeFunction::create( @@ -292,11 +292,11 @@ JS_ENUMERATE_TYPED_ARRAYS VERIFY(!m_##snake_namespace##snake_name##_prototype); \ VERIFY(!m_##snake_namespace##snake_name##_constructor); \ if constexpr (IsTypedArrayConstructor) { \ - m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, *typed_array_prototype()); \ - m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm, *typed_array_constructor()); \ + m_##snake_namespace##snake_name##_prototype = m_realm->create(*typed_array_prototype()); \ + m_##snake_namespace##snake_name##_constructor = m_realm->create(m_realm, *typed_array_constructor()); \ } else { \ - m_##snake_namespace##snake_name##_prototype = heap().allocate(m_realm, m_realm); \ - m_##snake_namespace##snake_name##_constructor = heap().allocate(m_realm, m_realm); \ + m_##snake_namespace##snake_name##_prototype = m_realm->create(m_realm); \ + m_##snake_namespace##snake_name##_constructor = m_realm->create(m_realm); \ } \ \ /* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \ @@ -351,12 +351,12 @@ JS_ENUMERATE_TEMPORAL_OBJECTS #undef __JS_ENUMERATE_INNER -#define __JS_ENUMERATE(ClassName, snake_name) \ - NonnullGCPtr Intrinsics::snake_name##_object() \ - { \ - if (!m_##snake_name##_object) \ - m_##snake_name##_object = heap().allocate(m_realm, m_realm); \ - return *m_##snake_name##_object; \ +#define __JS_ENUMERATE(ClassName, snake_name) \ + NonnullGCPtr Intrinsics::snake_name##_object() \ + { \ + if (!m_##snake_name##_object) \ + m_##snake_name##_object = m_realm->create(m_realm); \ + return *m_##snake_name##_object; \ } JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS #undef __JS_ENUMERATE diff --git a/Libraries/LibJS/Runtime/Iterator.cpp b/Libraries/LibJS/Runtime/Iterator.cpp index 63014028875..720a71d714c 100644 --- a/Libraries/LibJS/Runtime/Iterator.cpp +++ b/Libraries/LibJS/Runtime/Iterator.cpp @@ -21,7 +21,7 @@ JS_DEFINE_ALLOCATOR(IteratorRecord); NonnullGCPtr Iterator::create(Realm& realm, Object& prototype, NonnullGCPtr iterated) { - return realm.heap().allocate(realm, prototype, move(iterated)); + return realm.create(prototype, move(iterated)); } Iterator::Iterator(Object& prototype, NonnullGCPtr iterated) @@ -31,7 +31,7 @@ Iterator::Iterator(Object& prototype, NonnullGCPtr iterated) } Iterator::Iterator(Object& prototype) - : Iterator(prototype, prototype.heap().allocate(prototype.shape().realm(), prototype.shape().realm(), nullptr, js_undefined(), false)) + : Iterator(prototype, prototype.shape().realm().create(prototype.shape().realm(), nullptr, js_undefined(), false)) { } @@ -44,7 +44,7 @@ ThrowCompletionOr> get_iterator_direct(VM& vm, Obje // 2. Let iteratorRecord be Record { [[Iterator]]: obj, [[NextMethod]]: nextMethod, [[Done]]: false }. // 3. Return iteratorRecord. auto& realm = *vm.current_realm(); - return vm.heap().allocate(realm, realm, object, next_method, false); + return realm.create(realm, object, next_method, false); } // 7.4.3 GetIteratorFromMethod ( obj, method ), https://tc39.es/ecma262/#sec-getiteratorfrommethod @@ -62,7 +62,7 @@ ThrowCompletionOr> get_iterator_from_method(VM& vm, // 4. Let iteratorRecord be the Iterator Record { [[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false }. auto& realm = *vm.current_realm(); - auto iterator_record = vm.heap().allocate(realm, realm, iterator.as_object(), next_method, false); + auto iterator_record = realm.create(realm, iterator.as_object(), next_method, false); // 5. Return iteratorRecord. return iterator_record; diff --git a/Libraries/LibJS/Runtime/IteratorHelper.cpp b/Libraries/LibJS/Runtime/IteratorHelper.cpp index 05e6bb60df5..7365f7fbacf 100644 --- a/Libraries/LibJS/Runtime/IteratorHelper.cpp +++ b/Libraries/LibJS/Runtime/IteratorHelper.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(IteratorHelper); ThrowCompletionOr> IteratorHelper::create(Realm& realm, NonnullGCPtr underlying_iterator, NonnullGCPtr closure, GCPtr abrupt_closure) { - return realm.heap().allocate(realm, realm, realm.intrinsics().iterator_helper_prototype(), move(underlying_iterator), closure, abrupt_closure); + return realm.create(realm, realm.intrinsics().iterator_helper_prototype(), move(underlying_iterator), closure, abrupt_closure); } IteratorHelper::IteratorHelper(Realm& realm, Object& prototype, NonnullGCPtr underlying_iterator, NonnullGCPtr closure, GCPtr abrupt_closure) diff --git a/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Libraries/LibJS/Runtime/IteratorPrototype.cpp index e883f2075d7..c4172fe5d12 100644 --- a/Libraries/LibJS/Runtime/IteratorPrototype.cpp +++ b/Libraries/LibJS/Runtime/IteratorPrototype.cpp @@ -413,7 +413,7 @@ JS_DEFINE_NATIVE_FUNCTION(IteratorPrototype::flat_map) // 4. Let iterated be ? GetIteratorDirect(O). auto iterated = TRY(get_iterator_direct(vm, object)); - auto flat_map_iterator = vm.heap().allocate(realm); + auto flat_map_iterator = realm.create(); // 5. Let closure be a new Abstract Closure with no parameters that captures iterated and mapper and performs the following steps when called: auto closure = JS::create_heap_function(realm.heap(), [flat_map_iterator, mapper = NonnullGCPtr { mapper.as_function() }](VM& vm, IteratorHelper& iterator) mutable -> ThrowCompletionOr { diff --git a/Libraries/LibJS/Runtime/Map.cpp b/Libraries/LibJS/Runtime/Map.cpp index 8bce2ffd17e..ef00c7f3728 100644 --- a/Libraries/LibJS/Runtime/Map.cpp +++ b/Libraries/LibJS/Runtime/Map.cpp @@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(Map); NonnullGCPtr Map::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().map_prototype()); + return realm.create(realm.intrinsics().map_prototype()); } Map::Map(Object& prototype) diff --git a/Libraries/LibJS/Runtime/MapIterator.cpp b/Libraries/LibJS/Runtime/MapIterator.cpp index b81748ab596..eb8755a2f60 100644 --- a/Libraries/LibJS/Runtime/MapIterator.cpp +++ b/Libraries/LibJS/Runtime/MapIterator.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(MapIterator); 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.create(map, iteration_kind, realm.intrinsics().map_iterator_prototype()); } MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Libraries/LibJS/Runtime/NativeFunction.cpp b/Libraries/LibJS/Runtime/NativeFunction.cpp index 9d0d2696fa5..10773e008c6 100644 --- a/Libraries/LibJS/Runtime/NativeFunction.cpp +++ b/Libraries/LibJS/Runtime/NativeFunction.cpp @@ -53,7 +53,7 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Fun // 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, JS::create_heap_function(vm.heap(), move(behaviour)), prototype.value(), *realm.value()); + auto function = allocating_realm.create(JS::create_heap_function(vm.heap(), move(behaviour)), prototype.value(), *realm.value()); // 10. Perform SetFunctionLength(func, length). function->set_function_length(length); @@ -70,7 +70,7 @@ NonnullGCPtr NativeFunction::create(Realm& allocating_realm, Fun NonnullGCPtr NativeFunction::create(Realm& realm, DeprecatedFlyString const& name, Function(VM&)> function) { - return realm.heap().allocate(realm, name, JS::create_heap_function(realm.heap(), move(function)), realm.intrinsics().function_prototype()); + return realm.create(name, JS::create_heap_function(realm.heap(), move(function)), realm.intrinsics().function_prototype()); } NativeFunction::NativeFunction(JS::GCPtr(VM&)>> native_function, Object* prototype, Realm& realm) diff --git a/Libraries/LibJS/Runtime/NumberObject.cpp b/Libraries/LibJS/Runtime/NumberObject.cpp index e8571067e54..3b1a5d6b696 100644 --- a/Libraries/LibJS/Runtime/NumberObject.cpp +++ b/Libraries/LibJS/Runtime/NumberObject.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(NumberObject); NonnullGCPtr NumberObject::create(Realm& realm, double value) { - return realm.heap().allocate(realm, value, realm.intrinsics().number_prototype()); + return realm.create(value, realm.intrinsics().number_prototype()); } NumberObject::NumberObject(double value, Object& prototype) diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index 7297744d86c..21a9cf78bc7 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -31,10 +31,10 @@ static HashMap, HashMap Object::create(Realm& realm, Object* prototype) { if (!prototype) - return realm.heap().allocate(realm, realm.intrinsics().empty_object_shape()); + return realm.create(realm.intrinsics().empty_object_shape()); if (prototype == realm.intrinsics().object_prototype()) - return realm.heap().allocate(realm, realm.intrinsics().new_object_shape()); - return realm.heap().allocate(realm, ConstructWithPrototypeTag::Tag, *prototype); + return realm.create(realm.intrinsics().new_object_shape()); + return realm.create(ConstructWithPrototypeTag::Tag, *prototype); } NonnullGCPtr Object::create_prototype(Realm& realm, Object* prototype) @@ -42,12 +42,12 @@ NonnullGCPtr Object::create_prototype(Realm& realm, Object* prototype) auto shape = realm.heap().allocate_without_realm(realm); if (prototype) shape->set_prototype_without_transition(prototype); - return realm.heap().allocate(realm, shape); + return realm.create(shape); } NonnullGCPtr Object::create_with_premade_shape(Shape& shape) { - return shape.heap().allocate(shape.realm(), shape); + return shape.realm().create(shape); } Object::Object(GlobalObjectTag, Realm& realm, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access) diff --git a/Libraries/LibJS/Runtime/Promise.cpp b/Libraries/LibJS/Runtime/Promise.cpp index 979c046604a..df000581c44 100644 --- a/Libraries/LibJS/Runtime/Promise.cpp +++ b/Libraries/LibJS/Runtime/Promise.cpp @@ -46,7 +46,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.create(realm.intrinsics().promise_prototype()); } // 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects diff --git a/Libraries/LibJS/Runtime/PromiseCapability.cpp b/Libraries/LibJS/Runtime/PromiseCapability.cpp index e87241e6d88..11d3750eb07 100644 --- a/Libraries/LibJS/Runtime/PromiseCapability.cpp +++ b/Libraries/LibJS/Runtime/PromiseCapability.cpp @@ -63,7 +63,7 @@ ThrowCompletionOr> new_promise_capability(VM& vm // 2. NOTE: C is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see 27.2.3.1). // 3. Let resolvingFunctions be the Record { [[Resolve]]: undefined, [[Reject]]: undefined }. - auto resolving_functions = vm.heap().allocate(realm); + auto resolving_functions = realm.create(); // 4. Let executorClosure be a new Abstract Closure with parameters (resolve, reject) that captures resolvingFunctions and performs the following steps when called: auto executor_closure = [resolving_functions](auto& vm) -> ThrowCompletionOr { diff --git a/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 609ae8b3cb3..02b76fae4e3 100644 --- a/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -62,7 +62,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.create(index, values, capability, remaining_elements, realm.intrinsics().function_prototype()); } PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -94,7 +94,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.create(index, values, capability, remaining_elements, realm.intrinsics().function_prototype()); } PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -135,7 +135,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.create(index, values, capability, remaining_elements, realm.intrinsics().function_prototype()); } PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr capability, RemainingElements& remaining_elements, Object& prototype) @@ -176,7 +176,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.create(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/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp b/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp index 50e61b60868..af716c176b8 100644 --- a/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp +++ b/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(PromiseResolvingFunction); 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.create(promise, already_resolved, move(function), realm.intrinsics().function_prototype()); } PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype) diff --git a/Libraries/LibJS/Runtime/ProxyObject.cpp b/Libraries/LibJS/Runtime/ProxyObject.cpp index 5eb243cb7f1..911be773627 100644 --- a/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -38,7 +38,7 @@ struct RecursionDepthUpdater { NonnullGCPtr ProxyObject::create(Realm& realm, Object& target, Object& handler) { - return realm.heap().allocate(realm, target, handler, realm.intrinsics().object_prototype()); + return realm.create(target, handler, realm.intrinsics().object_prototype()); } ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype) diff --git a/Libraries/LibJS/Runtime/Realm.h b/Libraries/LibJS/Runtime/Realm.h index d09c5cfc30b..8f8f3940c2d 100644 --- a/Libraries/LibJS/Runtime/Realm.h +++ b/Libraries/LibJS/Runtime/Realm.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,14 @@ public: virtual void visit_edges(Cell::Visitor&) { } }; + template + NonnullGCPtr create(Args&&... args) + { + auto object = heap().allocate_without_realm(forward(args)...); + static_cast(object)->initialize(*this); + return *object; + } + static ThrowCompletionOr> initialize_host_defined_realm(VM&, Function create_global_object, Function create_global_this_value); [[nodiscard]] Object& global_object() const { return *m_global_object; } diff --git a/Libraries/LibJS/Runtime/RegExpObject.cpp b/Libraries/LibJS/Runtime/RegExpObject.cpp index a9d29f0c83b..7eae7bf397b 100644 --- a/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -148,12 +148,12 @@ ThrowCompletionOr parse_regex_pattern(VM& vm, StringView pattern, bo NonnullGCPtr RegExpObject::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().regexp_prototype()); + return realm.create(realm.intrinsics().regexp_prototype()); } NonnullGCPtr RegExpObject::create(Realm& realm, Regex regex, ByteString pattern, ByteString flags) { - return realm.heap().allocate(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype()); + return realm.create(move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype()); } RegExpObject::RegExpObject(Object& prototype) diff --git a/Libraries/LibJS/Runtime/RegExpStringIterator.cpp b/Libraries/LibJS/Runtime/RegExpStringIterator.cpp index cdaa65a1132..5a62dc934ff 100644 --- a/Libraries/LibJS/Runtime/RegExpStringIterator.cpp +++ b/Libraries/LibJS/Runtime/RegExpStringIterator.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(RegExpStringIterator); // 22.2.9.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.create(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/Libraries/LibJS/Runtime/Set.cpp b/Libraries/LibJS/Runtime/Set.cpp index 4ddd57067c3..c5f020309a2 100644 --- a/Libraries/LibJS/Runtime/Set.cpp +++ b/Libraries/LibJS/Runtime/Set.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(Set); NonnullGCPtr Set::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().set_prototype()); + return realm.create(realm.intrinsics().set_prototype()); } Set::Set(Object& prototype) diff --git a/Libraries/LibJS/Runtime/SetIterator.cpp b/Libraries/LibJS/Runtime/SetIterator.cpp index 500b6b98da7..d431e8eb712 100644 --- a/Libraries/LibJS/Runtime/SetIterator.cpp +++ b/Libraries/LibJS/Runtime/SetIterator.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(SetIterator); 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.create(set, iteration_kind, realm.intrinsics().set_iterator_prototype()); } SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype) diff --git a/Libraries/LibJS/Runtime/StringIterator.cpp b/Libraries/LibJS/Runtime/StringIterator.cpp index 86c111a8d6e..3da43869a47 100644 --- a/Libraries/LibJS/Runtime/StringIterator.cpp +++ b/Libraries/LibJS/Runtime/StringIterator.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(StringIterator); NonnullGCPtr StringIterator::create(Realm& realm, String string) { - return realm.heap().allocate(realm, move(string), realm.intrinsics().string_iterator_prototype()); + return realm.create(move(string), realm.intrinsics().string_iterator_prototype()); } StringIterator::StringIterator(String string, Object& prototype) diff --git a/Libraries/LibJS/Runtime/StringObject.cpp b/Libraries/LibJS/Runtime/StringObject.cpp index 9d7a08db77f..0983ac673c5 100644 --- a/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Libraries/LibJS/Runtime/StringObject.cpp @@ -28,7 +28,7 @@ NonnullGCPtr StringObject::create(Realm& realm, PrimitiveString& p // 7. Let length be the length of value. // 8. Perform ! DefinePropertyOrThrow(S, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }). // 9. Return S. - return realm.heap().allocate(realm, primitive_string, prototype); + return realm.create(primitive_string, prototype); } StringObject::StringObject(PrimitiveString& string, Object& prototype) diff --git a/Libraries/LibJS/Runtime/SuppressedError.cpp b/Libraries/LibJS/Runtime/SuppressedError.cpp index fab9310af78..ace7f592bbf 100644 --- a/Libraries/LibJS/Runtime/SuppressedError.cpp +++ b/Libraries/LibJS/Runtime/SuppressedError.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SuppressedError); NonnullGCPtr SuppressedError::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().suppressed_error_prototype()); + return realm.create(realm.intrinsics().suppressed_error_prototype()); } SuppressedError::SuppressedError(Object& prototype) diff --git a/Libraries/LibJS/Runtime/SymbolObject.cpp b/Libraries/LibJS/Runtime/SymbolObject.cpp index 430d3e1469a..00bf20cf02f 100644 --- a/Libraries/LibJS/Runtime/SymbolObject.cpp +++ b/Libraries/LibJS/Runtime/SymbolObject.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SymbolObject); NonnullGCPtr SymbolObject::create(Realm& realm, Symbol& primitive_symbol) { - return realm.heap().allocate(realm, primitive_symbol, realm.intrinsics().symbol_prototype()); + return realm.create(primitive_symbol, realm.intrinsics().symbol_prototype()); } SymbolObject::SymbolObject(Symbol& symbol, Object& prototype) diff --git a/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Libraries/LibJS/Runtime/Temporal/Temporal.cpp index 2d6b7ab520b..df0dabfe940 100644 --- a/Libraries/LibJS/Runtime/Temporal/Temporal.cpp +++ b/Libraries/LibJS/Runtime/Temporal/Temporal.cpp @@ -38,7 +38,7 @@ void Temporal::initialize(Realm& realm) define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; - define_direct_property(vm.names.Now, heap().allocate(realm, realm), attr); + define_direct_property(vm.names.Now, realm.create(realm), attr); define_intrinsic_accessor(vm.names.Calendar, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_calendar_constructor(); }); define_intrinsic_accessor(vm.names.Duration, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_duration_constructor(); }); define_intrinsic_accessor(vm.names.Instant, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_instant_constructor(); }); diff --git a/Libraries/LibJS/Runtime/TypedArray.cpp b/Libraries/LibJS/Runtime/TypedArray.cpp index 367d793328b..254492178ad 100644 --- a/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Libraries/LibJS/Runtime/TypedArray.cpp @@ -453,7 +453,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 realm.heap().allocate(realm, *prototype, length, *array_buffer); \ + return realm.create(*prototype, length, *array_buffer); \ } \ \ ThrowCompletionOr> ClassName::create(Realm& realm, u32 length) \ @@ -464,7 +464,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.create(realm.intrinsics().snake_name##_prototype(), length, array_buffer); \ } \ \ ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \ diff --git a/Libraries/LibJS/Runtime/WeakMap.cpp b/Libraries/LibJS/Runtime/WeakMap.cpp index b7c3678a92f..bcda1710c39 100644 --- a/Libraries/LibJS/Runtime/WeakMap.cpp +++ b/Libraries/LibJS/Runtime/WeakMap.cpp @@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(WeakMap); NonnullGCPtr WeakMap::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().weak_map_prototype()); + return realm.create(realm.intrinsics().weak_map_prototype()); } WeakMap::WeakMap(Object& prototype) diff --git a/Libraries/LibJS/Runtime/WeakRef.cpp b/Libraries/LibJS/Runtime/WeakRef.cpp index 7ce7d23c54c..e78ee0bab21 100644 --- a/Libraries/LibJS/Runtime/WeakRef.cpp +++ b/Libraries/LibJS/Runtime/WeakRef.cpp @@ -12,12 +12,12 @@ JS_DEFINE_ALLOCATOR(WeakRef); NonnullGCPtr WeakRef::create(Realm& realm, Object& value) { - return realm.heap().allocate(realm, value, realm.intrinsics().weak_ref_prototype()); + return realm.create(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.create(value, realm.intrinsics().weak_ref_prototype()); } WeakRef::WeakRef(Object& value, Object& prototype) diff --git a/Libraries/LibJS/Runtime/WeakSet.cpp b/Libraries/LibJS/Runtime/WeakSet.cpp index a340c35cea2..c4ecd202649 100644 --- a/Libraries/LibJS/Runtime/WeakSet.cpp +++ b/Libraries/LibJS/Runtime/WeakSet.cpp @@ -12,7 +12,7 @@ JS_DEFINE_ALLOCATOR(WeakSet); NonnullGCPtr WeakSet::create(Realm& realm) { - return realm.heap().allocate(realm, realm.intrinsics().weak_set_prototype()); + return realm.create(realm.intrinsics().weak_set_prototype()); } WeakSet::WeakSet(Object& prototype) diff --git a/Libraries/LibJS/Runtime/WrappedFunction.cpp b/Libraries/LibJS/Runtime/WrappedFunction.cpp index 95ea71c6f06..a7b21367406 100644 --- a/Libraries/LibJS/Runtime/WrappedFunction.cpp +++ b/Libraries/LibJS/Runtime/WrappedFunction.cpp @@ -24,7 +24,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 = realm.create(caller_realm, target, prototype); // 7. Let result be CopyNameAndLength(wrapped, Target). auto result = copy_name_and_length(vm, *wrapped, target); diff --git a/Libraries/LibTest/JavaScriptTestRunner.h b/Libraries/LibTest/JavaScriptTestRunner.h index cb2bbeb00d2..ccfcb854fd8 100644 --- a/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Libraries/LibTest/JavaScriptTestRunner.h @@ -284,7 +284,7 @@ inline JSFileResult TestRunner::run_file_test(ByteString const& test_path) *g_vm, [&](JS::Realm& realm_) -> JS::GlobalObject* { realm = &realm_; - global_object = g_vm->heap().allocate(*realm, *realm); + global_object = realm->create(*realm); return global_object; }, nullptr)); diff --git a/Libraries/LibWeb/Animations/Animation.cpp b/Libraries/LibWeb/Animations/Animation.cpp index e44c50af5a5..cabaf248f52 100644 --- a/Libraries/LibWeb/Animations/Animation.cpp +++ b/Libraries/LibWeb/Animations/Animation.cpp @@ -28,7 +28,7 @@ JS_DEFINE_ALLOCATOR(Animation); JS::NonnullGCPtr Animation::create(JS::Realm& realm, JS::GCPtr effect, Optional> timeline) { // 1. Let animation be a new Animation object. - auto animation = realm.heap().allocate(realm, realm); + auto animation = realm.create(realm); // 2. Run the procedure to set the timeline of an animation on animation passing timeline as the new timeline or, if // a timeline argument is missing, passing the default document timeline of the Document associated with the diff --git a/Libraries/LibWeb/Animations/AnimationPlaybackEvent.cpp b/Libraries/LibWeb/Animations/AnimationPlaybackEvent.cpp index 73db100d4db..ff54b5041bd 100644 --- a/Libraries/LibWeb/Animations/AnimationPlaybackEvent.cpp +++ b/Libraries/LibWeb/Animations/AnimationPlaybackEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(AnimationPlaybackEvent); JS::NonnullGCPtr AnimationPlaybackEvent::create(JS::Realm& realm, FlyString const& type, AnimationPlaybackEventInit const& event_init) { - return realm.heap().allocate(realm, realm, type, event_init); + return realm.create(realm, type, event_init); } // https://www.w3.org/TR/web-animations-1/#dom-animationplaybackevent-animationplaybackevent diff --git a/Libraries/LibWeb/Animations/DocumentTimeline.cpp b/Libraries/LibWeb/Animations/DocumentTimeline.cpp index 9571c47c439..480e4e62d68 100644 --- a/Libraries/LibWeb/Animations/DocumentTimeline.cpp +++ b/Libraries/LibWeb/Animations/DocumentTimeline.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(DocumentTimeline); JS::NonnullGCPtr DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time) { - auto timeline = realm.heap().allocate(realm, realm, document, origin_time); + auto timeline = realm.create(realm, document, origin_time); auto current_time = document.last_animation_frame_timestamp(); if (!current_time.has_value()) { // The document hasn't processed an animation frame yet, so just use the exact current time diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index 7dae6b4bf01..cb6bb4fef67 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -648,7 +648,7 @@ int KeyframeEffect::composite_order(JS::NonnullGCPtr a, JS::Nonn JS::NonnullGCPtr KeyframeEffect::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } // https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-keyframeeffect @@ -658,10 +658,8 @@ WebIDL::ExceptionOr> KeyframeEffect::construct_ Optional> const& keyframes, Variant options) { - auto& vm = realm.vm(); - // 1. Create a new KeyframeEffect object, effect. - auto effect = vm.heap().allocate(realm, realm); + auto effect = realm.create(realm); // 2. Set the target element of effect to target. effect->set_target(target); @@ -721,10 +719,8 @@ WebIDL::ExceptionOr> KeyframeEffect::construct_ // https://www.w3.org/TR/web-animations-1/#dom-keyframeeffect-keyframeeffect-source WebIDL::ExceptionOr> KeyframeEffect::construct_impl(JS::Realm& realm, JS::NonnullGCPtr source) { - auto& vm = realm.vm(); - // 1. Create a new KeyframeEffect object, effect. - auto effect = vm.heap().allocate(realm, realm); + auto effect = realm.create(realm); // 2. Set the following properties of effect using the corresponding values of source: diff --git a/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Libraries/LibWeb/Bindings/MainThreadVM.cpp index bef4f939dd4..07ec5be5b5e 100644 --- a/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -585,11 +585,11 @@ ErrorOr initialize_main_thread_vm(HTML::EventLoop::Type type) .underlying_realm = realm, // 7. Set settings's module map to a new module map, initially empty. - .module_map = realm.heap().allocate(realm), + .module_map = realm.create(), }; // 8. Set realm.[[HostDefined]] to settings. - realm.set_host_defined(make(move(settings), realm.heap().allocate(realm, realm))); + realm.set_host_defined(make(move(settings), realm.create(realm))); // 9. Set realm.[[GlobalObject]] to globalObject. realm.set_global_object(global_object); diff --git a/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Libraries/LibWeb/Bindings/OptionConstructor.cpp index 3777674811c..3d5482f884f 100644 --- a/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -57,7 +57,7 @@ JS::ThrowCompletionOr> OptionConstructor::construct if (vm.argument_count() > 0) { auto text = TRY(vm.argument(0).to_string(vm)); if (!text.is_empty()) { - auto new_text_node = vm.heap().allocate(realm, document, text); + auto new_text_node = realm.create(document, text); MUST(option_element->append_child(*new_text_node)); } } diff --git a/Libraries/LibWeb/CSS/AnimationEvent.cpp b/Libraries/LibWeb/CSS/AnimationEvent.cpp index f7d79ac5e09..4cb8edd1a84 100644 --- a/Libraries/LibWeb/CSS/AnimationEvent.cpp +++ b/Libraries/LibWeb/CSS/AnimationEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(AnimationEvent); JS::NonnullGCPtr AnimationEvent::create(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init) { - return realm.heap().allocate(realm, realm, type, event_init); + return realm.create(realm, type, event_init); } WebIDL::ExceptionOr> AnimationEvent::construct_impl(JS::Realm& realm, FlyString const& type, AnimationEventInit const& event_init) diff --git a/Libraries/LibWeb/CSS/CSSAnimation.cpp b/Libraries/LibWeb/CSS/CSSAnimation.cpp index 0ec4ab3805d..c9f911f8e15 100644 --- a/Libraries/LibWeb/CSS/CSSAnimation.cpp +++ b/Libraries/LibWeb/CSS/CSSAnimation.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(CSSAnimation); JS::NonnullGCPtr CSSAnimation::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } // https://www.w3.org/TR/css-animations-2/#animation-composite-order diff --git a/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index 551c901f1ce..7eea18b7226 100644 --- a/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(CSSFontFaceRule); JS::NonnullGCPtr CSSFontFaceRule::create(JS::Realm& realm, ParsedFontFace&& font_face) { - return realm.heap().allocate(realm, realm, move(font_face)); + return realm.create(realm, move(font_face)); } CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, ParsedFontFace&& font_face) diff --git a/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Libraries/LibWeb/CSS/CSSImportRule.cpp index 0d2a7c5295d..ca251187223 100644 --- a/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -25,7 +25,7 @@ JS_DEFINE_ALLOCATOR(CSSImportRule); JS::NonnullGCPtr CSSImportRule::create(URL::URL url, DOM::Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, move(url), document); + return realm.create(move(url), document); } CSSImportRule::CSSImportRule(URL::URL url, DOM::Document& document) diff --git a/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp b/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp index a056b488528..11f44c4d9e1 100644 --- a/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp +++ b/Libraries/LibWeb/CSS/CSSKeyframeRule.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSKeyframeRule); JS::NonnullGCPtr CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::PropertyOwningCSSStyleDeclaration& declarations) { - return realm.heap().allocate(realm, realm, key, declarations); + return realm.create(realm, key, declarations); } CSSKeyframeRule::CSSKeyframeRule(JS::Realm& realm, CSS::Percentage key, PropertyOwningCSSStyleDeclaration& declarations) diff --git a/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp b/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp index 96f0ae55161..85e92a9d3fb 100644 --- a/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp +++ b/Libraries/LibWeb/CSS/CSSKeyframesRule.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(CSSKeyframesRule); JS::NonnullGCPtr CSSKeyframesRule::create(JS::Realm& realm, FlyString name, JS::NonnullGCPtr css_rules) { - return realm.heap().allocate(realm, realm, move(name), move(css_rules)); + return realm.create(realm, move(name), move(css_rules)); } CSSKeyframesRule::CSSKeyframesRule(JS::Realm& realm, FlyString name, JS::NonnullGCPtr keyframes) diff --git a/Libraries/LibWeb/CSS/CSSLayerBlockRule.cpp b/Libraries/LibWeb/CSS/CSSLayerBlockRule.cpp index f21b09a7897..5296b0f5331 100644 --- a/Libraries/LibWeb/CSS/CSSLayerBlockRule.cpp +++ b/Libraries/LibWeb/CSS/CSSLayerBlockRule.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSLayerBlockRule); JS::NonnullGCPtr CSSLayerBlockRule::create(JS::Realm& realm, FlyString name, CSSRuleList& rules) { - return realm.heap().allocate(realm, realm, move(name), rules); + return realm.create(realm, move(name), rules); } FlyString CSSLayerBlockRule::next_unique_anonymous_layer_name() diff --git a/Libraries/LibWeb/CSS/CSSLayerStatementRule.cpp b/Libraries/LibWeb/CSS/CSSLayerStatementRule.cpp index b747b163c80..f20d1aacce1 100644 --- a/Libraries/LibWeb/CSS/CSSLayerStatementRule.cpp +++ b/Libraries/LibWeb/CSS/CSSLayerStatementRule.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSLayerStatementRule); JS::NonnullGCPtr CSSLayerStatementRule::create(JS::Realm& realm, Vector name_list) { - return realm.heap().allocate(realm, realm, move(name_list)); + return realm.create(realm, move(name_list)); } CSSLayerStatementRule::CSSLayerStatementRule(JS::Realm& realm, Vector name_list) diff --git a/Libraries/LibWeb/CSS/CSSMediaRule.cpp b/Libraries/LibWeb/CSS/CSSMediaRule.cpp index 59416f89115..5bf33243770 100644 --- a/Libraries/LibWeb/CSS/CSSMediaRule.cpp +++ b/Libraries/LibWeb/CSS/CSSMediaRule.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(CSSMediaRule); JS::NonnullGCPtr CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules) { - return realm.heap().allocate(realm, realm, media_queries, rules); + return realm.create(realm, media_queries, rules); } CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rules) diff --git a/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp b/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp index 031dba102ca..0d7228432cf 100644 --- a/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp +++ b/Libraries/LibWeb/CSS/CSSNamespaceRule.cpp @@ -25,7 +25,7 @@ CSSNamespaceRule::CSSNamespaceRule(JS::Realm& realm, Optional prefix, JS::NonnullGCPtr CSSNamespaceRule::create(JS::Realm& realm, Optional prefix, FlyString namespace_uri) { - return realm.heap().allocate(realm, realm, move(prefix), move(namespace_uri)); + return realm.create(realm, move(prefix), move(namespace_uri)); } void CSSNamespaceRule::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/CSS/CSSNestedDeclarations.cpp b/Libraries/LibWeb/CSS/CSSNestedDeclarations.cpp index 6d9d3b3da93..f566495e76e 100644 --- a/Libraries/LibWeb/CSS/CSSNestedDeclarations.cpp +++ b/Libraries/LibWeb/CSS/CSSNestedDeclarations.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSNestedDeclarations); JS::NonnullGCPtr CSSNestedDeclarations::create(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration) { - return realm.heap().allocate(realm, realm, declaration); + return realm.create(realm, declaration); } CSSNestedDeclarations::CSSNestedDeclarations(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration) diff --git a/Libraries/LibWeb/CSS/CSSPropertyRule.cpp b/Libraries/LibWeb/CSS/CSSPropertyRule.cpp index 025d6a627ed..5c57fcc2837 100644 --- a/Libraries/LibWeb/CSS/CSSPropertyRule.cpp +++ b/Libraries/LibWeb/CSS/CSSPropertyRule.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSPropertyRule); JS::NonnullGCPtr CSSPropertyRule::create(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, Optional initial_value) { - return realm.heap().allocate(realm, realm, move(name), move(syntax), inherits, move(initial_value)); + return realm.create(realm, move(name), move(syntax), inherits, move(initial_value)); } CSSPropertyRule::CSSPropertyRule(JS::Realm& realm, FlyString name, FlyString syntax, bool inherits, Optional initial_value) diff --git a/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Libraries/LibWeb/CSS/CSSRuleList.cpp index 11ea56e41a0..a3173a9bf17 100644 --- a/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -23,7 +23,7 @@ JS_DEFINE_ALLOCATOR(CSSRuleList); JS::NonnullGCPtr CSSRuleList::create(JS::Realm& realm, JS::MarkedVector const& rules) { - auto rule_list = realm.heap().allocate(realm, realm); + auto rule_list = realm.create(realm); for (auto* rule : rules) rule_list->m_rules.append(*rule); return rule_list; @@ -37,7 +37,7 @@ CSSRuleList::CSSRuleList(JS::Realm& realm) JS::NonnullGCPtr CSSRuleList::create_empty(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } void CSSRuleList::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index 74b9aa2650a..f617025e93b 100644 --- a/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -39,7 +39,7 @@ JS::GCPtr CSSStyleDeclaration::parent_rule() const JS::NonnullGCPtr PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector properties, HashMap custom_properties) { - return realm.heap().allocate(realm, realm, move(properties), move(custom_properties)); + return realm.create(realm, move(properties), move(custom_properties)); } PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector properties, HashMap custom_properties) @@ -69,7 +69,7 @@ String PropertyOwningCSSStyleDeclaration::item(size_t index) const JS::NonnullGCPtr ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector properties, HashMap custom_properties) { auto& realm = element.realm(); - return realm.heap().allocate(realm, element, move(properties), move(custom_properties)); + return realm.create(element, move(properties), move(custom_properties)); } ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector properties, HashMap custom_properties) diff --git a/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Libraries/LibWeb/CSS/CSSStyleRule.cpp index 534f04f60d8..6fd731377df 100644 --- a/Libraries/LibWeb/CSS/CSSStyleRule.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleRule.cpp @@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(CSSStyleRule); JS::NonnullGCPtr CSSStyleRule::create(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules) { - return realm.heap().allocate(realm, realm, move(selectors), declaration, nested_rules); + return realm.create(realm, move(selectors), declaration, nested_rules); } CSSStyleRule::CSSStyleRule(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules) diff --git a/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index 59bd7ac910e..d031e244f20 100644 --- a/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -25,7 +25,7 @@ JS_DEFINE_ALLOCATOR(CSSStyleSheet); JS::NonnullGCPtr CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional location) { - return realm.heap().allocate(realm, realm, rules, media, move(location)); + return realm.create(realm, rules, media, move(location)); } // https://drafts.csswg.org/cssom/#dom-cssstylesheet-cssstylesheet diff --git a/Libraries/LibWeb/CSS/CSSSupportsRule.cpp b/Libraries/LibWeb/CSS/CSSSupportsRule.cpp index c75d005e61d..a011ea41e80 100644 --- a/Libraries/LibWeb/CSS/CSSSupportsRule.cpp +++ b/Libraries/LibWeb/CSS/CSSSupportsRule.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(CSSSupportsRule); JS::NonnullGCPtr CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr&& supports, CSSRuleList& rules) { - return realm.heap().allocate(realm, realm, move(supports), rules); + return realm.create(realm, move(supports), rules); } CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr&& supports, CSSRuleList& rules) diff --git a/Libraries/LibWeb/CSS/CSSTransition.cpp b/Libraries/LibWeb/CSS/CSSTransition.cpp index 4075675b05e..d2c066c792c 100644 --- a/Libraries/LibWeb/CSS/CSSTransition.cpp +++ b/Libraries/LibWeb/CSS/CSSTransition.cpp @@ -24,7 +24,7 @@ JS::NonnullGCPtr CSSTransition::start_a_transition(DOM::Element& NonnullRefPtr reversing_adjusted_start_value, double reversing_shortening_factor) { auto& realm = element.realm(); - return realm.heap().allocate(realm, realm, element, property_id, transition_generation, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor); + return realm.create(realm, element, property_id, transition_generation, start_time, end_time, start_value, end_value, reversing_adjusted_start_value, reversing_shortening_factor); } Animations::AnimationClass CSSTransition::animation_class() const diff --git a/Libraries/LibWeb/CSS/FontFace.cpp b/Libraries/LibWeb/CSS/FontFace.cpp index fd38e5eddcf..87297f41809 100644 --- a/Libraries/LibWeb/CSS/FontFace.cpp +++ b/Libraries/LibWeb/CSS/FontFace.cpp @@ -107,7 +107,7 @@ JS::NonnullGCPtr FontFace::construct_impl(JS::Realm& realm, String fam if (buffer.is_empty() && sources.is_empty()) WebIDL::reject_promise(realm, promise, WebIDL::SyntaxError::create(realm, "FontFace constructor: Invalid font source"_string)); - auto font = realm.heap().allocate(realm, realm, promise, move(sources), move(buffer), move(family), descriptors); + auto font = realm.create(realm, promise, move(sources), move(buffer), move(family), descriptors); // 1. (continued) Return font face. If font face’s status is "error", terminate this algorithm; // otherwise, complete the rest of these steps asynchronously. diff --git a/Libraries/LibWeb/CSS/FontFaceSet.cpp b/Libraries/LibWeb/CSS/FontFaceSet.cpp index 997023ca7e3..f46a5a70983 100644 --- a/Libraries/LibWeb/CSS/FontFaceSet.cpp +++ b/Libraries/LibWeb/CSS/FontFaceSet.cpp @@ -37,7 +37,7 @@ JS::NonnullGCPtr FontFaceSet::construct_impl(JS::Realm& realm, Vect for (auto const& face : initial_faces) set_entries->set_add(face); - return realm.heap().allocate(realm, realm, ready_promise, set_entries); + return realm.create(realm, ready_promise, set_entries); } JS::NonnullGCPtr FontFaceSet::create(JS::Realm& realm) diff --git a/Libraries/LibWeb/CSS/MediaList.cpp b/Libraries/LibWeb/CSS/MediaList.cpp index c9446d99c5d..440f96a8a46 100644 --- a/Libraries/LibWeb/CSS/MediaList.cpp +++ b/Libraries/LibWeb/CSS/MediaList.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(MediaList); JS::NonnullGCPtr MediaList::create(JS::Realm& realm, Vector>&& media) { - return realm.heap().allocate(realm, realm, move(media)); + return realm.create(realm, move(media)); } MediaList::MediaList(JS::Realm& realm, Vector>&& media) diff --git a/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Libraries/LibWeb/CSS/MediaQueryList.cpp index c3c727e87db..c86b48fd4f7 100644 --- a/Libraries/LibWeb/CSS/MediaQueryList.cpp +++ b/Libraries/LibWeb/CSS/MediaQueryList.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(MediaQueryList); JS::NonnullGCPtr MediaQueryList::create(DOM::Document& document, Vector>&& media) { - return document.heap().allocate(document.realm(), document, move(media)); + return document.realm().create(document, move(media)); } MediaQueryList::MediaQueryList(DOM::Document& document, Vector>&& media) diff --git a/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp b/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp index 79fae086e43..65fc1b4e595 100644 --- a/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp +++ b/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(MediaQueryListEvent); JS::NonnullGCPtr MediaQueryListEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, FlyString const& event_name, MediaQueryListEventInit const& event_init) diff --git a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 32f33008ab6..e5a81b4eef8 100644 --- a/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -47,7 +47,7 @@ JS_DEFINE_ALLOCATOR(ResolvedCSSStyleDeclaration); JS::NonnullGCPtr ResolvedCSSStyleDeclaration::create(DOM::Element& element, Optional pseudo_element) { - return element.realm().heap().allocate(element.realm(), element, move(pseudo_element)); + return element.realm().create(element, move(pseudo_element)); } ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element, Optional pseudo_element) diff --git a/Libraries/LibWeb/CSS/Screen.cpp b/Libraries/LibWeb/CSS/Screen.cpp index e6dc367eff8..b17955fb312 100644 --- a/Libraries/LibWeb/CSS/Screen.cpp +++ b/Libraries/LibWeb/CSS/Screen.cpp @@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(Screen); JS::NonnullGCPtr Screen::create(HTML::Window& window) { - return window.heap().allocate(window.realm(), window); + return window.realm().create(window); } Screen::Screen(HTML::Window& window) diff --git a/Libraries/LibWeb/CSS/ScreenOrientation.cpp b/Libraries/LibWeb/CSS/ScreenOrientation.cpp index c0b0ed04af2..8c37fcff355 100644 --- a/Libraries/LibWeb/CSS/ScreenOrientation.cpp +++ b/Libraries/LibWeb/CSS/ScreenOrientation.cpp @@ -26,7 +26,7 @@ void ScreenOrientation::initialize(JS::Realm& realm) JS::NonnullGCPtr ScreenOrientation::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } // https://w3c.github.io/screen-orientation/#lock-method diff --git a/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Libraries/LibWeb/CSS/StyleSheetList.cpp index 89ae41f1dc0..c93cc64c1a2 100644 --- a/Libraries/LibWeb/CSS/StyleSheetList.cpp +++ b/Libraries/LibWeb/CSS/StyleSheetList.cpp @@ -131,7 +131,7 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet) JS::NonnullGCPtr StyleSheetList::create(JS::NonnullGCPtr document_or_shadow_root) { auto& realm = document_or_shadow_root->realm(); - return realm.heap().allocate(realm, document_or_shadow_root); + return realm.create(document_or_shadow_root); } StyleSheetList::StyleSheetList(JS::NonnullGCPtr document_or_shadow_root) diff --git a/Libraries/LibWeb/CSS/VisualViewport.cpp b/Libraries/LibWeb/CSS/VisualViewport.cpp index 7e559773830..47c8947d54e 100644 --- a/Libraries/LibWeb/CSS/VisualViewport.cpp +++ b/Libraries/LibWeb/CSS/VisualViewport.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(VisualViewport); JS::NonnullGCPtr VisualViewport::create(DOM::Document& document) { - return document.heap().allocate(document.realm(), document); + return document.realm().create(document); } VisualViewport::VisualViewport(DOM::Document& document) diff --git a/Libraries/LibWeb/Clipboard/Clipboard.cpp b/Libraries/LibWeb/Clipboard/Clipboard.cpp index f2e224e1621..fd36aa744aa 100644 --- a/Libraries/LibWeb/Clipboard/Clipboard.cpp +++ b/Libraries/LibWeb/Clipboard/Clipboard.cpp @@ -23,7 +23,7 @@ JS_DEFINE_ALLOCATOR(Clipboard); WebIDL::ExceptionOr> Clipboard::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } Clipboard::Clipboard(JS::Realm& realm) diff --git a/Libraries/LibWeb/Clipboard/ClipboardEvent.cpp b/Libraries/LibWeb/Clipboard/ClipboardEvent.cpp index 1a8950b20c8..73666e92538 100644 --- a/Libraries/LibWeb/Clipboard/ClipboardEvent.cpp +++ b/Libraries/LibWeb/Clipboard/ClipboardEvent.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(ClipboardEvent); JS::NonnullGCPtr ClipboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } ClipboardEvent::ClipboardEvent(JS::Realm& realm, FlyString const& event_name, ClipboardEventInit const& event_init) diff --git a/Libraries/LibWeb/Crypto/Crypto.cpp b/Libraries/LibWeb/Crypto/Crypto.cpp index b7293039477..d7ef9529329 100644 --- a/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Libraries/LibWeb/Crypto/Crypto.cpp @@ -21,7 +21,7 @@ JS_DEFINE_ALLOCATOR(Crypto); JS::NonnullGCPtr Crypto::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } Crypto::Crypto(JS::Realm& realm) diff --git a/Libraries/LibWeb/Crypto/CryptoKey.cpp b/Libraries/LibWeb/Crypto/CryptoKey.cpp index fd6d00de108..b7bd43668da 100644 --- a/Libraries/LibWeb/Crypto/CryptoKey.cpp +++ b/Libraries/LibWeb/Crypto/CryptoKey.cpp @@ -18,12 +18,12 @@ JS_DEFINE_ALLOCATOR(CryptoKeyPair); JS::NonnullGCPtr CryptoKey::create(JS::Realm& realm, InternalKeyData key_data) { - return realm.heap().allocate(realm, realm, move(key_data)); + return realm.create(realm, move(key_data)); } JS::NonnullGCPtr CryptoKey::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } CryptoKey::CryptoKey(JS::Realm& realm, InternalKeyData key_data) @@ -82,7 +82,7 @@ String CryptoKey::algorithm_name() const JS::NonnullGCPtr CryptoKeyPair::create(JS::Realm& realm, JS::NonnullGCPtr public_key, JS::NonnullGCPtr private_key) { - return realm.heap().allocate(realm, realm, public_key, private_key); + return realm.create(realm, public_key, private_key); } CryptoKeyPair::CryptoKeyPair(JS::Realm& realm, JS::NonnullGCPtr public_key, JS::NonnullGCPtr private_key) diff --git a/Libraries/LibWeb/Crypto/KeyAlgorithms.cpp b/Libraries/LibWeb/Crypto/KeyAlgorithms.cpp index 8b3e5c5e021..3d5541f8b46 100644 --- a/Libraries/LibWeb/Crypto/KeyAlgorithms.cpp +++ b/Libraries/LibWeb/Crypto/KeyAlgorithms.cpp @@ -36,7 +36,7 @@ static JS::ThrowCompletionOr impl_from(JS::VM& vm, StringView Name) JS::NonnullGCPtr KeyAlgorithm::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } KeyAlgorithm::KeyAlgorithm(JS::Realm& realm) @@ -66,7 +66,7 @@ void KeyAlgorithm::visit_edges(Visitor& visitor) JS::NonnullGCPtr RsaKeyAlgorithm::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } RsaKeyAlgorithm::RsaKeyAlgorithm(JS::Realm& realm) @@ -132,7 +132,7 @@ JS_DEFINE_NATIVE_FUNCTION(RsaKeyAlgorithm::public_exponent_getter) JS::NonnullGCPtr EcKeyAlgorithm::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } EcKeyAlgorithm::EcKeyAlgorithm(JS::Realm& realm) @@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(EcKeyAlgorithm::named_curve_getter) JS::NonnullGCPtr RsaHashedKeyAlgorithm::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } RsaHashedKeyAlgorithm::RsaHashedKeyAlgorithm(JS::Realm& realm) @@ -186,7 +186,7 @@ JS_DEFINE_NATIVE_FUNCTION(RsaHashedKeyAlgorithm::hash_getter) JS::NonnullGCPtr AesKeyAlgorithm::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } AesKeyAlgorithm::AesKeyAlgorithm(JS::Realm& realm) diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index 253e9a24768..1e72bf8ed09 100644 --- a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -43,7 +43,7 @@ JS_DEFINE_ALLOCATOR(SubtleCrypto); JS::NonnullGCPtr SubtleCrypto::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } SubtleCrypto::SubtleCrypto(JS::Realm& realm) diff --git a/Libraries/LibWeb/DOM/AbortController.cpp b/Libraries/LibWeb/DOM/AbortController.cpp index bbd830fde6c..232eb38c958 100644 --- a/Libraries/LibWeb/DOM/AbortController.cpp +++ b/Libraries/LibWeb/DOM/AbortController.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(AbortController); WebIDL::ExceptionOr> AbortController::construct_impl(JS::Realm& realm) { auto signal = TRY(AbortSignal::construct_impl(realm)); - return realm.heap().allocate(realm, realm, move(signal)); + return realm.create(realm, move(signal)); } // https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller diff --git a/Libraries/LibWeb/DOM/AbortSignal.cpp b/Libraries/LibWeb/DOM/AbortSignal.cpp index b0acc687581..1c34ad98bc8 100644 --- a/Libraries/LibWeb/DOM/AbortSignal.cpp +++ b/Libraries/LibWeb/DOM/AbortSignal.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(AbortSignal); WebIDL::ExceptionOr> AbortSignal::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } AbortSignal::AbortSignal(JS::Realm& realm) diff --git a/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp b/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp index 7cdfd3dc5db..8a0c173e71d 100644 --- a/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp +++ b/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(AccessibilityTreeNode); JS::NonnullGCPtr AccessibilityTreeNode::create(Document* document, DOM::Node const* value) { - return document->heap().allocate(document->realm(), value); + return document->realm().create(value); } AccessibilityTreeNode::AccessibilityTreeNode(JS::GCPtr value) diff --git a/Libraries/LibWeb/DOM/Attr.cpp b/Libraries/LibWeb/DOM/Attr.cpp index 5bf1b28c9b5..e0971f27d14 100644 --- a/Libraries/LibWeb/DOM/Attr.cpp +++ b/Libraries/LibWeb/DOM/Attr.cpp @@ -20,17 +20,17 @@ JS_DEFINE_ALLOCATOR(Attr); JS::NonnullGCPtr Attr::create(Document& document, FlyString local_name, String value, Element* owner_element) { - return document.heap().allocate(document.realm(), document, QualifiedName(move(local_name), Optional {}, Optional {}), move(value), owner_element); + return document.realm().create(document, QualifiedName(move(local_name), Optional {}, Optional {}), move(value), owner_element); } JS::NonnullGCPtr Attr::create(Document& document, QualifiedName qualified_name, String value, Element* owner_element) { - return document.heap().allocate(document.realm(), document, move(qualified_name), move(value), owner_element); + return document.realm().create(document, move(qualified_name), move(value), owner_element); } JS::NonnullGCPtr Attr::clone(Document& document) { - return *heap().allocate(realm(), document, m_qualified_name, m_value, nullptr); + return realm().create(document, m_qualified_name, m_value, nullptr); } Attr::Attr(Document& document, QualifiedName qualified_name, String value, Element* owner_element) diff --git a/Libraries/LibWeb/DOM/Comment.cpp b/Libraries/LibWeb/DOM/Comment.cpp index 066dbd62762..6025b79d026 100644 --- a/Libraries/LibWeb/DOM/Comment.cpp +++ b/Libraries/LibWeb/DOM/Comment.cpp @@ -22,7 +22,7 @@ Comment::Comment(Document& document, String const& data) WebIDL::ExceptionOr> Comment::construct_impl(JS::Realm& realm, String const& data) { auto& window = verify_cast(realm.global_object()); - return realm.heap().allocate(realm, window.associated_document(), data); + return realm.create(window.associated_document(), data); } void Comment::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/DOM/CustomEvent.cpp b/Libraries/LibWeb/DOM/CustomEvent.cpp index 2f7e001691f..63a2cfd41a0 100644 --- a/Libraries/LibWeb/DOM/CustomEvent.cpp +++ b/Libraries/LibWeb/DOM/CustomEvent.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(CustomEvent); JS::NonnullGCPtr CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> CustomEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init) diff --git a/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Libraries/LibWeb/DOM/DOMImplementation.cpp index 462ffcf1880..bddb4b5d417 100644 --- a/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -24,7 +24,7 @@ JS_DEFINE_ALLOCATOR(DOMImplementation); JS::NonnullGCPtr DOMImplementation::create(Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, document); + return realm.create(document); } DOMImplementation::DOMImplementation(Document& document) @@ -102,7 +102,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(Optionalset_ready_for_post_load_tasks(true); // 3. Append a new doctype, with "html" as its name and with its node document set to doc, to doc. - auto doctype = heap().allocate(realm(), html_document); + auto doctype = realm().create(html_document); doctype->set_name("html"_string); MUST(html_document->append_child(*doctype)); @@ -121,7 +121,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(Optionalappend_child(title_element)); // 2. Append a new Text node, with its data set to title (which could be the empty string) and its node document set to doc, to the title element created earlier. - auto text_node = heap().allocate(realm(), html_document, title.value()); + auto text_node = realm().create(html_document, title.value()); MUST(title_element->append_child(*text_node)); } diff --git a/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Libraries/LibWeb/DOM/DOMTokenList.cpp index 570012cc853..0e0920833c7 100644 --- a/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -59,7 +59,7 @@ JS_DEFINE_ALLOCATOR(DOMTokenList); JS::NonnullGCPtr DOMTokenList::create(Element& associated_element, FlyString associated_attribute) { auto& realm = associated_element.realm(); - return realm.heap().allocate(realm, associated_element, move(associated_attribute)); + return realm.create(associated_element, move(associated_attribute)); } // https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2 diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index b50382e01ab..2092c796fc8 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -374,12 +374,12 @@ WebIDL::ExceptionOr> Document::construct_impl(JS::Rea JS::NonnullGCPtr Document::create(JS::Realm& realm, URL::URL const& url) { - return realm.heap().allocate(realm, realm, url); + return realm.create(realm, url); } JS::NonnullGCPtr Document::create_for_fragment_parsing(JS::Realm& realm) { - return realm.heap().allocate(realm, realm, "about:blank"sv, TemporaryDocumentForFragmentParsing::Yes); + return realm.create(realm, "about:blank"sv, TemporaryDocumentForFragmentParsing::Yes); } Document::Document(JS::Realm& realm, const URL::URL& url, TemporaryDocumentForFragmentParsing temporary_document_for_fragment_parsing) @@ -429,9 +429,9 @@ void Document::initialize(JS::Realm& realm) Base::initialize(realm); WEB_SET_PROTOTYPE_FOR_INTERFACE(Document); - m_selection = heap().allocate(realm, realm, *this); + m_selection = realm.create(realm, *this); - m_list_of_available_images = heap().allocate(realm); + m_list_of_available_images = realm.create(); page().client().page_did_create_new_document(*this); } @@ -1709,12 +1709,12 @@ WebIDL::ExceptionOr> Document::create_element_ns(Optio JS::NonnullGCPtr Document::create_document_fragment() { - return heap().allocate(realm(), *this); + return realm().create(*this); } JS::NonnullGCPtr Document::create_text_node(String const& data) { - return heap().allocate(realm(), *this, data); + return realm().create(*this, data); } // https://dom.spec.whatwg.org/#dom-document-createcdatasection @@ -1729,12 +1729,12 @@ WebIDL::ExceptionOr> Document::create_cdata_secti return WebIDL::InvalidCharacterError::create(realm(), "String may not contain ']]>'"_string); // 3. Return a new CDATASection node with its data set to data and node document set to this. - return heap().allocate(realm(), *this, data); + return realm().create(*this, data); } JS::NonnullGCPtr Document::create_comment(String const& data) { - return heap().allocate(realm(), *this, data); + return realm().create(*this, data); } // https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction @@ -1749,7 +1749,7 @@ WebIDL::ExceptionOr> Document::create_pr return WebIDL::InvalidCharacterError::create(realm(), "String may not contain '?>'"_string); // 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this. - return heap().allocate(realm(), *this, data, target); + return realm().create(*this, data, target); } JS::NonnullGCPtr Document::create_range() @@ -3986,7 +3986,7 @@ void Document::queue_an_intersection_observer_entry(IntersectionObserver::Inters auto& realm = this->realm(); // 1. Construct an IntersectionObserverEntry, passing in time, rootBounds, boundingClientRect, intersectionRect, isIntersecting, and target. - auto entry = realm.heap().allocate(realm, realm, time, root_bounds, bounding_client_rect, intersection_rect, is_intersecting, intersection_ratio, target); + auto entry = realm.create(realm, time, root_bounds, bounding_client_rect, intersection_rect, is_intersecting, intersection_ratio, target); // 2. Append it to observer’s internal [[QueuedEntries]] slot. observer.queue_entry({}, entry); diff --git a/Libraries/LibWeb/DOM/DocumentFragment.cpp b/Libraries/LibWeb/DOM/DocumentFragment.cpp index e3b64728673..8e0086ff0b0 100644 --- a/Libraries/LibWeb/DOM/DocumentFragment.cpp +++ b/Libraries/LibWeb/DOM/DocumentFragment.cpp @@ -38,7 +38,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element) WebIDL::ExceptionOr> DocumentFragment::construct_impl(JS::Realm& realm) { auto& window = verify_cast(realm.global_object()); - return realm.heap().allocate(realm, window.associated_document()); + return realm.create(window.associated_document()); } } diff --git a/Libraries/LibWeb/DOM/DocumentLoading.cpp b/Libraries/LibWeb/DOM/DocumentLoading.cpp index efc4c12fbec..9a88b983e8a 100644 --- a/Libraries/LibWeb/DOM/DocumentLoading.cpp +++ b/Libraries/LibWeb/DOM/DocumentLoading.cpp @@ -31,7 +31,7 @@ static void convert_to_xml_error_document(DOM::Document& document, String error_ auto html_element = MUST(DOM::create_element(document, HTML::TagNames::html, Namespace::HTML)); auto body_element = MUST(DOM::create_element(document, HTML::TagNames::body, Namespace::HTML)); MUST(html_element->append_child(body_element)); - MUST(body_element->append_child(document.heap().allocate(document.realm(), document, error_string))); + MUST(body_element->append_child(document.realm().create(document, error_string))); document.remove_all_children(); MUST(document.append_child(html_element)); } @@ -249,7 +249,7 @@ static WebIDL::ExceptionOr> load_text_document(H auto title = MUST(String::from_byte_string(LexicalPath::basename(url.to_byte_string()))); auto title_element = MUST(DOM::create_element(document, HTML::TagNames::title, Namespace::HTML)); MUST(document->head()->append_child(title_element)); - auto title_text = document->heap().allocate(document->realm(), document, title); + auto title_text = document->realm().create(document, title); MUST(title_element->append_child(*title_text)); }); @@ -287,7 +287,7 @@ static WebIDL::ExceptionOr> load_media_document( auto title_element = TRY(DOM::create_element(document, HTML::TagNames::title, Namespace::HTML)); TRY(document->head()->append_child(title_element)); - auto title_text = document->heap().template allocate(document->realm(), document, title); + auto title_text = document->realm().template create(document, title); TRY(title_element->append_child(*title_text)); return {}; }; diff --git a/Libraries/LibWeb/DOM/DocumentType.cpp b/Libraries/LibWeb/DOM/DocumentType.cpp index ffde0a94f1a..f7ebc6466c5 100644 --- a/Libraries/LibWeb/DOM/DocumentType.cpp +++ b/Libraries/LibWeb/DOM/DocumentType.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(DocumentType); JS::NonnullGCPtr DocumentType::create(Document& document) { - return document.heap().allocate(document.realm(), document); + return document.realm().create(document); } DocumentType::DocumentType(Document& document) diff --git a/Libraries/LibWeb/DOM/EditingHostManager.cpp b/Libraries/LibWeb/DOM/EditingHostManager.cpp index baa5fdb1c15..446c032fd66 100644 --- a/Libraries/LibWeb/DOM/EditingHostManager.cpp +++ b/Libraries/LibWeb/DOM/EditingHostManager.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(EditingHostManager); JS::NonnullGCPtr EditingHostManager::create(JS::Realm& realm, JS::NonnullGCPtr document) { - return realm.heap().allocate(realm, document); + return realm.create(document); } EditingHostManager::EditingHostManager(JS::NonnullGCPtr document) @@ -47,7 +47,7 @@ void EditingHostManager::handle_insert(String const& data) if (!is(*node)) { auto& realm = node->realm(); - auto text = realm.heap().allocate(realm, node->document(), data); + auto text = realm.create(node->document(), data); MUST(node->append_child(*text)); MUST(selection->collapse(*text, 1)); return; diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index fe66a6a55a8..7725251e1e1 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -699,7 +699,7 @@ WebIDL::ExceptionOr Element::attach_a_shadow_root(Bindings::ShadowRootMode } // 5. Let shadow be a new shadow root whose node document is element’s node document, host is this, and mode is mode. - auto shadow = heap().allocate(realm(), document(), *this, mode); + auto shadow = realm().create(document(), *this, mode); // 6. Set shadow’s delegates focus to delegatesFocus". shadow->set_delegates_focus(delegates_focus); @@ -1547,7 +1547,7 @@ WebIDL::ExceptionOr> Element::parse_frag auto new_children = algorithm(*this, markup, HTML::HTMLParser::AllowDeclarativeShadowRoots::No); // 4. Let fragment be a new DocumentFragment whose node document is context's node document. - auto fragment = realm().heap().allocate(realm(), document()); + auto fragment = realm().create(document()); // 5. Append each Node in new children to fragment (in tree order). for (auto& child : new_children) { @@ -1721,7 +1721,7 @@ WebIDL::ExceptionOr> Element::insert_adjacent_element(String WebIDL::ExceptionOr Element::insert_adjacent_text(String const& where, String const& data) { // 1. Let text be a new Text node whose data is data and node document is this’s node document. - auto text = heap().allocate(realm(), document(), data); + auto text = realm().create(document(), data); // 2. Run insert adjacent, given this, where, and text. // Spec Note: This method returns nothing because it existed before we had a chance to design it. diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index 4d3f1862732..c7fb3798a23 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -281,153 +281,153 @@ static JS::NonnullGCPtr create_html_element(JS::Realm& realm, Document& FlyString tag_name = qualified_name.local_name(); if (tag_name == HTML::TagNames::a) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::area) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::audio) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::base) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::body) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::br) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::button) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::canvas) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::data) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::datalist) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::details) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::dialog) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::dir) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::div) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::dl) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::embed) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::fieldset) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::font) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::form) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::frame) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::frameset) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::head) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::hr) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::html) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::iframe) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::img) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::input) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::label) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::legend) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::li) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::link) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::map) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::marquee) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::menu) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::meta) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::meter) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::object) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::ol) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::optgroup) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::option) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::output) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::p) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::param) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::picture) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); // NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification. if (tag_name.is_one_of(HTML::TagNames::pre, HTML::TagNames::listing, HTML::TagNames::xmp)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::progress) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::script) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::select) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::slot) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::source) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::span) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::style) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::summary) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::caption) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::table) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::tr) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::template_) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::textarea) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::time) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::title) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::track) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::ul) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name == HTML::TagNames::video) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (tag_name.is_one_of( HTML::TagNames::article, HTML::TagNames::section, HTML::TagNames::nav, HTML::TagNames::aside, HTML::TagNames::hgroup, HTML::TagNames::header, HTML::TagNames::footer, HTML::TagNames::address, HTML::TagNames::dt, HTML::TagNames::dd, HTML::TagNames::figure, HTML::TagNames::figcaption, HTML::TagNames::main, HTML::TagNames::em, HTML::TagNames::strong, HTML::TagNames::small, HTML::TagNames::s, HTML::TagNames::cite, HTML::TagNames::dfn, HTML::TagNames::abbr, HTML::TagNames::ruby, HTML::TagNames::rt, HTML::TagNames::rp, HTML::TagNames::code, HTML::TagNames::var, HTML::TagNames::samp, HTML::TagNames::kbd, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::i, HTML::TagNames::b, HTML::TagNames::u, HTML::TagNames::mark, HTML::TagNames::bdi, HTML::TagNames::bdo, HTML::TagNames::wbr, HTML::TagNames::noscript, // Obsolete HTML::TagNames::acronym, HTML::TagNames::basefont, HTML::TagNames::big, HTML::TagNames::center, HTML::TagNames::nobr, HTML::TagNames::noembed, HTML::TagNames::noframes, HTML::TagNames::plaintext, HTML::TagNames::rb, HTML::TagNames::rtc, HTML::TagNames::strike, HTML::TagNames::tt)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (HTML::is_valid_custom_element_name(qualified_name.local_name())) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); } static JS::NonnullGCPtr create_svg_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) @@ -435,67 +435,67 @@ static JS::NonnullGCPtr create_svg_element(JS::Realm& realm, Do auto const& local_name = qualified_name.local_name(); if (local_name == SVG::TagNames::svg) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); // FIXME: Support SVG's mixedCase tag names properly. if (local_name.equals_ignoring_ascii_case(SVG::TagNames::clipPath)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::circle) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name.equals_ignoring_ascii_case(SVG::TagNames::defs)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::desc) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::ellipse) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name.equals_ignoring_ascii_case(SVG::TagNames::foreignObject)) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::line) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::linearGradient) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::mask) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::metadata) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::path) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::polygon) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::polyline) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::radialGradient) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::rect) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::g) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::stop) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::style) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::symbol) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::text) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::textPath) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::title) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::tspan) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::use) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::script) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::a) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); if (local_name == SVG::TagNames::image) - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); // https://svgwg.org/svg2-draft/types.html#ElementsInTheSVGDOM // Elements in the SVG namespace whose local name does not match an element defined in any // specification supported by the software must nonetheless implement the SVGElement interface. - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); } static JS::NonnullGCPtr create_mathml_element(JS::Realm& realm, Document& document, QualifiedName qualified_name) @@ -507,7 +507,7 @@ static JS::NonnullGCPtr create_mathml_element(JS::Realm& // https://w3c.github.io/mathml-core/#mathml-elements-and-attributes // The term MathML element refers to any element in the MathML namespace. - return realm.heap().allocate(realm, document, move(qualified_name)); + return realm.create(document, move(qualified_name)); } // https://dom.spec.whatwg.org/#concept-create-element WebIDL::ExceptionOr> create_element(Document& document, FlyString local_name, Optional namespace_, Optional prefix, Optional is_value, bool synchronous_custom_elements_flag) @@ -617,7 +617,7 @@ WebIDL::ExceptionOr> create_element(Document& document // 2. Set result to a new element that implements the HTMLUnknownElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, // local name set to localName, custom element state set to "failed", custom element definition set to null, is value set to null, and node document set to document. - JS::NonnullGCPtr element = realm.heap().allocate(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }); + JS::NonnullGCPtr element = realm.create(document, QualifiedName { local_name, prefix, Namespace::HTML }); element->set_custom_element_state(CustomElementState::Failed); return element; } @@ -628,7 +628,7 @@ WebIDL::ExceptionOr> create_element(Document& document // 2. Otherwise: // 1. Set result to a new element that implements the HTMLElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix, // local name set to localName, custom element state set to "undefined", custom element definition set to null, is value set to null, and node document set to document. - auto element = realm.heap().allocate(realm, document, QualifiedName { local_name, prefix, Namespace::HTML }); + auto element = realm.create(document, QualifiedName { local_name, prefix, Namespace::HTML }); element->set_custom_element_state(CustomElementState::Undefined); // 2. Enqueue a custom element upgrade reaction given result and definition. @@ -677,7 +677,7 @@ WebIDL::ExceptionOr> create_element(Document& document // https://dom.spec.whatwg.org/#concept-element-interface // The element interface for any name and namespace is Element, unless stated otherwise. dbgln("Potential FIXME: Creating unknown generic element '{}' in namespace '{}'", local_name, namespace_); - auto element = realm.heap().allocate(realm, document, move(qualified_name)); + auto element = realm.create(document, move(qualified_name)); element->set_is_value(move(is_value)); element->set_custom_element_state(CustomElementState::Uncustomized); return element; diff --git a/Libraries/LibWeb/DOM/Event.cpp b/Libraries/LibWeb/DOM/Event.cpp index 3707a411cf7..b34b4bcc60a 100644 --- a/Libraries/LibWeb/DOM/Event.cpp +++ b/Libraries/LibWeb/DOM/Event.cpp @@ -21,7 +21,7 @@ JS_DEFINE_ALLOCATOR(Event); // https://dom.spec.whatwg.org/#concept-event-create JS::NonnullGCPtr Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init) { - auto event = realm.heap().allocate(realm, realm, event_name, event_init); + auto event = realm.create(realm, event_name, event_init); // 4. Initialize event’s isTrusted attribute to true. event->m_is_trusted = true; return event; @@ -29,7 +29,7 @@ JS::NonnullGCPtr Event::create(JS::Realm& realm, FlyString const& event_n WebIDL::ExceptionOr> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } // https://dom.spec.whatwg.org/#inner-event-creation-steps diff --git a/Libraries/LibWeb/DOM/EventTarget.cpp b/Libraries/LibWeb/DOM/EventTarget.cpp index fc1a4a12cca..127976c42a5 100644 --- a/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Libraries/LibWeb/DOM/EventTarget.cpp @@ -54,7 +54,7 @@ EventTarget::~EventTarget() = default; WebIDL::ExceptionOr> EventTarget::construct_impl(JS::Realm& realm) { // The new EventTarget() constructor steps are to do nothing. - return realm.heap().allocate(realm, realm); + return realm.create(realm); } void EventTarget::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Libraries/LibWeb/DOM/HTMLCollection.cpp index 19a9d2a4c79..b590842c278 100644 --- a/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(HTMLCollection); JS::NonnullGCPtr HTMLCollection::create(ParentNode& root, Scope scope, Function filter) { - return root.heap().allocate(root.realm(), root, scope, move(filter)); + return root.realm().create(root, scope, move(filter)); } HTMLCollection::HTMLCollection(ParentNode& root, Scope scope, Function filter) diff --git a/Libraries/LibWeb/DOM/IDLEventListener.cpp b/Libraries/LibWeb/DOM/IDLEventListener.cpp index 1f2b89345f7..45923d2f566 100644 --- a/Libraries/LibWeb/DOM/IDLEventListener.cpp +++ b/Libraries/LibWeb/DOM/IDLEventListener.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(IDLEventListener); JS::NonnullGCPtr IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr callback) { - return realm.heap().allocate(realm, realm, move(callback)); + return realm.create(realm, move(callback)); } IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr callback) diff --git a/Libraries/LibWeb/DOM/LiveNodeList.cpp b/Libraries/LibWeb/DOM/LiveNodeList.cpp index 5fb9b6a0c23..9d809859cfd 100644 --- a/Libraries/LibWeb/DOM/LiveNodeList.cpp +++ b/Libraries/LibWeb/DOM/LiveNodeList.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(LiveNodeList); JS::NonnullGCPtr LiveNodeList::create(JS::Realm& realm, Node const& root, Scope scope, Function filter) { - return realm.heap().allocate(realm, realm, root, scope, move(filter)); + return realm.create(realm, root, scope, move(filter)); } LiveNodeList::LiveNodeList(JS::Realm& realm, Node const& root, Scope scope, Function filter) diff --git a/Libraries/LibWeb/DOM/MutationObserver.cpp b/Libraries/LibWeb/DOM/MutationObserver.cpp index 5f211556290..5e5f21a0a7a 100644 --- a/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(TransientRegisteredObserver); WebIDL::ExceptionOr> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr callback) { - return realm.heap().allocate(realm, realm, callback); + return realm.create(realm, callback); } // https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver diff --git a/Libraries/LibWeb/DOM/MutationRecord.cpp b/Libraries/LibWeb/DOM/MutationRecord.cpp index aa0186d39f3..79b1d7cecb3 100644 --- a/Libraries/LibWeb/DOM/MutationRecord.cpp +++ b/Libraries/LibWeb/DOM/MutationRecord.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(MutationRecord); JS::NonnullGCPtr MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value) { - return realm.heap().allocate(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value); + return realm.create(realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value); } MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value) diff --git a/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Libraries/LibWeb/DOM/NamedNodeMap.cpp index a8afdf1a881..8a09c105fed 100644 --- a/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(NamedNodeMap); JS::NonnullGCPtr NamedNodeMap::create(Element& element) { auto& realm = element.realm(); - return realm.heap().allocate(realm, element); + return realm.create(element); } NamedNodeMap::NamedNodeMap(Element& element) diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index 02528ac3d75..f9852f10824 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -1034,7 +1034,7 @@ WebIDL::ExceptionOr> Node::clone_node(Document* document, } else if (is(this)) { // DocumentType auto document_type = verify_cast(this); - auto document_type_copy = heap().allocate(realm(), *document); + auto document_type_copy = realm().create(*document); // Set copy’s name, public ID, and system ID to those of node. document_type_copy->set_name(document_type->name()); @@ -1053,26 +1053,26 @@ WebIDL::ExceptionOr> Node::clone_node(Document* document, auto& text = static_cast(*this); // Set copy’s data to that of node. - auto text_copy = heap().allocate(realm(), *document, text.data()); + auto text_copy = realm().create(*document, text.data()); copy = move(text_copy); } else if (is(this)) { // Comment auto comment = verify_cast(this); // Set copy’s data to that of node. - auto comment_copy = heap().allocate(realm(), *document, comment->data()); + auto comment_copy = realm().create(*document, comment->data()); copy = move(comment_copy); } else if (is(this)) { // ProcessingInstruction auto processing_instruction = verify_cast(this); // Set copy’s target and data to those of node. - auto processing_instruction_copy = heap().allocate(realm(), *document, processing_instruction->data(), processing_instruction->target()); + auto processing_instruction_copy = realm().create(*document, processing_instruction->data(), processing_instruction->target()); copy = processing_instruction_copy; } // Otherwise, Do nothing. else if (is(this)) { - copy = heap().allocate(realm(), *document); + copy = realm().create(*document); } // FIXME: 4. Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise. @@ -1551,7 +1551,7 @@ void Node::string_replace_all(String const& string) // 2. If string is not the empty string, then set node to a new Text node whose data is string and node document is parent’s node document. if (!string.is_empty()) - node = heap().allocate(realm(), document(), string); + node = realm().create(document(), string); // 3. Replace all with node within parent. replace_all(node); @@ -1588,7 +1588,7 @@ WebIDL::ExceptionOr Node::unsafely_set_html(Element& context_element, Stri auto new_children = HTML::HTMLParser::parse_html_fragment(context_element, html, HTML::HTMLParser::AllowDeclarativeShadowRoots::Yes); // 2. Let fragment be a new DocumentFragment whose node document is contextElement’s node document. - auto fragment = heap().allocate(realm(), context_element.document()); + auto fragment = realm().create(context_element.document()); // 3. For each node in newChildren, append node to fragment. for (auto& child : new_children) diff --git a/Libraries/LibWeb/DOM/NodeFilter.cpp b/Libraries/LibWeb/DOM/NodeFilter.cpp index 190b1c8f475..46fdfa6b249 100644 --- a/Libraries/LibWeb/DOM/NodeFilter.cpp +++ b/Libraries/LibWeb/DOM/NodeFilter.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(NodeFilter); JS::NonnullGCPtr NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback) { - return realm.heap().allocate(realm, realm, callback); + return realm.create(realm, callback); } NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback) diff --git a/Libraries/LibWeb/DOM/NodeIterator.cpp b/Libraries/LibWeb/DOM/NodeIterator.cpp index b6440d788e5..eb04c38a3ec 100644 --- a/Libraries/LibWeb/DOM/NodeIterator.cpp +++ b/Libraries/LibWeb/DOM/NodeIterator.cpp @@ -54,7 +54,7 @@ WebIDL::ExceptionOr> NodeIterator::create(Node& r // 2. Set iterator’s root and iterator’s reference to root. // 3. Set iterator’s pointer before reference to true. auto& realm = root.realm(); - auto iterator = realm.heap().allocate(realm, root); + auto iterator = realm.create(root); // 4. Set iterator’s whatToShow to whatToShow. iterator->m_what_to_show = what_to_show; diff --git a/Libraries/LibWeb/DOM/NodeOperations.cpp b/Libraries/LibWeb/DOM/NodeOperations.cpp index fb67b1c70fa..ee16efdc577 100644 --- a/Libraries/LibWeb/DOM/NodeOperations.cpp +++ b/Libraries/LibWeb/DOM/NodeOperations.cpp @@ -27,13 +27,13 @@ WebIDL::ExceptionOr> convert_nodes_to_single_node(Vector< if (node.has>()) return *node.get>(); - return document.heap().allocate(document.realm(), document, node.get()); + return document.realm().create(document, node.get()); }; if (nodes.size() == 1) return potentially_convert_string_to_text_node(nodes.first()); - auto document_fragment = document.heap().allocate(document.realm(), document); + auto document_fragment = document.realm().create(document); for (auto const& unconverted_node : nodes) { auto node = potentially_convert_string_to_text_node(unconverted_node); (void)TRY(document_fragment->append_child(node)); diff --git a/Libraries/LibWeb/DOM/Position.h b/Libraries/LibWeb/DOM/Position.h index e05cfa5476b..1ff7b9aa751 100644 --- a/Libraries/LibWeb/DOM/Position.h +++ b/Libraries/LibWeb/DOM/Position.h @@ -23,7 +23,7 @@ class Position final : public JS::Cell { public: [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm& realm, JS::NonnullGCPtr node, unsigned offset) { - return realm.heap().allocate(realm, node, offset); + return realm.create(node, offset); } JS::GCPtr node() { return m_node; } diff --git a/Libraries/LibWeb/DOM/Range.cpp b/Libraries/LibWeb/DOM/Range.cpp index 657b518fd9f..671f2ec2237 100644 --- a/Libraries/LibWeb/DOM/Range.cpp +++ b/Libraries/LibWeb/DOM/Range.cpp @@ -45,13 +45,13 @@ JS::NonnullGCPtr Range::create(HTML::Window& window) JS::NonnullGCPtr Range::create(Document& document) { auto& realm = document.realm(); - return realm.heap().allocate(realm, document); + return realm.create(document); } JS::NonnullGCPtr Range::create(Node& start_container, WebIDL::UnsignedLong start_offset, Node& end_container, WebIDL::UnsignedLong end_offset) { auto& realm = start_container.realm(); - return realm.heap().allocate(realm, start_container, start_offset, end_container, end_offset); + return realm.create(start_container, start_offset, end_container, end_offset); } WebIDL::ExceptionOr> Range::construct_impl(JS::Realm& realm) @@ -442,12 +442,12 @@ WebIDL::ExceptionOr Range::select_node_contents(Node& node) JS::NonnullGCPtr Range::clone_range() const { - return heap().allocate(shape().realm(), const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset); + return shape().realm().create(const_cast(*m_start_container), m_start_offset, const_cast(*m_end_container), m_end_offset); } JS::NonnullGCPtr Range::inverted() const { - return heap().allocate(shape().realm(), const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset); + return shape().realm().create(const_cast(*m_end_container), m_end_offset, const_cast(*m_start_container), m_start_offset); } JS::NonnullGCPtr Range::normalized() const @@ -607,7 +607,7 @@ WebIDL::ExceptionOr> Range::extract_contents( WebIDL::ExceptionOr> Range::extract() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. - auto fragment = heap().allocate(realm(), const_cast(start_container()->document())); + auto fragment = realm().create(const_cast(start_container()->document())); // 2. If range is collapsed, then return fragment. if (collapsed()) @@ -936,7 +936,7 @@ WebIDL::ExceptionOr> Range::clone_contents() WebIDL::ExceptionOr> Range::clone_the_contents() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. - auto fragment = heap().allocate(realm(), const_cast(start_container()->document())); + auto fragment = realm().create(const_cast(start_container()->document())); // 2. If range is collapsed, then return fragment. if (collapsed()) diff --git a/Libraries/LibWeb/DOM/StaticNodeList.cpp b/Libraries/LibWeb/DOM/StaticNodeList.cpp index 1625c8254df..03d1812a668 100644 --- a/Libraries/LibWeb/DOM/StaticNodeList.cpp +++ b/Libraries/LibWeb/DOM/StaticNodeList.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(StaticNodeList); JS::NonnullGCPtr StaticNodeList::create(JS::Realm& realm, Vector> static_nodes) { - return realm.heap().allocate(realm, realm, move(static_nodes)); + return realm.create(realm, move(static_nodes)); } StaticNodeList::StaticNodeList(JS::Realm& realm, Vector> static_nodes) diff --git a/Libraries/LibWeb/DOM/StaticRange.cpp b/Libraries/LibWeb/DOM/StaticRange.cpp index 5081a81374b..778bb51c5ed 100644 --- a/Libraries/LibWeb/DOM/StaticRange.cpp +++ b/Libraries/LibWeb/DOM/StaticRange.cpp @@ -35,7 +35,7 @@ WebIDL::ExceptionOr> StaticRange::construct_impl(J return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node."_string); // 2. Set this’s start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]). - return realm.heap().allocate(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset); + return realm.create(*init.start_container, init.start_offset, *init.end_container, init.end_offset); } void StaticRange::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/DOM/Text.cpp b/Libraries/LibWeb/DOM/Text.cpp index 275b4729131..fe96a856cf3 100644 --- a/Libraries/LibWeb/DOM/Text.cpp +++ b/Libraries/LibWeb/DOM/Text.cpp @@ -45,7 +45,7 @@ WebIDL::ExceptionOr> Text::construct_impl(JS::Realm& real { // The new Text(data) constructor steps are to set this’s data to data and this’s node document to current global object’s associated Document. auto& window = verify_cast(HTML::current_principal_global_object()); - return realm.heap().allocate(realm, window.associated_document(), data); + return realm.create(window.associated_document(), data); } // https://dom.spec.whatwg.org/#dom-text-splittext @@ -66,7 +66,7 @@ WebIDL::ExceptionOr> Text::split_text(size_t offset) auto new_data = TRY(substring_data(offset, count)); // 5. Let new node be a new Text node, with the same node document as node. Set new node’s data to new data. - auto new_node = heap().allocate(realm(), document(), new_data); + auto new_node = realm().create(document(), new_data); // 6. Let parent be node’s parent. JS::GCPtr parent = this->parent(); diff --git a/Libraries/LibWeb/DOM/TreeWalker.cpp b/Libraries/LibWeb/DOM/TreeWalker.cpp index 8d2c055cd60..697cedd3c9f 100644 --- a/Libraries/LibWeb/DOM/TreeWalker.cpp +++ b/Libraries/LibWeb/DOM/TreeWalker.cpp @@ -45,7 +45,7 @@ JS::NonnullGCPtr TreeWalker::create(Node& root, unsigned what_to_sho // 1. Let walker be a new TreeWalker object. // 2. Set walker’s root and walker’s current to root. auto& realm = root.realm(); - auto walker = realm.heap().allocate(realm, root); + auto walker = realm.create(root); // 3. Set walker’s whatToShow to whatToShow. walker->m_what_to_show = what_to_show; diff --git a/Libraries/LibWeb/DOM/XMLDocument.cpp b/Libraries/LibWeb/DOM/XMLDocument.cpp index 2d1fcce7683..a18a68a1016 100644 --- a/Libraries/LibWeb/DOM/XMLDocument.cpp +++ b/Libraries/LibWeb/DOM/XMLDocument.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(XMLDocument); JS::NonnullGCPtr XMLDocument::create(JS::Realm& realm, URL::URL const& url) { - return realm.heap().allocate(realm, realm, url); + return realm.create(realm, url); } XMLDocument::XMLDocument(JS::Realm& realm, URL::URL const& url) diff --git a/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index 01a1e095b27..ad4c5b0aef2 100644 --- a/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -28,7 +28,7 @@ JS_DEFINE_ALLOCATOR(XMLSerializer); WebIDL::ExceptionOr> XMLSerializer::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } XMLSerializer::XMLSerializer(JS::Realm& realm) diff --git a/Libraries/LibWeb/DOMURL/DOMURL.cpp b/Libraries/LibWeb/DOMURL/DOMURL.cpp index 5fdc33836a9..d008fd21371 100644 --- a/Libraries/LibWeb/DOMURL/DOMURL.cpp +++ b/Libraries/LibWeb/DOMURL/DOMURL.cpp @@ -22,7 +22,7 @@ JS_DEFINE_ALLOCATOR(DOMURL); JS::NonnullGCPtr DOMURL::create(JS::Realm& realm, URL::URL url, JS::NonnullGCPtr query) { - return realm.heap().allocate(realm, realm, move(url), move(query)); + return realm.create(realm, move(url), query); } // https://url.spec.whatwg.org/#api-url-parser diff --git a/Libraries/LibWeb/DOMURL/URLSearchParams.cpp b/Libraries/LibWeb/DOMURL/URLSearchParams.cpp index 4b531c033a4..6cd520a364f 100644 --- a/Libraries/LibWeb/DOMURL/URLSearchParams.cpp +++ b/Libraries/LibWeb/DOMURL/URLSearchParams.cpp @@ -127,7 +127,7 @@ Vector url_decode(StringView input) JS::NonnullGCPtr URLSearchParams::create(JS::Realm& realm, Vector list) { - return realm.heap().allocate(realm, realm, move(list)); + return realm.create(realm, move(list)); } // https://url.spec.whatwg.org/#urlsearchparams-initialize diff --git a/Libraries/LibWeb/DOMURL/URLSearchParamsIterator.cpp b/Libraries/LibWeb/DOMURL/URLSearchParamsIterator.cpp index b2f03fa7d9f..9f030334e38 100644 --- a/Libraries/LibWeb/DOMURL/URLSearchParamsIterator.cpp +++ b/Libraries/LibWeb/DOMURL/URLSearchParamsIterator.cpp @@ -15,7 +15,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm); + auto prototype = realm.create(realm); m_prototypes.set("URLSearchParamsIterator"_fly_string, prototype); } @@ -27,7 +27,7 @@ JS_DEFINE_ALLOCATOR(URLSearchParamsIterator); WebIDL::ExceptionOr> URLSearchParamsIterator::create(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind) { - return url_search_params.heap().allocate(url_search_params.realm(), url_search_params, iteration_kind); + return url_search_params.realm().create(url_search_params, iteration_kind); } URLSearchParamsIterator::URLSearchParamsIterator(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind) diff --git a/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Libraries/LibWeb/Encoding/TextDecoder.cpp index 4664774b738..97b036e6f9d 100644 --- a/Libraries/LibWeb/Encoding/TextDecoder.cpp +++ b/Libraries/LibWeb/Encoding/TextDecoder.cpp @@ -44,7 +44,7 @@ WebIDL::ExceptionOr> TextDecoder::construct_impl(J auto decoder = TextCodec::decoder_for_exact_name(encoding.value()); VERIFY(decoder.has_value()); - return realm.heap().allocate(realm, realm, *decoder, lowercase_encoding_name, fatal, ignore_bom); + return realm.create(realm, *decoder, lowercase_encoding_name, fatal, ignore_bom); } // https://encoding.spec.whatwg.org/#dom-textdecoder diff --git a/Libraries/LibWeb/Encoding/TextEncoder.cpp b/Libraries/LibWeb/Encoding/TextEncoder.cpp index 393cd9b1baf..22b34c8917f 100644 --- a/Libraries/LibWeb/Encoding/TextEncoder.cpp +++ b/Libraries/LibWeb/Encoding/TextEncoder.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(TextEncoder); WebIDL::ExceptionOr> TextEncoder::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } TextEncoder::TextEncoder(JS::Realm& realm) diff --git a/Libraries/LibWeb/EntriesAPI/FileSystemEntry.cpp b/Libraries/LibWeb/EntriesAPI/FileSystemEntry.cpp index 16ea5d2f9a6..ac8dafe1923 100644 --- a/Libraries/LibWeb/EntriesAPI/FileSystemEntry.cpp +++ b/Libraries/LibWeb/EntriesAPI/FileSystemEntry.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(FileSystemEntry); JS::NonnullGCPtr FileSystemEntry::create(JS::Realm& realm, EntryType entry_type, ByteString name) { - return realm.heap().allocate(realm, realm, entry_type, name); + return realm.create(realm, entry_type, name); } FileSystemEntry::FileSystemEntry(JS::Realm& realm, EntryType entry_type, ByteString name) diff --git a/Libraries/LibWeb/Fetch/BodyInit.cpp b/Libraries/LibWeb/Fetch/BodyInit.cpp index 4ec827ced5e..30c4ae10aac 100644 --- a/Libraries/LibWeb/Fetch/BodyInit.cpp +++ b/Libraries/LibWeb/Fetch/BodyInit.cpp @@ -55,7 +55,7 @@ WebIDL::ExceptionOr extract_body(JS::Realm& realm, } // 4. Otherwise, set stream to a new ReadableStream object, and set up stream with byte reading support. else { - stream = realm.heap().allocate(realm, realm); + stream = realm.create(realm); Streams::set_up_readable_stream_controller_with_byte_reading_support(*stream); } diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index f39e5b3a81a..a3df8c1f536 100644 --- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -727,7 +727,7 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const HTML::TemporaryExecutionContext const execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes }; // 1. Let transformStream be a new TransformStream. - auto transform_stream = realm.heap().allocate(realm, realm); + auto transform_stream = realm.create(realm); // 2. Let identityTransformAlgorithm be an algorithm which, given chunk, enqueues chunk in transformStream. auto identity_transform_algorithm = JS::create_heap_function(realm.heap(), [&realm, transform_stream](JS::Value chunk) -> JS::NonnullGCPtr { @@ -2236,8 +2236,8 @@ WebIDL::ExceptionOr> nonstandard_resource_load HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes }; // 12. Let stream be a new ReadableStream. - auto stream = realm.heap().allocate(realm, realm); - auto fetched_data_receiver = realm.heap().allocate(realm, fetch_params, stream); + auto stream = realm.create(realm); + auto fetched_data_receiver = realm.create(fetch_params, stream); // 10. Let pullAlgorithm be the followings steps: auto pull_algorithm = JS::create_heap_function(realm.heap(), [&realm, fetched_data_receiver]() { diff --git a/Libraries/LibWeb/Fetch/Headers.cpp b/Libraries/LibWeb/Fetch/Headers.cpp index 43e1058ad95..5915a7f9c5d 100644 --- a/Libraries/LibWeb/Fetch/Headers.cpp +++ b/Libraries/LibWeb/Fetch/Headers.cpp @@ -20,7 +20,7 @@ WebIDL::ExceptionOr> Headers::construct_impl(JS::Realm auto& vm = realm.vm(); // The new Headers(init) constructor steps are: - auto headers = realm.heap().allocate(realm, realm, Infrastructure::HeaderList::create(vm)); + auto headers = realm.create(realm, Infrastructure::HeaderList::create(vm)); // 1. Set this’s guard to "none". headers->m_guard = Guard::None; diff --git a/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Libraries/LibWeb/Fetch/HeadersIterator.cpp index b2d0d530a0d..6576af8dc48 100644 --- a/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -15,7 +15,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm); + auto prototype = realm.create(realm); m_prototypes.set("HeadersIterator"_fly_string, prototype); } @@ -27,7 +27,7 @@ JS_DEFINE_ALLOCATOR(HeadersIterator); JS::NonnullGCPtr HeadersIterator::create(Headers const& headers, JS::Object::PropertyKind iteration_kind) { - return headers.heap().allocate(headers.realm(), headers, iteration_kind); + return headers.realm().create(headers, iteration_kind); } HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind) diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp index 0037d3548e9..8d0e9c00437 100644 --- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp +++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp @@ -127,7 +127,7 @@ void Body::incrementally_read_loop(Streams::ReadableStreamDefaultReader& reader, { auto& realm = reader.realm(); // 1. Let readRequest be the following read request: - auto read_request = realm.heap().allocate(realm, *this, reader, task_destination, process_body_chunk, process_end_of_body, process_body_error); + auto read_request = realm.create(*this, reader, task_destination, process_body_chunk, process_end_of_body, process_body_error); // 2. Read a chunk from reader given readRequest. reader.read_a_chunk(read_request); diff --git a/Libraries/LibWeb/Fetch/Request.cpp b/Libraries/LibWeb/Fetch/Request.cpp index 9a8568748f9..67bd25e0eb3 100644 --- a/Libraries/LibWeb/Fetch/Request.cpp +++ b/Libraries/LibWeb/Fetch/Request.cpp @@ -85,10 +85,10 @@ JS::NonnullGCPtr Request::create(JS::Realm& realm, JS::NonnullGCPtr(realm, realm, request); + auto request_object = realm.create(realm, request); // 3. Set requestObject’s headers to a new Headers object with realm, whose headers list is request’s headers list and guard is guard. - request_object->m_headers = realm.heap().allocate(realm, realm, request->header_list()); + request_object->m_headers = realm.create(realm, request->header_list()); request_object->m_headers->set_guard(guard); // 4. Set requestObject’s signal to signal. @@ -104,7 +104,7 @@ WebIDL::ExceptionOr> Request::construct_impl(JS::Realm auto& vm = realm.vm(); // Referred to as 'this' in the spec. - auto request_object = realm.heap().allocate(realm, realm, Infrastructure::Request::create(vm)); + auto request_object = realm.create(realm, Infrastructure::Request::create(vm)); // 1. Let request be null. JS::GCPtr input_request; @@ -402,7 +402,7 @@ WebIDL::ExceptionOr> Request::construct_impl(JS::Realm request_object->m_signal = TRY(DOM::AbortSignal::create_dependent_abort_signal(this_relevant_realm, signals)); // 31. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is request’s header list and guard is "request". - request_object->m_headers = realm.heap().allocate(realm, realm, request->header_list()); + request_object->m_headers = realm.create(realm, request->header_list()); request_object->m_headers->set_guard(Headers::Guard::Request); // 32. If this’s request’s mode is "no-cors", then: diff --git a/Libraries/LibWeb/Fetch/Response.cpp b/Libraries/LibWeb/Fetch/Response.cpp index 1f74a9a41fa..fb4a69a3746 100644 --- a/Libraries/LibWeb/Fetch/Response.cpp +++ b/Libraries/LibWeb/Fetch/Response.cpp @@ -74,10 +74,10 @@ JS::NonnullGCPtr Response::create(JS::Realm& realm, JS::NonnullGCPtr(realm, realm, response); + auto response_object = realm.create(realm, response); // 3. Set responseObject’s headers to a new Headers object with realm, whose headers list is response’s headers list and guard is guard. - response_object->m_headers = realm.heap().allocate(realm, realm, response->header_list()); + response_object->m_headers = realm.create(realm, response->header_list()); response_object->m_headers->set_guard(guard); // 4. Return responseObject. @@ -131,14 +131,14 @@ WebIDL::ExceptionOr> Response::construct_impl(JS::Rea auto& vm = realm.vm(); // Referred to as 'this' in the spec. - auto response_object = realm.heap().allocate(realm, realm, Infrastructure::Response::create(vm)); + auto response_object = realm.create(realm, Infrastructure::Response::create(vm)); // 1. Set this’s response to a new response. // NOTE: This is done at the beginning as the 'this' value Response object // cannot exist with a null Infrastructure::Response. // 2. Set this’s headers to a new Headers object with this’s relevant Realm, whose header list is this’s response’s header list and guard is "response". - response_object->m_headers = realm.heap().allocate(realm, realm, response_object->response()->header_list()); + response_object->m_headers = realm.create(realm, response_object->response()->header_list()); response_object->m_headers->set_guard(Headers::Guard::Response); // 3. Let bodyWithType be null. diff --git a/Libraries/LibWeb/FileAPI/Blob.cpp b/Libraries/LibWeb/FileAPI/Blob.cpp index 69e956cfa9c..afe73e5c50d 100644 --- a/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Libraries/LibWeb/FileAPI/Blob.cpp @@ -30,7 +30,7 @@ JS_DEFINE_ALLOCATOR(Blob); JS::NonnullGCPtr Blob::create(JS::Realm& realm, ByteBuffer byte_buffer, String type) { - return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)); + return realm.create(realm, move(byte_buffer), move(type)); } // https://w3c.github.io/FileAPI/#convert-line-endings-to-native @@ -188,7 +188,7 @@ JS::NonnullGCPtr Blob::create(JS::Realm& realm, Optional> { // 1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string. if (!blob_parts.has_value() && !options.has_value()) - return realm.heap().allocate(realm, realm); + return realm.create(realm); ByteBuffer byte_buffer {}; // 2. Let bytes be the result of processing blob parts given blobParts and options. @@ -213,7 +213,7 @@ JS::NonnullGCPtr Blob::create(JS::Realm& realm, Optional> } // 4. Return a Blob object referring to bytes as its associated byte sequence, with its size set to the length of bytes, and its type set to the value of t from the substeps above. - return realm.heap().allocate(realm, realm, move(byte_buffer), move(type)); + return realm.create(realm, move(byte_buffer), move(type)); } WebIDL::ExceptionOr> Blob::construct_impl(JS::Realm& realm, Optional> const& blob_parts, Optional const& options) @@ -305,7 +305,7 @@ WebIDL::ExceptionOr> Blob::slice_blob(Optional start // b. S.size = span. // c. S.type = relativeContentType. auto byte_buffer = TRY_OR_THROW_OOM(vm, m_byte_buffer.slice(relative_start, span)); - return heap().allocate(realm(), realm(), move(byte_buffer), move(relative_content_type)); + return realm().create(realm(), move(byte_buffer), move(relative_content_type)); } // https://w3c.github.io/FileAPI/#dom-blob-stream @@ -321,7 +321,7 @@ JS::NonnullGCPtr Blob::get_stream() auto& realm = this->realm(); // 1. Let stream be a new ReadableStream created in blob’s relevant Realm. - auto stream = realm.heap().allocate(realm, realm); + auto stream = realm.create(realm); // 2. Set up stream with byte reading support. set_up_readable_stream_controller_with_byte_reading_support(stream); diff --git a/Libraries/LibWeb/FileAPI/File.cpp b/Libraries/LibWeb/FileAPI/File.cpp index 14a6e4652f1..67c4e1c5348 100644 --- a/Libraries/LibWeb/FileAPI/File.cpp +++ b/Libraries/LibWeb/FileAPI/File.cpp @@ -38,7 +38,7 @@ File::~File() = default; JS::NonnullGCPtr File::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } // https://w3c.github.io/FileAPI/#ref-for-dom-file-file @@ -79,7 +79,7 @@ WebIDL::ExceptionOr> File::create(JS::Realm& realm, Vecto // 4. F.name is set to n. // 5. F.type is set to t. // 6. F.lastModified is set to d. - return realm.heap().allocate(realm, realm, move(bytes), move(name), move(type), last_modified); + return realm.create(realm, move(bytes), move(name), move(type), last_modified); } WebIDL::ExceptionOr> File::construct_impl(JS::Realm& realm, Vector const& file_bits, String const& file_name, Optional const& options) diff --git a/Libraries/LibWeb/FileAPI/FileList.cpp b/Libraries/LibWeb/FileAPI/FileList.cpp index f2dda3b3e25..0a21892114e 100644 --- a/Libraries/LibWeb/FileAPI/FileList.cpp +++ b/Libraries/LibWeb/FileAPI/FileList.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(FileList); JS::NonnullGCPtr FileList::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } FileList::FileList(JS::Realm& realm) diff --git a/Libraries/LibWeb/FileAPI/FileReader.cpp b/Libraries/LibWeb/FileAPI/FileReader.cpp index 24039eb03b0..acb0581d549 100644 --- a/Libraries/LibWeb/FileAPI/FileReader.cpp +++ b/Libraries/LibWeb/FileAPI/FileReader.cpp @@ -55,7 +55,7 @@ void FileReader::visit_edges(JS::Cell::Visitor& visitor) JS::NonnullGCPtr FileReader::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } JS::NonnullGCPtr FileReader::construct_impl(JS::Realm& realm) diff --git a/Libraries/LibWeb/Geometry/DOMMatrix.cpp b/Libraries/LibWeb/Geometry/DOMMatrix.cpp index f0089ddf920..7c550b2e196 100644 --- a/Libraries/LibWeb/Geometry/DOMMatrix.cpp +++ b/Libraries/LibWeb/Geometry/DOMMatrix.cpp @@ -25,7 +25,7 @@ WebIDL::ExceptionOr> DOMMatrix::construct_impl(JS::R // -> If init is omitted if (!init.has_value()) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with the sequence [1, 0, 0, 1, 0, 0]. - return realm.heap().allocate(realm, realm, 1, 0, 0, 1, 0, 0); + return realm.create(realm, 1, 0, 0, 1, 0, 0); } auto const& init_value = init.value(); @@ -43,11 +43,11 @@ WebIDL::ExceptionOr> DOMMatrix::construct_impl(JS::R // If 2dTransform is true if (result.is_2d_transform) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the elements m11, m12, m21, m22, m41 and m42 of matrix. - return realm.heap().allocate(realm, realm, elements[0][0], elements[1][0], elements[0][1], elements[1][1], elements[0][3], elements[1][3]); + return realm.create(realm, elements[0][0], elements[1][0], elements[0][1], elements[1][1], elements[0][3], elements[1][3]); } // Otherwise, return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 16 elements of matrix. - return realm.heap().allocate(realm, realm, + return realm.create(realm, elements[0][0], elements[1][0], elements[2][0], elements[3][0], elements[0][1], elements[1][1], elements[2][1], elements[3][1], elements[0][2], elements[1][2], elements[2][2], elements[3][2], @@ -59,13 +59,13 @@ WebIDL::ExceptionOr> DOMMatrix::construct_impl(JS::R // -> If init is a sequence with 6 elements if (double_sequence.size() == 6) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with the sequence init. - return realm.heap().allocate(realm, realm, double_sequence[0], double_sequence[1], double_sequence[2], double_sequence[3], double_sequence[4], double_sequence[5]); + return realm.create(realm, double_sequence[0], double_sequence[1], double_sequence[2], double_sequence[3], double_sequence[4], double_sequence[5]); } // -> If init is a sequence with 16 elements if (double_sequence.size() == 16) { // Return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with the sequence init. - return realm.heap().allocate(realm, realm, + return realm.create(realm, double_sequence[0], double_sequence[1], double_sequence[2], double_sequence[3], double_sequence[4], double_sequence[5], double_sequence[6], double_sequence[7], double_sequence[8], double_sequence[9], double_sequence[10], double_sequence[11], @@ -92,7 +92,7 @@ WebIDL::ExceptionOr> DOMMatrix::create_from_dom_matr // 2. Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, // the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); + return realm.create(realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); } // https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary @@ -104,11 +104,11 @@ WebIDL::ExceptionOr> DOMMatrix::create_from_dom_matr // 2. If the is2D dictionary member of other is true. if (init.is2d.has_value() && init.is2d.value()) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); + return realm.create(realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); } // Otherwise, Return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 16 elements m11, m12, m13, ..., m44 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m13, init.m14, + return realm.create(realm, init.m11.value(), init.m12.value(), init.m13, init.m14, init.m21.value(), init.m22.value(), init.m23, init.m24, init.m31, init.m32, init.m33, init.m34, init.m41.value(), init.m42.value(), init.m43, init.m44); @@ -116,12 +116,12 @@ WebIDL::ExceptionOr> DOMMatrix::create_from_dom_matr JS::NonnullGCPtr DOMMatrix::create_from_dom_matrix_read_only(JS::Realm& realm, DOMMatrixReadOnly const& read_only_matrix) { - return realm.heap().allocate(realm, realm, read_only_matrix); + return realm.create(realm, read_only_matrix); } JS::NonnullGCPtr DOMMatrix::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } DOMMatrix::DOMMatrix(JS::Realm& realm, double m11, double m12, double m21, double m22, double m41, double m42) @@ -170,11 +170,11 @@ WebIDL::ExceptionOr> DOMMatrix::from_float32_array(J // If array32 has 6 elements, return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array32 in the provided order. if (elements.size() == 6) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); // If array32 has 16 elements, return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array32 in the provided order. if (elements.size() == 16) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5), elements.at(6), elements.at(7), elements.at(8), elements.at(9), elements.at(10), elements.at(11), elements.at(12), elements.at(13), elements.at(14), elements.at(15)); @@ -195,11 +195,11 @@ WebIDL::ExceptionOr> DOMMatrix::from_float64_array(J // If array64 has 6 elements, return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array64 in the provided order. if (elements.size() == 6) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); // If array64 has 16 elements, return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array64 in the provided order. if (elements.size() == 16) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5), elements.at(6), elements.at(7), elements.at(8), elements.at(9), elements.at(10), elements.at(11), elements.at(12), elements.at(13), elements.at(14), elements.at(15)); diff --git a/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp b/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp index c36df9ab639..91126aba7a4 100644 --- a/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp +++ b/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp @@ -31,7 +31,7 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::cons // -> If init is omitted if (!init.has_value()) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with the sequence [1, 0, 0, 1, 0, 0]. - return realm.heap().allocate(realm, realm, 1, 0, 0, 1, 0, 0); + return realm.create(realm, 1, 0, 0, 1, 0, 0); } auto const& init_value = init.value(); @@ -49,11 +49,11 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::cons // If 2dTransform is true if (result.is_2d_transform) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the elements m11, m12, m21, m22, m41 and m42 of matrix. - return realm.heap().allocate(realm, realm, elements[0][0], elements[1][0], elements[0][1], elements[1][1], elements[0][3], elements[1][3]); + return realm.create(realm, elements[0][0], elements[1][0], elements[0][1], elements[1][1], elements[0][3], elements[1][3]); } // Otherwise, return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 16 elements of matrix. - return realm.heap().allocate(realm, realm, + return realm.create(realm, elements[0][0], elements[1][0], elements[2][0], elements[3][0], elements[0][1], elements[1][1], elements[2][1], elements[3][1], elements[0][2], elements[1][2], elements[2][2], elements[3][2], @@ -65,13 +65,13 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::cons // -> If init is a sequence with 6 elements if (double_sequence.size() == 6) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with the sequence init. - return realm.heap().allocate(realm, realm, double_sequence[0], double_sequence[1], double_sequence[2], double_sequence[3], double_sequence[4], double_sequence[5]); + return realm.create(realm, double_sequence[0], double_sequence[1], double_sequence[2], double_sequence[3], double_sequence[4], double_sequence[5]); } // -> If init is a sequence with 16 elements if (double_sequence.size() == 16) { // Return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with the sequence init. - return realm.heap().allocate(realm, realm, + return realm.create(realm, double_sequence[0], double_sequence[1], double_sequence[2], double_sequence[3], double_sequence[4], double_sequence[5], double_sequence[6], double_sequence[7], double_sequence[8], double_sequence[9], double_sequence[10], double_sequence[11], @@ -98,7 +98,7 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::crea // 2. Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, // the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); + return realm.create(realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); } // https://drafts.fxtf.org/geometry/#create-a-dommatrixreadonly-from-the-dictionary @@ -110,11 +110,11 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::crea // 2. If the is2D dictionary member of other is true. if (init.is2d.has_value() && init.is2d.value()) { // Return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 6 elements m11, m12, m21, m22, m41 and m42 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); + return realm.create(realm, init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value()); } // Otherwise, Return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers, the values being the 16 elements m11, m12, m13, ..., m44 of other in the given order. - return realm.heap().allocate(realm, realm, init.m11.value(), init.m12.value(), init.m13, init.m14, + return realm.create(realm, init.m11.value(), init.m12.value(), init.m13, init.m14, init.m21.value(), init.m22.value(), init.m23, init.m24, init.m31, init.m32, init.m33, init.m34, init.m41.value(), init.m42.value(), init.m43, init.m44); @@ -122,7 +122,7 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::crea JS::NonnullGCPtr DOMMatrixReadOnly::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } DOMMatrixReadOnly::DOMMatrixReadOnly(JS::Realm& realm, double m11, double m12, double m21, double m22, double m41, double m42) @@ -241,11 +241,11 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::from // If array32 has 6 elements, return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array32 in the provided order. if (elements.size() == 6) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); // If array32 has 16 elements, return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array32 in the provided order. if (elements.size() == 16) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5), elements.at(6), elements.at(7), elements.at(8), elements.at(9), elements.at(10), elements.at(11), elements.at(12), elements.at(13), elements.at(14), elements.at(15)); @@ -266,11 +266,11 @@ WebIDL::ExceptionOr> DOMMatrixReadOnly::from // If array64 has 6 elements, return the result of invoking create a 2d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array64 in the provided order. if (elements.size() == 6) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5)); // If array64 has 16 elements, return the result of invoking create a 3d matrix of type DOMMatrixReadOnly or DOMMatrix as appropriate, with a sequence of numbers taking the values from array64 in the provided order. if (elements.size() == 16) - return realm.heap().allocate(realm, realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), + return realm.create(realm, elements.at(0), elements.at(1), elements.at(2), elements.at(3), elements.at(4), elements.at(5), elements.at(6), elements.at(7), elements.at(8), elements.at(9), elements.at(10), elements.at(11), elements.at(12), elements.at(13), elements.at(14), elements.at(15)); diff --git a/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Libraries/LibWeb/Geometry/DOMPoint.cpp index ebcf317cfc2..64975ac9601 100644 --- a/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -15,12 +15,12 @@ JS_DEFINE_ALLOCATOR(DOMPoint); JS::NonnullGCPtr DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { - return realm.heap().allocate(realm, realm, x, y, z, w); + return realm.create(realm, x, y, z, w); } JS::NonnullGCPtr DOMPoint::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w) diff --git a/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp b/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp index 257bc2d45ea..cac5acdc841 100644 --- a/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp +++ b/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp @@ -19,12 +19,12 @@ JS_DEFINE_ALLOCATOR(DOMPointReadOnly); JS::NonnullGCPtr DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w) { - return realm.heap().allocate(realm, realm, x, y, z, w); + return realm.create(realm, x, y, z, w); } JS::NonnullGCPtr DOMPointReadOnly::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double z, double w) diff --git a/Libraries/LibWeb/Geometry/DOMQuad.cpp b/Libraries/LibWeb/Geometry/DOMQuad.cpp index f49bf5610cb..eacddede11e 100644 --- a/Libraries/LibWeb/Geometry/DOMQuad.cpp +++ b/Libraries/LibWeb/Geometry/DOMQuad.cpp @@ -14,12 +14,12 @@ JS_DEFINE_ALLOCATOR(DOMQuad); JS::NonnullGCPtr DOMQuad::construct_impl(JS::Realm& realm, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4) { - return realm.heap().allocate(realm, realm, p1, p2, p3, p4); + return realm.create(realm, p1, p2, p3, p4); } JS::NonnullGCPtr DOMQuad::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } DOMQuad::DOMQuad(JS::Realm& realm, DOMPointInit const& p1, DOMPointInit const& p2, DOMPointInit const& p3, DOMPointInit const& p4) diff --git a/Libraries/LibWeb/Geometry/DOMRect.cpp b/Libraries/LibWeb/Geometry/DOMRect.cpp index 698c32aea31..6fc4eda4b14 100644 --- a/Libraries/LibWeb/Geometry/DOMRect.cpp +++ b/Libraries/LibWeb/Geometry/DOMRect.cpp @@ -20,19 +20,19 @@ WebIDL::ExceptionOr> DOMRect::construct_impl(JS::Realm JS::NonnullGCPtr DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect) { - return realm.heap().allocate(realm, realm, rect.x(), rect.y(), rect.width(), rect.height()); + return realm.create(realm, rect.x(), rect.y(), rect.width(), rect.height()); } JS::NonnullGCPtr DOMRect::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } // https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary JS::NonnullGCPtr DOMRect::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other) { auto& realm = *vm.current_realm(); - return realm.heap().allocate(realm, realm, other.x, other.y, other.width, other.height); + return realm.create(realm, other.x, other.y, other.width, other.height); } DOMRect::DOMRect(JS::Realm& realm, double x, double y, double width, double height) diff --git a/Libraries/LibWeb/Geometry/DOMRectList.cpp b/Libraries/LibWeb/Geometry/DOMRectList.cpp index f7d3d59ba66..5620d586b27 100644 --- a/Libraries/LibWeb/Geometry/DOMRectList.cpp +++ b/Libraries/LibWeb/Geometry/DOMRectList.cpp @@ -20,7 +20,7 @@ JS::NonnullGCPtr DOMRectList::create(JS::Realm& realm, Vector> rects; for (auto& rect : rect_handles) rects.append(*rect); - return realm.heap().allocate(realm, realm, move(rects)); + return realm.create(realm, move(rects)); } DOMRectList::DOMRectList(JS::Realm& realm, Vector> rects) diff --git a/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp b/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp index 2668b6f611b..98d756ec20c 100644 --- a/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp +++ b/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp @@ -17,19 +17,19 @@ JS_DEFINE_ALLOCATOR(DOMRectReadOnly); WebIDL::ExceptionOr> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height) { - return realm.heap().allocate(realm, realm, x, y, width, height); + return realm.create(realm, x, y, width, height); } // https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary JS::NonnullGCPtr DOMRectReadOnly::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other) { auto& realm = *vm.current_realm(); - return realm.heap().allocate(realm, realm, other.x, other.y, other.width, other.height); + return realm.create(realm, other.x, other.y, other.width, other.height); } JS::NonnullGCPtr DOMRectReadOnly::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double width, double height) diff --git a/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp b/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp index 7d76799ee67..68089984fa4 100644 --- a/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp +++ b/Libraries/LibWeb/HTML/AnimatedBitmapDecodedImageData.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(AnimatedBitmapDecodedImageData); ErrorOr> AnimatedBitmapDecodedImageData::create(JS::Realm& realm, Vector&& frames, size_t loop_count, bool animated) { - return realm.heap().allocate(realm, move(frames), loop_count, animated); + return realm.create(move(frames), loop_count, animated); } AnimatedBitmapDecodedImageData::AnimatedBitmapDecodedImageData(Vector&& frames, size_t loop_count, bool animated) diff --git a/Libraries/LibWeb/HTML/BeforeUnloadEvent.cpp b/Libraries/LibWeb/HTML/BeforeUnloadEvent.cpp index 72616bd0629..f61f06c3696 100644 --- a/Libraries/LibWeb/HTML/BeforeUnloadEvent.cpp +++ b/Libraries/LibWeb/HTML/BeforeUnloadEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(BeforeUnloadEvent); JS::NonnullGCPtr BeforeUnloadEvent::create(JS::Realm& realm, FlyString const& event_name, DOM::EventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } BeforeUnloadEvent::BeforeUnloadEvent(JS::Realm& realm, FlyString const& event_name, DOM::EventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/BroadcastChannel.cpp b/Libraries/LibWeb/HTML/BroadcastChannel.cpp index cb80830c564..859dbd78bf8 100644 --- a/Libraries/LibWeb/HTML/BroadcastChannel.cpp +++ b/Libraries/LibWeb/HTML/BroadcastChannel.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(BroadcastChannel); JS::NonnullGCPtr BroadcastChannel::construct_impl(JS::Realm& realm, FlyString const& name) { - return realm.heap().allocate(realm, realm, name); + return realm.create(realm, name); } BroadcastChannel::BroadcastChannel(JS::Realm& realm, FlyString const& name) diff --git a/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Libraries/LibWeb/HTML/BrowsingContext.cpp index c1dc381cb47..dab150414f3 100644 --- a/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -179,7 +179,7 @@ WebIDL::ExceptionOr BrowsingContext auto realm_execution_context = Bindings::create_a_new_javascript_realm( Bindings::main_thread_vm(), [&](JS::Realm& realm) -> JS::Object* { - auto window_proxy = realm.heap().allocate(realm, realm); + auto window_proxy = realm.create(realm); browsing_context->set_window_proxy(window_proxy); // - For the global object, create a new Window object. diff --git a/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Libraries/LibWeb/HTML/CanvasGradient.cpp index 6d1b4ca2177..ec9eee1d129 100644 --- a/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -25,21 +25,21 @@ WebIDL::ExceptionOr> CanvasGradient::create_rad return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"_string); auto radial_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasRadialGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, r0, Gfx::FloatPoint { x1, y1 }, r1)); - return realm.heap().allocate(realm, realm, *radial_gradient); + return realm.create(realm, *radial_gradient); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient WebIDL::ExceptionOr> CanvasGradient::create_linear(JS::Realm& realm, double x0, double y0, double x1, double y1) { auto linear_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasLinearGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, Gfx::FloatPoint { x1, y1 })); - return realm.heap().allocate(realm, realm, *linear_gradient); + return realm.create(realm, *linear_gradient); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient WebIDL::ExceptionOr> CanvasGradient::create_conic(JS::Realm& realm, double start_angle, double x, double y) { auto conic_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasConicGradientPaintStyle::create(Gfx::FloatPoint { x, y }, start_angle)); - return realm.heap().allocate(realm, realm, *conic_gradient); + return realm.create(realm, *conic_gradient); } CanvasGradient::CanvasGradient(JS::Realm& realm, Gfx::GradientPaintStyle& gradient) diff --git a/Libraries/LibWeb/HTML/CanvasPattern.cpp b/Libraries/LibWeb/HTML/CanvasPattern.cpp index 54fe700086d..2b67c5586d6 100644 --- a/Libraries/LibWeb/HTML/CanvasPattern.cpp +++ b/Libraries/LibWeb/HTML/CanvasPattern.cpp @@ -141,7 +141,7 @@ WebIDL::ExceptionOr> CanvasPattern::create(JS::Realm& r // FIXME: 7. If image is not origin-clean, then mark pattern as not origin-clean. // 8. Return pattern. - return realm.heap().allocate(realm, realm, *pattern); + return realm.create(realm, *pattern); } void CanvasPattern::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 351490247d3..64be502b023 100644 --- a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -35,7 +35,7 @@ JS_DEFINE_ALLOCATOR(CanvasRenderingContext2D); JS::NonnullGCPtr CanvasRenderingContext2D::create(JS::Realm& realm, HTMLCanvasElement& element) { - return realm.heap().allocate(realm, realm, element); + return realm.create(realm, element); } CanvasRenderingContext2D::CanvasRenderingContext2D(JS::Realm& realm, HTMLCanvasElement& element) diff --git a/Libraries/LibWeb/HTML/CloseEvent.cpp b/Libraries/LibWeb/HTML/CloseEvent.cpp index a639c2be24a..d3cabefb30c 100644 --- a/Libraries/LibWeb/HTML/CloseEvent.cpp +++ b/Libraries/LibWeb/HTML/CloseEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(CloseEvent); JS::NonnullGCPtr CloseEvent::create(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> CloseEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CloseEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/CloseWatcher.cpp b/Libraries/LibWeb/HTML/CloseWatcher.cpp index d1a5f2d8062..07ade54086f 100644 --- a/Libraries/LibWeb/HTML/CloseWatcher.cpp +++ b/Libraries/LibWeb/HTML/CloseWatcher.cpp @@ -27,7 +27,7 @@ JS::NonnullGCPtr CloseWatcher::establish(HTML::Window& window) VERIFY(window.associated_document().is_fully_active()); // 2. Let closeWatcher be a new close watcher - auto close_watcher = window.heap().allocate(window.realm(), window.realm()); + auto close_watcher = window.realm().create(window.realm()); // 3. Let manager be window's associated close watcher manager auto manager = window.close_watcher_manager(); diff --git a/Libraries/LibWeb/HTML/CloseWatcherManager.cpp b/Libraries/LibWeb/HTML/CloseWatcherManager.cpp index 3b1d66e2f6e..fc1285be3c4 100644 --- a/Libraries/LibWeb/HTML/CloseWatcherManager.cpp +++ b/Libraries/LibWeb/HTML/CloseWatcherManager.cpp @@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(CloseWatcherManager); JS::NonnullGCPtr CloseWatcherManager::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } CloseWatcherManager::CloseWatcherManager(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h b/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h index 25d1d11e90d..b7df4db234d 100644 --- a/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h +++ b/Libraries/LibWeb/HTML/CustomElements/CustomElementDefinition.h @@ -25,7 +25,7 @@ class CustomElementDefinition : public JS::Cell { static JS::NonnullGCPtr create(JS::Realm& realm, String const& name, String const& local_name, WebIDL::CallbackType& constructor, Vector&& observed_attributes, LifecycleCallbacksStorage&& lifecycle_callbacks, bool form_associated, bool disable_internals, bool disable_shadow) { - return realm.heap().allocate(realm, name, local_name, constructor, move(observed_attributes), move(lifecycle_callbacks), form_associated, disable_internals, disable_shadow); + return realm.create(name, local_name, constructor, move(observed_attributes), move(lifecycle_callbacks), form_associated, disable_internals, disable_shadow); } ~CustomElementDefinition() = default; diff --git a/Libraries/LibWeb/HTML/DOMParser.cpp b/Libraries/LibWeb/HTML/DOMParser.cpp index 9903da9e30a..c9ca80a0121 100644 --- a/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Libraries/LibWeb/HTML/DOMParser.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(DOMParser); WebIDL::ExceptionOr> DOMParser::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } DOMParser::DOMParser(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/DOMStringList.cpp b/Libraries/LibWeb/HTML/DOMStringList.cpp index e10b95cb493..49a42cd3080 100644 --- a/Libraries/LibWeb/HTML/DOMStringList.cpp +++ b/Libraries/LibWeb/HTML/DOMStringList.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(DOMStringList); JS::NonnullGCPtr DOMStringList::create(JS::Realm& realm, Vector list) { - return realm.heap().allocate(realm, realm, list); + return realm.create(realm, list); } DOMStringList::DOMStringList(JS::Realm& realm, Vector list) diff --git a/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Libraries/LibWeb/HTML/DOMStringMap.cpp index 66b92af4cc6..f2a045f3326 100644 --- a/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(DOMStringMap); JS::NonnullGCPtr DOMStringMap::create(DOM::Element& element) { auto& realm = element.realm(); - return realm.heap().allocate(realm, element); + return realm.create(element); } DOMStringMap::DOMStringMap(DOM::Element& element) diff --git a/Libraries/LibWeb/HTML/DataTransfer.cpp b/Libraries/LibWeb/HTML/DataTransfer.cpp index e7f9489b1f3..27c48ac51c4 100644 --- a/Libraries/LibWeb/HTML/DataTransfer.cpp +++ b/Libraries/LibWeb/HTML/DataTransfer.cpp @@ -31,7 +31,7 @@ ENUMERATE_DATA_TRANSFER_EFFECTS JS::NonnullGCPtr DataTransfer::create(JS::Realm& realm, NonnullRefPtr drag_data_store) { - return realm.heap().allocate(realm, realm, move(drag_data_store)); + return realm.create(realm, move(drag_data_store)); } // https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer @@ -46,7 +46,7 @@ JS::NonnullGCPtr DataTransfer::construct_impl(JS::Realm& realm) // 3. Set the dropEffect and effectAllowed to "none". // NOTE: This is done by the default-initializers. - return realm.heap().allocate(realm, realm, move(drag_data_store)); + return realm.create(realm, move(drag_data_store)); } DataTransfer::DataTransfer(JS::Realm& realm, NonnullRefPtr drag_data_store) diff --git a/Libraries/LibWeb/HTML/DataTransferItem.cpp b/Libraries/LibWeb/HTML/DataTransferItem.cpp index c4ea795138d..56b8f1c4f84 100644 --- a/Libraries/LibWeb/HTML/DataTransferItem.cpp +++ b/Libraries/LibWeb/HTML/DataTransferItem.cpp @@ -21,7 +21,7 @@ JS_DEFINE_ALLOCATOR(DataTransferItem); JS::NonnullGCPtr DataTransferItem::create(JS::Realm& realm, JS::NonnullGCPtr data_transfer, size_t item_index) { - return realm.heap().allocate(realm, realm, data_transfer, item_index); + return realm.create(realm, data_transfer, item_index); } DataTransferItem::DataTransferItem(JS::Realm& realm, JS::NonnullGCPtr data_transfer, size_t item_index) diff --git a/Libraries/LibWeb/HTML/DataTransferItemList.cpp b/Libraries/LibWeb/HTML/DataTransferItemList.cpp index c0dba11f360..037d8d02d79 100644 --- a/Libraries/LibWeb/HTML/DataTransferItemList.cpp +++ b/Libraries/LibWeb/HTML/DataTransferItemList.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(DataTransferItemList); JS::NonnullGCPtr DataTransferItemList::create(JS::Realm& realm, JS::NonnullGCPtr data_transfer) { - return realm.heap().allocate(realm, realm, data_transfer); + return realm.create(realm, data_transfer); } DataTransferItemList::DataTransferItemList(JS::Realm& realm, JS::NonnullGCPtr data_transfer) diff --git a/Libraries/LibWeb/HTML/DragEvent.cpp b/Libraries/LibWeb/HTML/DragEvent.cpp index 47d1ec087f9..1b79e2cc647 100644 --- a/Libraries/LibWeb/HTML/DragEvent.cpp +++ b/Libraries/LibWeb/HTML/DragEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(DragEvent); JS::NonnullGCPtr DragEvent::create(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y) { - return realm.heap().allocate(realm, realm, event_name, event_init, page_x, page_y, offset_x, offset_y); + return realm.create(realm, event_name, event_init, page_x, page_y, offset_x, offset_y); } WebIDL::ExceptionOr> DragEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/ElementInternals.cpp b/Libraries/LibWeb/HTML/ElementInternals.cpp index d6d9490bcd7..3d1fb721c25 100644 --- a/Libraries/LibWeb/HTML/ElementInternals.cpp +++ b/Libraries/LibWeb/HTML/ElementInternals.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(ElementInternals); JS::NonnullGCPtr ElementInternals::create(JS::Realm& realm, HTMLElement& target_element) { - return realm.heap().allocate(realm, realm, target_element); + return realm.create(realm, target_element); } ElementInternals::ElementInternals(JS::Realm& realm, HTMLElement& target_element) diff --git a/Libraries/LibWeb/HTML/ErrorEvent.cpp b/Libraries/LibWeb/HTML/ErrorEvent.cpp index 83c0f66ac6c..e5a56d48a61 100644 --- a/Libraries/LibWeb/HTML/ErrorEvent.cpp +++ b/Libraries/LibWeb/HTML/ErrorEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(ErrorEvent); JS::NonnullGCPtr ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/EventSource.cpp b/Libraries/LibWeb/HTML/EventSource.cpp index 089006b1b48..66dd6b70ce3 100644 --- a/Libraries/LibWeb/HTML/EventSource.cpp +++ b/Libraries/LibWeb/HTML/EventSource.cpp @@ -37,7 +37,7 @@ WebIDL::ExceptionOr> EventSource::construct_impl(J auto& vm = realm.vm(); // 1. Let ev be a new EventSource object. - auto event_source = realm.heap().allocate(realm, realm); + auto event_source = realm.create(realm); // 2. Let settings be ev's relevant settings object. auto& settings = relevant_settings_object(event_source); diff --git a/Libraries/LibWeb/HTML/FormDataEvent.cpp b/Libraries/LibWeb/HTML/FormDataEvent.cpp index 95e4992aac6..8265199d9a2 100644 --- a/Libraries/LibWeb/HTML/FormDataEvent.cpp +++ b/Libraries/LibWeb/HTML/FormDataEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(FormDataEvent); WebIDL::ExceptionOr> FormDataEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } FormDataEvent::FormDataEvent(JS::Realm& realm, FlyString const& event_name, FormDataEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/HTMLAllCollection.cpp b/Libraries/LibWeb/HTML/HTMLAllCollection.cpp index 92dfff2b648..60fc4ba95a3 100644 --- a/Libraries/LibWeb/HTML/HTMLAllCollection.cpp +++ b/Libraries/LibWeb/HTML/HTMLAllCollection.cpp @@ -34,7 +34,7 @@ JS_DEFINE_ALLOCATOR(HTMLAllCollection); JS::NonnullGCPtr HTMLAllCollection::create(DOM::ParentNode& root, Scope scope, Function filter) { - return root.heap().allocate(root.realm(), root, scope, move(filter)); + return root.realm().create(root, scope, move(filter)); } HTMLAllCollection::HTMLAllCollection(DOM::ParentNode& root, Scope scope, Function filter) diff --git a/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index 4468f335c5c..d150a262d4b 100644 --- a/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -125,7 +125,7 @@ WebIDL::ExceptionOr HTMLDetailsElement::create_shadow_tree_if_needed() auto& realm = this->realm(); // The element is also expected to have an internal shadow tree with two slots. - auto shadow_root = heap().allocate(realm, document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm.create(document(), *this, Bindings::ShadowRootMode::Closed); shadow_root->set_slot_assignment(Bindings::SlotAssignmentMode::Manual); // The first slot is expected to take the details element's first summary element child, if any. diff --git a/Libraries/LibWeb/HTML/HTMLDocument.cpp b/Libraries/LibWeb/HTML/HTMLDocument.cpp index 7c50b53275c..a92f3390616 100644 --- a/Libraries/LibWeb/HTML/HTMLDocument.cpp +++ b/Libraries/LibWeb/HTML/HTMLDocument.cpp @@ -25,7 +25,7 @@ WebIDL::ExceptionOr> HTMLDocument::construct_impl JS::NonnullGCPtr HTMLDocument::create(JS::Realm& realm, URL::URL const& url) { - return realm.heap().allocate(realm, realm, url); + return realm.create(realm, url); } void HTMLDocument::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp index 69997405dd8..c07f8c9f38a 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -211,7 +211,7 @@ JS::NonnullGCPtr HTMLElement::rendered_text_fragment(Stri { // 1. Let fragment be a new DocumentFragment whose node document is document. // Instead of creating a DocumentFragment the nodes are appended directly. - auto fragment = heap().allocate(realm(), document()); + auto fragment = realm().create(document()); // 2. Let position be a position variable for input, initially pointing at the start of input. // 3. Let text be the empty string. diff --git a/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp b/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp index 60e121bc852..c2612778efd 100644 --- a/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormControlsCollection.cpp @@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(HTMLFormControlsCollection); JS::NonnullGCPtr HTMLFormControlsCollection::create(DOM::ParentNode& root, Scope scope, Function filter) { - return root.heap().allocate(root.realm(), root, scope, move(filter)); + return root.realm().create(root, scope, move(filter)); } HTMLFormControlsCollection::HTMLFormControlsCollection(DOM::ParentNode& root, Scope scope, Function filter) diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index aa77427b921..ef44059581e 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -91,12 +91,11 @@ void HTMLInputElement::visit_edges(Cell::Visitor& visitor) // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity JS::NonnullGCPtr HTMLInputElement::validity() const { - auto& vm = this->vm(); auto& realm = this->realm(); dbgln("FIXME: Implement validity attribute getter"); - return vm.heap().allocate(realm, realm); + return realm.create(realm); } JS::GCPtr HTMLInputElement::create_layout_node(CSS::StyleProperties style) @@ -815,18 +814,18 @@ void HTMLInputElement::update_shadow_tree() void HTMLInputElement::create_button_input_shadow_tree() { - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); set_shadow_root(shadow_root); auto text_container = MUST(DOM::create_element(document(), HTML::TagNames::span, Namespace::HTML)); MUST(text_container->set_attribute(HTML::AttributeNames::style, "display: inline-block; pointer-events: none;"_string)); - m_text_node = heap().allocate(realm(), document(), value()); + m_text_node = realm().create(document(), value()); MUST(text_container->append_child(*m_text_node)); MUST(shadow_root->append_child(*text_container)); } void HTMLInputElement::create_text_input_shadow_tree() { - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); set_shadow_root(shadow_root); auto initial_value = m_value; @@ -853,7 +852,7 @@ void HTMLInputElement::create_text_input_shadow_tree() )~~~"_string)); MUST(element->append_child(*m_placeholder_element)); - m_placeholder_text_node = heap().allocate(realm(), document(), String {}); + m_placeholder_text_node = realm().create(document(), String {}); m_placeholder_text_node->set_data(placeholder()); MUST(m_placeholder_element->append_child(*m_placeholder_text_node)); @@ -868,7 +867,7 @@ void HTMLInputElement::create_text_input_shadow_tree() )~~~"_string)); MUST(element->append_child(*m_inner_text_element)); - m_text_node = heap().allocate(realm(), document(), move(initial_value)); + m_text_node = realm().create(document(), move(initial_value)); if (type_state() == TypeAttributeState::FileUpload) { // NOTE: file upload state is mutable, but we don't allow the text node to be modifed m_text_node->set_always_editable(false); @@ -942,7 +941,7 @@ void HTMLInputElement::create_text_input_shadow_tree() void HTMLInputElement::create_color_input_shadow_tree() { - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); auto color = value_sanitization_algorithm(m_value); @@ -981,7 +980,7 @@ void HTMLInputElement::create_file_input_shadow_tree() { auto& realm = this->realm(); - auto shadow_root = heap().allocate(realm, document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm.create(document(), *this, Bindings::ShadowRootMode::Closed); m_file_button = DOM::create_element(document(), HTML::TagNames::button, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); m_file_label = DOM::create_element(document(), HTML::TagNames::label, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); @@ -1026,7 +1025,7 @@ void HTMLInputElement::update_file_input_shadow_tree() void HTMLInputElement::create_range_input_shadow_tree() { - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); set_shadow_root(shadow_root); m_slider_runnable_track = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 9d0f67746d3..537760747ee 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -56,10 +56,10 @@ void HTMLMediaElement::initialize(JS::Realm& realm) Base::initialize(realm); WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLMediaElement); - m_audio_tracks = realm.heap().allocate(realm, realm); - m_video_tracks = realm.heap().allocate(realm, realm); - m_text_tracks = realm.heap().allocate(realm, realm); - m_document_observer = realm.heap().allocate(realm, realm, document()); + m_audio_tracks = realm.create(realm); + m_video_tracks = realm.create(realm); + m_text_tracks = realm.create(realm); + m_document_observer = realm.create(realm, document()); // https://html.spec.whatwg.org/multipage/media.html#playing-the-media-resource:media-element-82 m_document_observer->set_document_became_inactive([this]() { @@ -134,7 +134,6 @@ void HTMLMediaElement::removed_from(DOM::Node* node) void HTMLMediaElement::set_decoder_error(String error_message) { auto& realm = this->realm(); - auto& vm = realm.vm(); // -> If the media data is corrupted // Fatal errors in decoding the media data that occur after the user agent has established whether the current media @@ -148,7 +147,7 @@ void HTMLMediaElement::set_decoder_error(String error_message) m_fetch_controller->stop_fetch(); // 2. Set the error attribute to the result of creating a MediaError with MEDIA_ERR_DECODE. - m_error = vm.heap().allocate(realm, realm, MediaError::Code::Decode, move(error_message)); + m_error = realm.create(realm, MediaError::Code::Decode, move(error_message)); // 3. Set the element's networkState attribute to the NETWORK_IDLE value. m_network_state = NetworkState::Idle; @@ -166,13 +165,12 @@ void HTMLMediaElement::set_decoder_error(String error_message) JS::NonnullGCPtr HTMLMediaElement::buffered() const { auto& realm = this->realm(); - auto& vm = realm.vm(); // FIXME: The buffered attribute must return a new static normalized TimeRanges object that represents the ranges of the // media resource, if any, that the user agent has buffered, at the time the attribute is evaluated. Users agents // must accurately determine the ranges available, even for media streams where this can only be determined by // tedious inspection. - return vm.heap().allocate(realm, realm); + return realm.create(realm); } // https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype @@ -781,7 +779,6 @@ void HTMLMediaElement::children_changed() WebIDL::ExceptionOr HTMLMediaElement::select_resource() { auto& realm = this->realm(); - auto& vm = realm.vm(); // 1. Set the element's networkState attribute to the NETWORK_NO_SOURCE value. m_network_state = NetworkState::NoSource; @@ -919,7 +916,7 @@ WebIDL::ExceptionOr HTMLMediaElement::select_resource() // NOTE: We do not bother with maintaining this pointer. We inspect the DOM tree on the fly, rather than dealing // with the headache of auto-updating this pointer as the DOM changes. - m_source_element_selector = vm.heap().allocate(realm, *this, *candidate); + m_source_element_selector = realm.create(*this, *candidate); TRY(m_source_element_selector->process_candidate()); break; @@ -1099,7 +1096,6 @@ bool HTMLMediaElement::verify_response(JS::NonnullGCPtr HTMLMediaElement::process_media_data(Function failure_callback) { auto& realm = this->realm(); - auto& vm = realm.vm(); auto audio_loader = Audio::Loader::create(m_media_data.bytes()); auto playback_manager = Media::PlaybackManager::from_data(m_media_data); @@ -1122,7 +1118,7 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Function If the media resource is found to have an audio track if (!audio_loader.is_error()) { // 1. Create an AudioTrack object to represent the audio track. - audio_track = vm.heap().allocate(realm, realm, *this, audio_loader.release_value()); + audio_track = realm.create(realm, *this, audio_loader.release_value()); // 2. Update the media element's audioTracks attribute's AudioTrackList object with the new AudioTrack object. m_audio_tracks->add_track({}, *audio_track); @@ -1154,7 +1150,7 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Function If the media resource is found to have a video track if (!playback_manager.is_error()) { // 1. Create a VideoTrack object to represent the video track. - video_track = vm.heap().allocate(realm, realm, *this, playback_manager.release_value()); + video_track = realm.create(realm, *this, playback_manager.release_value()); // 2. Update the media element's videoTracks attribute's VideoTrackList object with the new VideoTrack object. m_video_tracks->add_track({}, *video_track); @@ -1272,10 +1268,9 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Function HTMLMediaElement::handle_media_source_failure(Span> promises, String error_message) { auto& realm = this->realm(); - auto& vm = realm.vm(); // 1. Set the error attribute to the result of creating a MediaError with MEDIA_ERR_SRC_NOT_SUPPORTED. - m_error = vm.heap().allocate(realm, realm, MediaError::Code::SrcNotSupported, move(error_message)); + m_error = realm.create(realm, MediaError::Code::SrcNotSupported, move(error_message)); // 2. Forget the media element's media-resource-specific tracks. forget_media_resource_specific_tracks(); diff --git a/Libraries/LibWeb/HTML/HTMLMeterElement.cpp b/Libraries/LibWeb/HTML/HTMLMeterElement.cpp index 4a3234e740c..501b3c1b24f 100644 --- a/Libraries/LibWeb/HTML/HTMLMeterElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMeterElement.cpp @@ -190,7 +190,7 @@ void HTMLMeterElement::create_shadow_tree_if_needed() if (shadow_root()) return; - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); set_shadow_root(shadow_root); auto meter_bar_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); diff --git a/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index be6f49ce236..e7a8ea6cf2a 100644 --- a/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(HTMLOptionsCollection); JS::NonnullGCPtr HTMLOptionsCollection::create(DOM::ParentNode& root, Function filter) { - return root.heap().allocate(root.realm(), root, move(filter)); + return root.realm().create(root, move(filter)); } HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function filter) diff --git a/Libraries/LibWeb/HTML/HTMLProgressElement.cpp b/Libraries/LibWeb/HTML/HTMLProgressElement.cpp index fdef7906fb7..837a7272029 100644 --- a/Libraries/LibWeb/HTML/HTMLProgressElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLProgressElement.cpp @@ -111,7 +111,7 @@ void HTMLProgressElement::create_shadow_tree_if_needed() if (shadow_root()) return; - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); set_shadow_root(shadow_root); auto progress_bar_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 2d7a2f0ea47..bc48c4b551e 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -514,7 +514,7 @@ void HTMLSelectElement::create_shadow_tree_if_needed() if (shadow_root()) return; - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); set_shadow_root(shadow_root); auto border = DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML).release_value_but_fixme_should_propagate_errors(); diff --git a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index f9666c80cb1..f27948c6e98 100644 --- a/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -25,7 +25,7 @@ void HTMLTemplateElement::initialize(JS::Realm& realm) Base::initialize(realm); WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLTemplateElement); - m_content = heap().allocate(realm, m_document->appropriate_template_contents_owner_document()); + m_content = realm.create(m_document->appropriate_template_contents_owner_document()); m_content->set_host(this); } diff --git a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index fed3a3cafdd..5fc445b41ab 100644 --- a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -362,7 +362,7 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed() if (shadow_root()) return; - auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + auto shadow_root = realm().create(document(), *this, Bindings::ShadowRootMode::Closed); set_shadow_root(shadow_root); auto element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); @@ -372,14 +372,14 @@ void HTMLTextAreaElement::create_shadow_tree_if_needed() m_placeholder_element->set_use_pseudo_element(CSS::Selector::PseudoElement::Type::Placeholder); MUST(element->append_child(*m_placeholder_element)); - m_placeholder_text_node = heap().allocate(realm(), document(), String {}); + m_placeholder_text_node = realm().create(document(), String {}); m_placeholder_text_node->set_data(get_attribute_value(HTML::AttributeNames::placeholder)); MUST(m_placeholder_element->append_child(*m_placeholder_text_node)); m_inner_text_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML)); MUST(element->append_child(*m_inner_text_element)); - m_text_node = heap().allocate(realm(), document(), String {}); + m_text_node = realm().create(document(), String {}); handle_readonly_attribute(attribute(HTML::AttributeNames::readonly)); // NOTE: If `children_changed()` was called before now, `m_raw_value` will hold the text content. // Otherwise, it will get filled in whenever that does get called. diff --git a/Libraries/LibWeb/HTML/HashChangeEvent.cpp b/Libraries/LibWeb/HTML/HashChangeEvent.cpp index 78e35921a29..f660c69f2b0 100644 --- a/Libraries/LibWeb/HTML/HashChangeEvent.cpp +++ b/Libraries/LibWeb/HTML/HashChangeEvent.cpp @@ -16,12 +16,12 @@ JS_DEFINE_ALLOCATOR(HashChangeEvent); [[nodiscard]] JS::NonnullGCPtr HashChangeEvent::create(JS::Realm& realm, FlyString const& event_name, HashChangeEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } JS::NonnullGCPtr HashChangeEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, HashChangeEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } HashChangeEvent::HashChangeEvent(JS::Realm& realm, FlyString const& event_name, HashChangeEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/History.cpp b/Libraries/LibWeb/HTML/History.cpp index c28bea37230..654e416c8b5 100644 --- a/Libraries/LibWeb/HTML/History.cpp +++ b/Libraries/LibWeb/HTML/History.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(History); JS::NonnullGCPtr History::create(JS::Realm& realm, DOM::Document& document) { - return realm.heap().allocate(realm, realm, document); + return realm.create(realm, document); } History::History(JS::Realm& realm, DOM::Document& document) diff --git a/Libraries/LibWeb/HTML/ImageBitmap.cpp b/Libraries/LibWeb/HTML/ImageBitmap.cpp index 3ba5d4d93ca..3edeeface5c 100644 --- a/Libraries/LibWeb/HTML/ImageBitmap.cpp +++ b/Libraries/LibWeb/HTML/ImageBitmap.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(ImageBitmap); JS::NonnullGCPtr ImageBitmap::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } ImageBitmap::ImageBitmap(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/ImageData.cpp b/Libraries/LibWeb/HTML/ImageData.cpp index 9faa2ddabf4..9eaa5764858 100644 --- a/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Libraries/LibWeb/HTML/ImageData.cpp @@ -32,7 +32,7 @@ WebIDL::ExceptionOr> ImageData::create(JS::Realm& re auto data = TRY(JS::Uint8ClampedArray::create(realm, sw * sh * 4)); auto bitmap = TRY_OR_THROW_OOM(vm, Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::AlphaType::Unpremultiplied, Gfx::IntSize(sw, sh), sw * sizeof(u32), data->data().data())); - return realm.heap().allocate(realm, realm, bitmap, data); + return realm.create(realm, bitmap, data); } WebIDL::ExceptionOr> ImageData::construct_impl(JS::Realm& realm, u32 sw, u32 sh, Optional const& settings) @@ -76,7 +76,7 @@ WebIDL::ExceptionOr> ImageData::create(JS::Realm& re // 7. Initialize this given sw, sh, settings set to settings, and source set to data. auto bitmap = TRY_OR_THROW_OOM(vm, Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::AlphaType::Unpremultiplied, Gfx::IntSize(sw, height), sw * sizeof(u32), uint8_clamped_array_data.data().data())); - return realm.heap().allocate(realm, realm, bitmap, uint8_clamped_array_data); + return realm.create(realm, bitmap, uint8_clamped_array_data); } WebIDL::ExceptionOr> ImageData::construct_impl(JS::Realm& realm, JS::Handle const& data, u32 sw, Optional sh, Optional const& settings) diff --git a/Libraries/LibWeb/HTML/ImageRequest.cpp b/Libraries/LibWeb/HTML/ImageRequest.cpp index 0c7f93c905a..d77290fdb93 100644 --- a/Libraries/LibWeb/HTML/ImageRequest.cpp +++ b/Libraries/LibWeb/HTML/ImageRequest.cpp @@ -25,7 +25,7 @@ JS_DEFINE_ALLOCATOR(ImageRequest); JS::NonnullGCPtr ImageRequest::create(JS::Realm& realm, JS::NonnullGCPtr page) { - return realm.heap().allocate(realm, page); + return realm.create(page); } ImageRequest::ImageRequest(JS::NonnullGCPtr page) diff --git a/Libraries/LibWeb/HTML/MessageChannel.cpp b/Libraries/LibWeb/HTML/MessageChannel.cpp index 591d14467cb..4697e889d5d 100644 --- a/Libraries/LibWeb/HTML/MessageChannel.cpp +++ b/Libraries/LibWeb/HTML/MessageChannel.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(MessageChannel); WebIDL::ExceptionOr> MessageChannel::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } MessageChannel::MessageChannel(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/MessageEvent.cpp b/Libraries/LibWeb/HTML/MessageEvent.cpp index f09f26a2690..75e9deaba08 100644 --- a/Libraries/LibWeb/HTML/MessageEvent.cpp +++ b/Libraries/LibWeb/HTML/MessageEvent.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(MessageEvent); JS::NonnullGCPtr MessageEvent::create(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> MessageEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MessageEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/MessagePort.cpp b/Libraries/LibWeb/HTML/MessagePort.cpp index 8bcf90b1b41..7771e1d99f2 100644 --- a/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Libraries/LibWeb/HTML/MessagePort.cpp @@ -38,7 +38,7 @@ static HashTable>& all_message_ports() JS::NonnullGCPtr MessagePort::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } MessagePort::MessagePort(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/NavigateEvent.cpp b/Libraries/LibWeb/HTML/NavigateEvent.cpp index 50088dd4673..a6639e17f62 100644 --- a/Libraries/LibWeb/HTML/NavigateEvent.cpp +++ b/Libraries/LibWeb/HTML/NavigateEvent.cpp @@ -27,7 +27,7 @@ JS_DEFINE_ALLOCATOR(NavigateEvent); JS::NonnullGCPtr NavigateEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, NavigateEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } NavigateEvent::NavigateEvent(JS::Realm& realm, FlyString const& event_name, NavigateEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/Navigation.cpp b/Libraries/LibWeb/HTML/Navigation.cpp index 945d243c057..65cc0cdda48 100644 --- a/Libraries/LibWeb/HTML/Navigation.cpp +++ b/Libraries/LibWeb/HTML/Navigation.cpp @@ -64,7 +64,7 @@ void NavigationAPIMethodTracker::visit_edges(Cell::Visitor& visitor) JS::NonnullGCPtr Navigation::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } Navigation::Navigation(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/NavigationCurrentEntryChangeEvent.cpp b/Libraries/LibWeb/HTML/NavigationCurrentEntryChangeEvent.cpp index 944304e9195..eeef4b3b82f 100644 --- a/Libraries/LibWeb/HTML/NavigationCurrentEntryChangeEvent.cpp +++ b/Libraries/LibWeb/HTML/NavigationCurrentEntryChangeEvent.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(NavigationCurrentEntryChangeEvent); JS::NonnullGCPtr NavigationCurrentEntryChangeEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, NavigationCurrentEntryChangeEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } NavigationCurrentEntryChangeEvent::NavigationCurrentEntryChangeEvent(JS::Realm& realm, FlyString const& event_name, NavigationCurrentEntryChangeEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/NavigationDestination.cpp b/Libraries/LibWeb/HTML/NavigationDestination.cpp index c04dcf7c210..2e573952909 100644 --- a/Libraries/LibWeb/HTML/NavigationDestination.cpp +++ b/Libraries/LibWeb/HTML/NavigationDestination.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(NavigationDestination); JS::NonnullGCPtr NavigationDestination::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } NavigationDestination::NavigationDestination(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp b/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp index f1224dcef45..078db760779 100644 --- a/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp +++ b/Libraries/LibWeb/HTML/NavigationHistoryEntry.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(NavigationHistoryEntry); JS::NonnullGCPtr NavigationHistoryEntry::create(JS::Realm& realm, JS::NonnullGCPtr she) { - return realm.heap().allocate(realm, realm, she); + return realm.create(realm, she); } NavigationHistoryEntry::NavigationHistoryEntry(JS::Realm& realm, JS::NonnullGCPtr she) diff --git a/Libraries/LibWeb/HTML/NavigationTransition.cpp b/Libraries/LibWeb/HTML/NavigationTransition.cpp index 43373240858..3bdcd3a196a 100644 --- a/Libraries/LibWeb/HTML/NavigationTransition.cpp +++ b/Libraries/LibWeb/HTML/NavigationTransition.cpp @@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(NavigationTransition); JS::NonnullGCPtr NavigationTransition::create(JS::Realm& realm, Bindings::NavigationType navigation_type, JS::NonnullGCPtr from_entry, JS::NonnullGCPtr finished_promise) { - return realm.heap().allocate(realm, realm, navigation_type, from_entry, finished_promise); + return realm.create(realm, navigation_type, from_entry, finished_promise); } NavigationTransition::NavigationTransition(JS::Realm& realm, Bindings::NavigationType navigation_type, JS::NonnullGCPtr from_entry, JS::NonnullGCPtr finished_promise) diff --git a/Libraries/LibWeb/HTML/Navigator.cpp b/Libraries/LibWeb/HTML/Navigator.cpp index 83953ab59f6..57e844f67c5 100644 --- a/Libraries/LibWeb/HTML/Navigator.cpp +++ b/Libraries/LibWeb/HTML/Navigator.cpp @@ -24,7 +24,7 @@ JS_DEFINE_ALLOCATOR(Navigator); JS::NonnullGCPtr Navigator::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } Navigator::Navigator(JS::Realm& realm) @@ -73,28 +73,28 @@ void Navigator::visit_edges(Cell::Visitor& visitor) JS::NonnullGCPtr Navigator::mime_types() { if (!m_mime_type_array) - m_mime_type_array = heap().allocate(realm(), realm()); + m_mime_type_array = realm().create(realm()); return *m_mime_type_array; } JS::NonnullGCPtr Navigator::plugins() { if (!m_plugin_array) - m_plugin_array = heap().allocate(realm(), realm()); + m_plugin_array = realm().create(realm()); return *m_plugin_array; } JS::NonnullGCPtr Navigator::clipboard() { if (!m_clipboard) - m_clipboard = heap().allocate(realm(), realm()); + m_clipboard = realm().create(realm()); return *m_clipboard; } JS::NonnullGCPtr Navigator::user_activation() { if (!m_user_activation) - m_user_activation = heap().allocate(realm(), realm()); + m_user_activation = realm().create(realm()); return *m_user_activation; } @@ -120,14 +120,14 @@ Optional Navigator::do_not_track() const JS::NonnullGCPtr Navigator::service_worker() { if (!m_service_worker_container) - m_service_worker_container = heap().allocate(realm(), realm()); + m_service_worker_container = realm().create(realm()); return *m_service_worker_container; } JS::NonnullGCPtr Navigator::media_capabilities() { if (!m_media_capabilities) - m_media_capabilities = heap().allocate(realm(), realm()); + m_media_capabilities = realm().create(realm()); return *m_media_capabilities; } diff --git a/Libraries/LibWeb/HTML/PageTransitionEvent.cpp b/Libraries/LibWeb/HTML/PageTransitionEvent.cpp index fb1cde99138..b2dc94c0a16 100644 --- a/Libraries/LibWeb/HTML/PageTransitionEvent.cpp +++ b/Libraries/LibWeb/HTML/PageTransitionEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(PageTransitionEvent); JS::NonnullGCPtr PageTransitionEvent::create(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> PageTransitionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PageTransitionEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 91b5f45704b..9869d0763e0 100644 --- a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -526,13 +526,13 @@ void HTMLParser::handle_initial(HTMLToken& token) } if (token.is_comment()) { - auto comment = realm().heap().allocate(realm(), document(), token.comment()); + auto comment = realm().create(document(), token.comment()); MUST(document().append_child(*comment)); return; } if (token.is_doctype()) { - auto doctype = realm().heap().allocate(realm(), document()); + auto doctype = realm().create(document()); doctype->set_name(token.doctype_data().name); doctype->set_public_id(token.doctype_data().public_identifier); doctype->set_system_id(token.doctype_data().system_identifier); @@ -561,7 +561,7 @@ void HTMLParser::handle_before_html(HTMLToken& token) // -> A comment token if (token.is_comment()) { // Insert a comment as the last child of the Document object. - auto comment = realm().heap().allocate(realm(), document(), token.comment()); + auto comment = realm().create(document(), token.comment()); MUST(document().append_child(*comment)); return; } @@ -736,7 +736,7 @@ JS::NonnullGCPtr HTMLParser::create_element_for(HTMLToken const& t // 10. Append each attribute in the given token to element. token.for_each_attribute([&](auto const& attribute) { DOM::QualifiedName qualified_name { attribute.local_name, attribute.prefix, attribute.namespace_ }; - auto dom_attribute = realm().heap().allocate(realm(), *document, move(qualified_name), attribute.value, element); + auto dom_attribute = realm().create(*document, move(qualified_name), attribute.value, element); element->append_attribute(dom_attribute); return IterationDecision::Continue; }); @@ -857,7 +857,7 @@ AnythingElse: void HTMLParser::insert_comment(HTMLToken& token) { auto adjusted_insertion_location = find_appropriate_place_for_inserting_node(); - adjusted_insertion_location.parent->insert_before(realm().heap().allocate(realm(), document(), token.comment()), adjusted_insertion_location.insert_before_sibling); + adjusted_insertion_location.parent->insert_before(realm().create(document(), token.comment()), adjusted_insertion_location.insert_before_sibling); } void HTMLParser::handle_in_head(HTMLToken& token) @@ -1183,7 +1183,7 @@ DOM::Text* HTMLParser::find_character_insertion_node() if (adjusted_insertion_location.insert_before_sibling) { if (is_empty_text_node(adjusted_insertion_location.insert_before_sibling->previous_sibling())) return static_cast(adjusted_insertion_location.insert_before_sibling->previous_sibling()); - auto new_text_node = realm().heap().allocate(realm(), document(), String {}); + auto new_text_node = realm().create(document(), String {}); adjusted_insertion_location.parent->insert_before(*new_text_node, *adjusted_insertion_location.insert_before_sibling); return new_text_node; } @@ -1191,7 +1191,7 @@ DOM::Text* HTMLParser::find_character_insertion_node() return nullptr; if (is_empty_text_node(adjusted_insertion_location.parent->last_child())) return static_cast(adjusted_insertion_location.parent->last_child()); - auto new_text_node = realm().heap().allocate(realm(), document(), String {}); + auto new_text_node = realm().create(document(), String {}); MUST(adjusted_insertion_location.parent->append_child(*new_text_node)); return new_text_node; } @@ -1316,7 +1316,7 @@ void HTMLParser::handle_after_body(HTMLToken& token) if (token.is_comment()) { auto& insertion_location = m_stack_of_open_elements.first(); - MUST(insertion_location.append_child(realm().heap().allocate(realm(), document(), token.comment()))); + MUST(insertion_location.append_child(realm().create(document(), token.comment()))); return; } @@ -1352,7 +1352,7 @@ void HTMLParser::handle_after_body(HTMLToken& token) void HTMLParser::handle_after_after_body(HTMLToken& token) { if (token.is_comment()) { - auto comment = realm().heap().allocate(realm(), document(), token.comment()); + auto comment = realm().create(document(), token.comment()); MUST(document().append_child(*comment)); return; } @@ -4104,7 +4104,7 @@ void HTMLParser::handle_after_frameset(HTMLToken& token) void HTMLParser::handle_after_after_frameset(HTMLToken& token) { if (token.is_comment()) { - auto comment = document().heap().allocate(document().realm(), document(), token.comment()); + auto comment = document().realm().create(document(), token.comment()); MUST(document().append_child(comment)); return; } diff --git a/Libraries/LibWeb/HTML/Path2D.cpp b/Libraries/LibWeb/HTML/Path2D.cpp index 814ab0ed8a0..69e05631318 100644 --- a/Libraries/LibWeb/HTML/Path2D.cpp +++ b/Libraries/LibWeb/HTML/Path2D.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(Path2D); WebIDL::ExceptionOr> Path2D::construct_impl(JS::Realm& realm, Optional, String>> const& path) { - return realm.heap().allocate(realm, realm, path); + return realm.create(realm, path); } // https://html.spec.whatwg.org/multipage/canvas.html#dom-path2d diff --git a/Libraries/LibWeb/HTML/PopStateEvent.cpp b/Libraries/LibWeb/HTML/PopStateEvent.cpp index 7f5fa7cbf54..0a29203bdc2 100644 --- a/Libraries/LibWeb/HTML/PopStateEvent.cpp +++ b/Libraries/LibWeb/HTML/PopStateEvent.cpp @@ -16,12 +16,12 @@ JS_DEFINE_ALLOCATOR(PopStateEvent); [[nodiscard]] JS::NonnullGCPtr PopStateEvent::create(JS::Realm& realm, FlyString const& event_name, PopStateEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } JS::NonnullGCPtr PopStateEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PopStateEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } PopStateEvent::PopStateEvent(JS::Realm& realm, FlyString const& event_name, PopStateEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp b/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp index 17dd435ed98..c86ee4fc6a9 100644 --- a/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp +++ b/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(PromiseRejectionEvent); JS::NonnullGCPtr PromiseRejectionEvent::create(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> PromiseRejectionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, PromiseRejectionEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/RadioNodeList.cpp b/Libraries/LibWeb/HTML/RadioNodeList.cpp index 22bb7722a65..a8c97af6f32 100644 --- a/Libraries/LibWeb/HTML/RadioNodeList.cpp +++ b/Libraries/LibWeb/HTML/RadioNodeList.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(RadioNodeList); JS::NonnullGCPtr RadioNodeList::create(JS::Realm& realm, DOM::Node const& root, Scope scope, Function filter) { - return realm.heap().allocate(realm, realm, root, scope, move(filter)); + return realm.create(realm, root, scope, move(filter)); } RadioNodeList::RadioNodeList(JS::Realm& realm, DOM::Node const& root, Scope scope, Function filter) diff --git a/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Libraries/LibWeb/HTML/Scripting/Environments.cpp index c49be26c31f..5dd17069a8f 100644 --- a/Libraries/LibWeb/HTML/Scripting/Environments.cpp +++ b/Libraries/LibWeb/HTML/Scripting/Environments.cpp @@ -520,7 +520,7 @@ SerializedEnvironmentSettingsObject EnvironmentSettingsObject::serialize() JS::NonnullGCPtr EnvironmentSettingsObject::storage_manager() { if (!m_storage_manager) - m_storage_manager = realm().heap().allocate(realm(), realm()); + m_storage_manager = realm().create(realm()); return *m_storage_manager; } diff --git a/Libraries/LibWeb/HTML/Scripting/ImportMapParseResult.cpp b/Libraries/LibWeb/HTML/Scripting/ImportMapParseResult.cpp index 132cb0c873f..7914c70b86f 100644 --- a/Libraries/LibWeb/HTML/Scripting/ImportMapParseResult.cpp +++ b/Libraries/LibWeb/HTML/Scripting/ImportMapParseResult.cpp @@ -23,7 +23,7 @@ ImportMapParseResult::~ImportMapParseResult() = default; JS::NonnullGCPtr ImportMapParseResult::create(JS::Realm& realm, ByteString const& input, URL::URL base_url) { // 1. Let result be an import map parse result whose import map is null and whose error to rethrow is null. - auto result = realm.heap().allocate(realm); + auto result = realm.create(); // 2. Parse an import map string given input and baseURL, catching any exceptions. auto import_map = parse_import_map_string(realm, input, base_url); diff --git a/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp b/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp index d1aa7c2d679..32e997dd850 100644 --- a/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp +++ b/Libraries/LibWeb/HTML/Scripting/ModuleScript.cpp @@ -40,7 +40,7 @@ WebIDL::ExceptionOr> JavaScriptModuleScript::c // 2. Let script be a new module script that this algorithm will subsequently initialize. // 3. Set script's realm to realm. // 4. Set script's base URL to baseURL. - auto script = realm.heap().allocate(realm, move(base_url), filename, realm); + auto script = realm.create(move(base_url), filename, realm); // FIXME: 5. Set script's fetch options to options. diff --git a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp index a83289eed3d..92dd0ba9f2d 100644 --- a/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp +++ b/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp @@ -40,7 +40,7 @@ void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation // 3. Let settings object be a new environment settings object whose algorithms are defined as follows: // NOTE: See the functions defined for this class. - auto settings_object = realm->heap().allocate(*realm, window, move(execution_context)); + auto settings_object = realm->create(window, move(execution_context)); // 4. If reservedEnvironment is non-null, then: if (reserved_environment) { @@ -73,7 +73,7 @@ void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation // 7. Set realm's [[HostDefined]] field to settings object. // Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object - auto intrinsics = realm->heap().allocate(*realm, *realm); + auto intrinsics = realm->create(*realm); auto host_defined = make(settings_object, intrinsics, page); realm->set_host_defined(move(host_defined)); diff --git a/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp b/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp index 8ae95f0b0bd..04b7db168b6 100644 --- a/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp +++ b/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.cpp @@ -32,7 +32,7 @@ JS::NonnullGCPtr WorkerEnvironmentSettingsObjec // 4. Let settings object be a new environment settings object whose algorithms are defined as follows: // NOTE: See the functions defined for this class. - auto settings_object = realm->heap().allocate(*realm, move(execution_context), worker); + auto settings_object = realm->create(move(execution_context), worker); settings_object->target_browsing_context = nullptr; settings_object->m_origin = move(inherited_origin); @@ -44,7 +44,7 @@ JS::NonnullGCPtr WorkerEnvironmentSettingsObjec // FIXME: 7. Otherwise, set settings object's top-level origin to an implementation-defined value. // 8. Set realm's [[HostDefined]] field to settings object. - auto intrinsics = realm->heap().allocate(*realm, *realm); + auto intrinsics = realm->create(*realm); auto host_defined = make(settings_object, intrinsics, page); realm->set_host_defined(move(host_defined)); diff --git a/Libraries/LibWeb/HTML/ServiceWorker.cpp b/Libraries/LibWeb/HTML/ServiceWorker.cpp index 1895ab2cb66..ed4e93c3421 100644 --- a/Libraries/LibWeb/HTML/ServiceWorker.cpp +++ b/Libraries/LibWeb/HTML/ServiceWorker.cpp @@ -22,7 +22,7 @@ ServiceWorker::~ServiceWorker() = default; JS::NonnullGCPtr ServiceWorker::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm, ""_string); + return realm.create(realm, ""_string); } void ServiceWorker::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/ServiceWorkerContainer.cpp b/Libraries/LibWeb/HTML/ServiceWorkerContainer.cpp index 57a0e9f4663..f4b79db84b2 100644 --- a/Libraries/LibWeb/HTML/ServiceWorkerContainer.cpp +++ b/Libraries/LibWeb/HTML/ServiceWorkerContainer.cpp @@ -40,7 +40,7 @@ void ServiceWorkerContainer::visit_edges(Cell::Visitor& visitor) JS::NonnullGCPtr ServiceWorkerContainer::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } // https://w3c.github.io/ServiceWorker/#navigator-service-worker-register diff --git a/Libraries/LibWeb/HTML/ServiceWorkerRegistration.cpp b/Libraries/LibWeb/HTML/ServiceWorkerRegistration.cpp index d893db60612..15bc0cb2a7d 100644 --- a/Libraries/LibWeb/HTML/ServiceWorkerRegistration.cpp +++ b/Libraries/LibWeb/HTML/ServiceWorkerRegistration.cpp @@ -26,6 +26,6 @@ void ServiceWorkerRegistration::initialize(JS::Realm& realm) JS::NonnullGCPtr ServiceWorkerRegistration::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } } diff --git a/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp b/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp index 85ba85fdeaf..d26f006c48c 100644 --- a/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp +++ b/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp @@ -21,7 +21,7 @@ ShadowRealmGlobalScope::~ShadowRealmGlobalScope() = default; JS::NonnullGCPtr ShadowRealmGlobalScope::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } void ShadowRealmGlobalScope::initialize(JS::Realm&) diff --git a/Libraries/LibWeb/HTML/SharedResourceRequest.cpp b/Libraries/LibWeb/HTML/SharedResourceRequest.cpp index 524b6c3b8a2..eb4425fb830 100644 --- a/Libraries/LibWeb/HTML/SharedResourceRequest.cpp +++ b/Libraries/LibWeb/HTML/SharedResourceRequest.cpp @@ -30,7 +30,7 @@ JS::NonnullGCPtr SharedResourceRequest::get_or_create(JS: auto& shared_resource_requests = document->shared_resource_requests(); if (auto it = shared_resource_requests.find(url); it != shared_resource_requests.end()) return *it->value; - auto request = realm.heap().allocate(realm, page, url, *document); + auto request = realm.create(page, url, *document); shared_resource_requests.set(url, request); return request; } diff --git a/Libraries/LibWeb/HTML/Storage.cpp b/Libraries/LibWeb/HTML/Storage.cpp index c5d1a04f967..26a655d48f4 100644 --- a/Libraries/LibWeb/HTML/Storage.cpp +++ b/Libraries/LibWeb/HTML/Storage.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(Storage); JS::NonnullGCPtr Storage::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } Storage::Storage(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/SubmitEvent.cpp b/Libraries/LibWeb/HTML/SubmitEvent.cpp index 41b6f38ced2..8e32ba57aee 100644 --- a/Libraries/LibWeb/HTML/SubmitEvent.cpp +++ b/Libraries/LibWeb/HTML/SubmitEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SubmitEvent); JS::NonnullGCPtr SubmitEvent::create(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> SubmitEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, SubmitEventInit const& event_init) diff --git a/Libraries/LibWeb/HTML/TextMetrics.cpp b/Libraries/LibWeb/HTML/TextMetrics.cpp index dec8ccdfcc4..c12b21bacc8 100644 --- a/Libraries/LibWeb/HTML/TextMetrics.cpp +++ b/Libraries/LibWeb/HTML/TextMetrics.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(TextMetrics); JS::NonnullGCPtr TextMetrics::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } TextMetrics::TextMetrics(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/TextTrack.cpp b/Libraries/LibWeb/HTML/TextTrack.cpp index 7f691ccc397..ba6474cae48 100644 --- a/Libraries/LibWeb/HTML/TextTrack.cpp +++ b/Libraries/LibWeb/HTML/TextTrack.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(TextTrack); JS::NonnullGCPtr TextTrack::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } TextTrack::TextTrack(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/ToggleEvent.cpp b/Libraries/LibWeb/HTML/ToggleEvent.cpp index ab5b33c8d35..fe11f74636b 100644 --- a/Libraries/LibWeb/HTML/ToggleEvent.cpp +++ b/Libraries/LibWeb/HTML/ToggleEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(ToggleEvent); JS::NonnullGCPtr ToggleEvent::create(JS::Realm& realm, FlyString const& event_name, ToggleEventInit event_init) { - return realm.heap().allocate(realm, realm, event_name, move(event_init)); + return realm.create(realm, event_name, move(event_init)); } WebIDL::ExceptionOr> ToggleEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ToggleEventInit event_init) diff --git a/Libraries/LibWeb/HTML/TrackEvent.cpp b/Libraries/LibWeb/HTML/TrackEvent.cpp index 2a75ec14e29..736c8aea57b 100644 --- a/Libraries/LibWeb/HTML/TrackEvent.cpp +++ b/Libraries/LibWeb/HTML/TrackEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(TrackEvent); JS::NonnullGCPtr TrackEvent::create(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init) { - return realm.heap().allocate(realm, realm, event_name, move(event_init)); + return realm.create(realm, event_name, move(event_init)); } WebIDL::ExceptionOr> TrackEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, TrackEventInit event_init) diff --git a/Libraries/LibWeb/HTML/UserActivation.cpp b/Libraries/LibWeb/HTML/UserActivation.cpp index 719e1f4d42e..c062aedd106 100644 --- a/Libraries/LibWeb/HTML/UserActivation.cpp +++ b/Libraries/LibWeb/HTML/UserActivation.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(UserActivation); WebIDL::ExceptionOr> UserActivation::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } UserActivation::UserActivation(JS::Realm& realm) diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cpp index ade50005a1f..bf23bf85024 100644 --- a/Libraries/LibWeb/HTML/Window.cpp +++ b/Libraries/LibWeb/HTML/Window.cpp @@ -99,7 +99,7 @@ private: JS::NonnullGCPtr Window::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } Window::Window(JS::Realm& realm) @@ -642,11 +642,11 @@ Vector> Window::pdf_viewer_plugin_objects() if (m_pdf_viewer_plugin_objects.is_empty()) { // FIXME: Propagate errors. - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "PDF Viewer"_string)); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Chrome PDF Viewer"_string)); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Chromium PDF Viewer"_string)); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "Microsoft Edge PDF Viewer"_string)); - m_pdf_viewer_plugin_objects.append(realm().heap().allocate(realm(), realm(), "WebKit built-in PDF"_string)); + m_pdf_viewer_plugin_objects.append(realm().create(realm(), "PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().create(realm(), "Chrome PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().create(realm(), "Chromium PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().create(realm(), "Microsoft Edge PDF Viewer"_string)); + m_pdf_viewer_plugin_objects.append(realm().create(realm(), "WebKit built-in PDF"_string)); } return m_pdf_viewer_plugin_objects; @@ -664,8 +664,8 @@ Vector> Window::pdf_viewer_mime_type_objects() return {}; if (m_pdf_viewer_mime_type_objects.is_empty()) { - m_pdf_viewer_mime_type_objects.append(realm().heap().allocate(realm(), realm(), "application/pdf"_string)); - m_pdf_viewer_mime_type_objects.append(realm().heap().allocate(realm(), realm(), "text/pdf"_string)); + m_pdf_viewer_mime_type_objects.append(realm().create(realm(), "application/pdf"_string)); + m_pdf_viewer_mime_type_objects.append(realm().create(realm(), "text/pdf"_string)); } return m_pdf_viewer_mime_type_objects; @@ -687,7 +687,7 @@ JS::NonnullGCPtr Window::count_queuing_strategy_size_funct auto function = JS::NativeFunction::create(realm, move(steps), 0, "size", &realm); // 3. Set globalObject’s count queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object. - m_count_queuing_strategy_size_function = heap().allocate(realm, *function, relevant_settings_object(*this)); + m_count_queuing_strategy_size_function = realm.create(*function, relevant_settings_object(*this)); } return JS::NonnullGCPtr { *m_count_queuing_strategy_size_function }; @@ -711,7 +711,7 @@ JS::NonnullGCPtr Window::byte_length_queuing_strategy_size auto function = JS::NativeFunction::create(realm, move(steps), 1, "size", &realm); // 3. Set globalObject’s byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object. - m_byte_length_queuing_strategy_size_function = heap().allocate(realm, *function, relevant_settings_object(*this)); + m_byte_length_queuing_strategy_size_function = realm.create(*function, relevant_settings_object(*this)); } return JS::NonnullGCPtr { *m_byte_length_queuing_strategy_size_function }; @@ -741,9 +741,9 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge(realm, realm), JS::default_attributes); + define_direct_property("inspector", realm.create(realm), JS::default_attributes); if (s_internals_object_exposed) - define_direct_property("internals", heap().allocate(realm, realm), JS::default_attributes); + define_direct_property("internals", realm.create(realm), JS::default_attributes); return {}; } @@ -878,7 +878,7 @@ JS::NonnullGCPtr Window::location() // The Window object's location getter steps are to return this's Location object. if (!m_location) - m_location = heap().allocate(realm, realm); + m_location = realm.create(realm); return JS::NonnullGCPtr { *m_location }; } @@ -1033,7 +1033,7 @@ JS::NonnullGCPtr Window::navigator() // The navigator and clientInformation getter steps are to return this's associated Navigator. if (!m_navigator) - m_navigator = heap().allocate(realm, realm); + m_navigator = realm.create(realm); return JS::NonnullGCPtr { *m_navigator }; } @@ -1043,7 +1043,7 @@ JS::NonnullGCPtr Window::close_watcher_manager() auto& realm = this->realm(); if (!m_close_watcher_manager) - m_close_watcher_manager = heap().allocate(realm, realm); + m_close_watcher_manager = realm.create(realm); return JS::NonnullGCPtr { *m_close_watcher_manager }; } @@ -1222,7 +1222,7 @@ JS::NonnullGCPtr Window::get_computed_style(DOM::Eleme // AD-HOC: Just return a ResolvedCSSStyleDeclaration because that's what we have for now. // FIXME: Implement CSSStyleProperties, and then follow the rest of these steps instead. - return heap().allocate(realm(), element, obj_pseudo); + return realm().create(element, obj_pseudo); // 4. Let decls be an empty list of CSS declarations. @@ -1253,7 +1253,7 @@ WebIDL::ExceptionOr> Window::match_media(S auto parsed_media_query_list = parse_media_query_list(CSS::Parser::ParsingContext(associated_document()), query); // 2. Return a new MediaQueryList object, with this's associated Document as the document, with parsed media query list as its associated media query list. - auto media_query_list = heap().allocate(realm(), associated_document(), move(parsed_media_query_list)); + auto media_query_list = realm().create(associated_document(), move(parsed_media_query_list)); associated_document().add_media_query_list(media_query_list); return media_query_list; } @@ -1263,7 +1263,7 @@ JS::NonnullGCPtr Window::screen() { // The screen attribute must return the Screen object associated with the Window object. if (!m_screen) - m_screen = heap().allocate(realm(), *this); + m_screen = realm().create(*this); return JS::NonnullGCPtr { *m_screen }; } @@ -1568,7 +1568,7 @@ void Window::cancel_animation_frame(WebIDL::UnsignedLong handle) AnimationFrameCallbackDriver& Window::animation_frame_callback_driver() { if (!m_animation_frame_callback_driver) - m_animation_frame_callback_driver = heap().allocate(realm()); + m_animation_frame_callback_driver = realm().create(); return *m_animation_frame_callback_driver; } @@ -1649,7 +1649,7 @@ JS::NonnullGCPtr Window::navigation() // to a new Navigation object created in the Window object's relevant realm. if (!m_navigation) { auto& realm = relevant_realm(*this); - m_navigation = heap().allocate(realm, realm); + m_navigation = realm.create(realm); } // The navigation getter steps are to return this's navigation API. @@ -1663,7 +1663,7 @@ JS::NonnullGCPtr Window::custom_elements() // The customElements attribute of the Window interface must return the CustomElementRegistry object for that Window object. if (!m_custom_element_registry) - m_custom_element_registry = heap().allocate(realm, realm); + m_custom_element_registry = realm.create(realm); return JS::NonnullGCPtr { *m_custom_element_registry }; } diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp index 08a1130b6f3..361cbae81a2 100644 --- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp +++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp @@ -535,7 +535,7 @@ void WindowOrWorkerGlobalScopeMixin::queue_the_performance_observer_task() entries_as_gc_ptrs.append(*entry); // 5. Let observerEntryList be a new PerformanceObserverEntryList, with its entry list set to entries. - auto observer_entry_list = realm.heap().allocate(realm, realm, move(entries_as_gc_ptrs)); + auto observer_entry_list = realm.create(realm, move(entries_as_gc_ptrs)); // 6. Let droppedEntriesCount be null. Optional dropped_entries_count; @@ -642,17 +642,16 @@ JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin { auto& realm = this_impl().realm(); if (!m_performance) - m_performance = this_impl().heap().allocate(realm, realm); + m_performance = realm.create(realm); return JS::NonnullGCPtr { *m_performance }; } JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin::indexed_db() { - auto& vm = this_impl().vm(); auto& realm = this_impl().realm(); if (!m_indexed_db) - m_indexed_db = vm.heap().allocate(realm, realm); + m_indexed_db = realm.create(realm); return *m_indexed_db; } @@ -790,7 +789,7 @@ JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin::crypto() auto& realm = platform_object.realm(); if (!m_crypto) - m_crypto = platform_object.heap().allocate(realm, realm); + m_crypto = realm.create(realm); return JS::NonnullGCPtr { *m_crypto }; } diff --git a/Libraries/LibWeb/HTML/Worker.cpp b/Libraries/LibWeb/HTML/Worker.cpp index 8f4ea71e296..a41b351c7e3 100644 --- a/Libraries/LibWeb/HTML/Worker.cpp +++ b/Libraries/LibWeb/HTML/Worker.cpp @@ -71,7 +71,7 @@ WebIDL::ExceptionOr> Worker::create(String const& scrip // 5. Let worker URL be the resulting URL record. // 6. Let worker be a new Worker object. - auto worker = document.heap().allocate(document.realm(), script_url, options, document); + auto worker = document.realm().create(script_url, options, document); // 7. Let outside port be a new MessagePort in outside settings's Realm. auto outside_port = MessagePort::create(outside_settings.realm()); @@ -110,7 +110,7 @@ void Worker::run_a_worker(URL::URL& url, EnvironmentSettingsObject& outside_sett // and is shared. Run the rest of these steps in that agent. // Note: This spawns a new process to act as the 'agent' for the worker. - m_agent = heap().allocate(outside_settings.realm(), url, options, port, outside_settings); + m_agent = outside_settings.realm().create(url, options, port, outside_settings); } // https://html.spec.whatwg.org/multipage/workers.html#dom-worker-terminate diff --git a/Libraries/LibWeb/HTML/WorkerNavigator.cpp b/Libraries/LibWeb/HTML/WorkerNavigator.cpp index 6743c26b0bc..f70d9697d02 100644 --- a/Libraries/LibWeb/HTML/WorkerNavigator.cpp +++ b/Libraries/LibWeb/HTML/WorkerNavigator.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(WorkerNavigator); JS::NonnullGCPtr WorkerNavigator::create(WorkerGlobalScope& global_scope) { - return global_scope.heap().allocate(global_scope.realm(), global_scope); + return global_scope.realm().create(global_scope); } WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope) @@ -43,14 +43,14 @@ void WorkerNavigator::visit_edges(Cell::Visitor& visitor) JS::NonnullGCPtr WorkerNavigator::media_capabilities() { if (!m_media_capabilities) - m_media_capabilities = heap().allocate(realm(), realm()); + m_media_capabilities = realm().create(realm()); return *m_media_capabilities; } JS::NonnullGCPtr WorkerNavigator::service_worker() { if (!m_service_worker_container) - m_service_worker_container = heap().allocate(realm(), realm()); + m_service_worker_container = realm().create(realm()); return *m_service_worker_container; } diff --git a/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Libraries/LibWeb/HighResolutionTime/Performance.cpp index 2149b88def8..808d5902831 100644 --- a/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -48,7 +48,7 @@ JS::GCPtr Performance::timing() { auto& realm = this->realm(); if (!m_timing) - m_timing = heap().allocate(realm, realm); + m_timing = realm.create(realm); return m_timing; } @@ -60,7 +60,7 @@ JS::GCPtr Performance::navigation() u16 type = 0; u16 redirect_count = 0; - m_navigation = heap().allocate(realm, realm, type, redirect_count); + m_navigation = realm.create(realm, type, redirect_count); } return m_navigation; } @@ -305,7 +305,7 @@ WebIDL::ExceptionOr> Performanc // NOTE: Already the default value of `detail`. // 4. Create a new PerformanceMeasure object (entry) with this's relevant realm. - auto entry = realm.heap().allocate(realm, realm, measure_name, start_time, duration, detail); + auto entry = realm.create(realm, measure_name, start_time, duration, detail); // 10. Queue entry. window_or_worker().queue_performance_entry(entry); diff --git a/Libraries/LibWeb/IndexedDB/IDBDatabase.cpp b/Libraries/LibWeb/IndexedDB/IDBDatabase.cpp index 2e00a42857c..f3d9400af51 100644 --- a/Libraries/LibWeb/IndexedDB/IDBDatabase.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBDatabase.cpp @@ -26,7 +26,7 @@ IDBDatabase::~IDBDatabase() = default; JS::NonnullGCPtr IDBDatabase::create(JS::Realm& realm, Database& db) { - return realm.heap().allocate(realm, realm, db); + return realm.create(realm, db); } void IDBDatabase::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp b/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp index db8a9aace34..a5f5cccb1a9 100644 --- a/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp @@ -29,7 +29,7 @@ void IDBOpenDBRequest::initialize(JS::Realm& realm) JS::NonnullGCPtr IDBOpenDBRequest::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } // https://w3c.github.io/IndexedDB/#dom-idbopendbrequest-onblocked diff --git a/Libraries/LibWeb/IndexedDB/IDBVersionChangeEvent.cpp b/Libraries/LibWeb/IndexedDB/IDBVersionChangeEvent.cpp index 315d8ccdf48..f521bfac3cf 100644 --- a/Libraries/LibWeb/IndexedDB/IDBVersionChangeEvent.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBVersionChangeEvent.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(IDBVersionChangeEvent); JS::NonnullGCPtr IDBVersionChangeEvent::create(JS::Realm& realm, FlyString const& event_name, IDBVersionChangeEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } IDBVersionChangeEvent::IDBVersionChangeEvent(JS::Realm& realm, FlyString const& event_name, IDBVersionChangeEventInit const& event_init) diff --git a/Libraries/LibWeb/IndexedDB/Internal/Database.cpp b/Libraries/LibWeb/IndexedDB/Internal/Database.cpp index 2b96b198011..1daa55ccd6a 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/Database.cpp +++ b/Libraries/LibWeb/IndexedDB/Internal/Database.cpp @@ -18,7 +18,7 @@ Database::~Database() = default; JS::NonnullGCPtr Database::create(JS::Realm& realm, String const& name) { - return realm.heap().allocate(realm, realm, name); + return realm.create(realm, name); } void Database::visit_edges(Visitor& visitor) diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp index 6e184c022fc..6319bd7f6c6 100644 --- a/Libraries/LibWeb/Internals/Internals.cpp +++ b/Libraries/LibWeb/Internals/Internals.cpp @@ -161,7 +161,7 @@ void Internals::spoof_current_url(String const& url_string) JS::NonnullGCPtr Internals::create_internal_animation_timeline() { auto& realm = this->realm(); - return realm.heap().allocate(realm, realm); + return realm.create(realm); } void Internals::simulate_drag_start(double x, double y, String const& name, String const& contents) diff --git a/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp b/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp index 50f20f197bd..173113085a7 100644 --- a/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp +++ b/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp @@ -45,7 +45,7 @@ WebIDL::ExceptionOr> IntersectionObserver // 2. Set this’s internal [[callback]] slot to callback. // 8. The thresholds attribute getter will return this sorted thresholds list. // 9. Return this. - return realm.heap().allocate(realm, realm, callback, options.root, move(thresholds)); + return realm.create(realm, callback, options.root, move(thresholds)); } IntersectionObserver::IntersectionObserver(JS::Realm& realm, JS::GCPtr callback, Optional, JS::Handle>> const& root, Vector&& thresholds) diff --git a/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp b/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp index 79b90174a8d..1a060633d70 100644 --- a/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp +++ b/Libraries/LibWeb/IntersectionObserver/IntersectionObserverEntry.cpp @@ -23,7 +23,7 @@ WebIDL::ExceptionOr> IntersectionObs auto bounding_client_rect = Geometry::DOMRectReadOnly::from_rect(vm, options.bounding_client_rect); auto intersection_rect = Geometry::DOMRectReadOnly::from_rect(vm, options.intersection_rect); - return realm.heap().allocate(realm, realm, options.time, root_bounds, bounding_client_rect, intersection_rect, options.is_intersecting, options.intersection_ratio, *options.target); + return realm.create(realm, options.time, root_bounds, bounding_client_rect, intersection_rect, options.is_intersecting, options.intersection_ratio, *options.target); } IntersectionObserverEntry::IntersectionObserverEntry(JS::Realm& realm, HighResolutionTime::DOMHighResTimeStamp time, JS::GCPtr root_bounds, JS::NonnullGCPtr bounding_client_rect, JS::NonnullGCPtr intersection_rect, bool is_intersecting, double intersection_ratio, JS::NonnullGCPtr target) diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp index 0058f33e204..0575b6cbaa8 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -241,7 +241,7 @@ void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Se // FIXME: Handle images, and multiple values if (pseudo_element_content.type == CSS::ContentData::Type::String) { - auto text = document.heap().allocate(document.realm(), document, pseudo_element_content.data); + auto text = document.realm().create(document, pseudo_element_content.data); auto text_node = document.heap().allocate_without_realm(document, *text); text_node->set_generated_for(generated_for, element); diff --git a/Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp b/Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp index 1d262379b40..82211b47d87 100644 --- a/Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp +++ b/Libraries/LibWeb/MediaCapabilitiesAPI/MediaCapabilities.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(MediaCapabilities); JS::NonnullGCPtr MediaCapabilities::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } MediaCapabilities::MediaCapabilities(JS::Realm& realm) diff --git a/Libraries/LibWeb/MediaSourceExtensions/BufferedChangeEvent.cpp b/Libraries/LibWeb/MediaSourceExtensions/BufferedChangeEvent.cpp index 3a524408072..7703fbdf832 100644 --- a/Libraries/LibWeb/MediaSourceExtensions/BufferedChangeEvent.cpp +++ b/Libraries/LibWeb/MediaSourceExtensions/BufferedChangeEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(BufferedChangeEvent); WebIDL::ExceptionOr> BufferedChangeEvent::construct_impl(JS::Realm& realm, AK::FlyString const& type, BufferedChangeEventInit const& event_init) { - return realm.heap().allocate(realm, realm, type, event_init); + return realm.create(realm, type, event_init); } BufferedChangeEvent::BufferedChangeEvent(JS::Realm& realm, AK::FlyString const& type, BufferedChangeEventInit const&) diff --git a/Libraries/LibWeb/MediaSourceExtensions/ManagedMediaSource.cpp b/Libraries/LibWeb/MediaSourceExtensions/ManagedMediaSource.cpp index c928b3b6288..7cf53c42fef 100644 --- a/Libraries/LibWeb/MediaSourceExtensions/ManagedMediaSource.cpp +++ b/Libraries/LibWeb/MediaSourceExtensions/ManagedMediaSource.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(ManagedMediaSource); WebIDL::ExceptionOr> ManagedMediaSource::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } ManagedMediaSource::ManagedMediaSource(JS::Realm& realm) diff --git a/Libraries/LibWeb/MediaSourceExtensions/MediaSource.cpp b/Libraries/LibWeb/MediaSourceExtensions/MediaSource.cpp index d91d9e2630b..8df56855133 100644 --- a/Libraries/LibWeb/MediaSourceExtensions/MediaSource.cpp +++ b/Libraries/LibWeb/MediaSourceExtensions/MediaSource.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(MediaSource); WebIDL::ExceptionOr> MediaSource::construct_impl(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } MediaSource::MediaSource(JS::Realm& realm) diff --git a/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp b/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp index 1f266b08158..a61b589fda7 100644 --- a/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp +++ b/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(PerformanceObserver); WebIDL::ExceptionOr> PerformanceObserver::construct_impl(JS::Realm& realm, JS::GCPtr callback) { - return realm.heap().allocate(realm, realm, callback); + return realm.create(realm, callback); } PerformanceObserver::PerformanceObserver(JS::Realm& realm, JS::GCPtr callback) diff --git a/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp b/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp index 8acd315f505..3e6b97bad4d 100644 --- a/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp +++ b/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(IdleDeadline); JS::NonnullGCPtr IdleDeadline::create(JS::Realm& realm, bool did_timeout) { - return realm.heap().allocate(realm, realm, did_timeout); + return realm.create(realm, did_timeout); } IdleDeadline::IdleDeadline(JS::Realm& realm, bool did_timeout) diff --git a/Libraries/LibWeb/ResizeObserver/ResizeObservation.cpp b/Libraries/LibWeb/ResizeObserver/ResizeObservation.cpp index c2a4f8e844b..598598518fc 100644 --- a/Libraries/LibWeb/ResizeObserver/ResizeObservation.cpp +++ b/Libraries/LibWeb/ResizeObserver/ResizeObservation.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(ResizeObservation); WebIDL::ExceptionOr> ResizeObservation::create(JS::Realm& realm, DOM::Element& target, Bindings::ResizeObserverBoxOptions observed_box) { - return realm.heap().allocate(realm, realm, target, observed_box); + return realm.create(realm, target, observed_box); } ResizeObservation::ResizeObservation(JS::Realm& realm, DOM::Element& target, Bindings::ResizeObserverBoxOptions observed_box) @@ -24,7 +24,7 @@ ResizeObservation::ResizeObservation(JS::Realm& realm, DOM::Element& target, Bin , m_target(target) , m_observed_box(observed_box) { - auto computed_size = realm.heap().allocate(realm, realm); + auto computed_size = realm.create(realm); m_last_reported_sizes.append(computed_size); } diff --git a/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp b/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp index 8111ef3cb57..4864922ff42 100644 --- a/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp +++ b/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(ResizeObserver); // https://drafts.csswg.org/resize-observer/#dom-resizeobserver-resizeobserver WebIDL::ExceptionOr> ResizeObserver::construct_impl(JS::Realm& realm, WebIDL::CallbackType* callback) { - return realm.heap().allocate(realm, realm, callback); + return realm.create(realm, callback); } ResizeObserver::ResizeObserver(JS::Realm& realm, WebIDL::CallbackType* callback) diff --git a/Libraries/LibWeb/ResizeObserver/ResizeObserverEntry.cpp b/Libraries/LibWeb/ResizeObserver/ResizeObserverEntry.cpp index 2910248a069..d2729978b17 100644 --- a/Libraries/LibWeb/ResizeObserver/ResizeObserverEntry.cpp +++ b/Libraries/LibWeb/ResizeObserver/ResizeObserverEntry.cpp @@ -20,7 +20,7 @@ WebIDL::ExceptionOr> ResizeObserverEntry:: { // 1. Let this be a new ResizeObserverEntry. // 2. Set this.target slot to target. - auto resize_observer_entry = realm.heap().allocate(realm, realm, target); + auto resize_observer_entry = realm.create(realm, target); // 3. Set this.borderBoxSize slot to result of calculating box size given target and observedBox of "border-box". auto border_box_size = ResizeObserverSize::calculate_box_size(realm, target, Bindings::ResizeObserverBoxOptions::BorderBox); diff --git a/Libraries/LibWeb/ResizeObserver/ResizeObserverSize.cpp b/Libraries/LibWeb/ResizeObserver/ResizeObserverSize.cpp index 3b48300efee..7e164e7dde5 100644 --- a/Libraries/LibWeb/ResizeObserver/ResizeObserverSize.cpp +++ b/Libraries/LibWeb/ResizeObserver/ResizeObserverSize.cpp @@ -24,7 +24,7 @@ void ResizeObserverSize::initialize(JS::Realm& realm) JS::NonnullGCPtr ResizeObserverSize::calculate_box_size(JS::Realm& realm, DOM::Element& target, Bindings::ResizeObserverBoxOptions observed_box) { // 1. Let computedSize be a new ResizeObserverSize object. - auto computed_size = realm.heap().allocate(realm, realm); + auto computed_size = realm.create(realm); // FIXME: 2. If target is an SVGGraphicsElement that does not have an associated CSS layout box: // Otherwise: diff --git a/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp index acd9e7d9c3e..faeba958e8c 100644 --- a/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp +++ b/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SVGAnimatedLength); JS::NonnullGCPtr SVGAnimatedLength::create(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) { - return realm.heap().allocate(realm, realm, move(base_val), move(anim_val)); + return realm.create(realm, move(base_val), move(anim_val)); } SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) diff --git a/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp b/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp index 57a609d3000..5196dbeaa10 100644 --- a/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp +++ b/Libraries/LibWeb/SVG/SVGAnimatedNumber.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SVGAnimatedNumber); JS::NonnullGCPtr SVGAnimatedNumber::create(JS::Realm& realm, float base_val, float anim_val) { - return realm.heap().allocate(realm, realm, base_val, anim_val); + return realm.create(realm, base_val, anim_val); } SVGAnimatedNumber::SVGAnimatedNumber(JS::Realm& realm, float base_val, float anim_val) diff --git a/Libraries/LibWeb/SVG/SVGAnimatedString.cpp b/Libraries/LibWeb/SVG/SVGAnimatedString.cpp index 2d86402c5a9..5949b0dbb1e 100644 --- a/Libraries/LibWeb/SVG/SVGAnimatedString.cpp +++ b/Libraries/LibWeb/SVG/SVGAnimatedString.cpp @@ -17,7 +17,7 @@ JS_DEFINE_ALLOCATOR(SVGAnimatedString); JS::NonnullGCPtr SVGAnimatedString::create(JS::Realm& realm, JS::NonnullGCPtr element, FlyString reflected_attribute, Optional deprecated_reflected_attribute, Optional initial_value) { - return realm.heap().allocate(realm, realm, element, move(reflected_attribute), move(deprecated_reflected_attribute), move(initial_value)); + return realm.create(realm, element, move(reflected_attribute), move(deprecated_reflected_attribute), move(initial_value)); } SVGAnimatedString::SVGAnimatedString(JS::Realm& realm, JS::NonnullGCPtr element, FlyString reflected_attribute, Optional deprecated_reflected_attribute, Optional initial_value) diff --git a/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cpp b/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cpp index 092156d26ac..012a5e7e352 100644 --- a/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cpp +++ b/Libraries/LibWeb/SVG/SVGAnimatedTransformList.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(SVGAnimatedTransformList); JS::NonnullGCPtr SVGAnimatedTransformList::create(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) { - return realm.heap().allocate(realm, realm, base_val, anim_val); + return realm.create(realm, base_val, anim_val); } SVGAnimatedTransformList::SVGAnimatedTransformList(JS::Realm& realm, JS::NonnullGCPtr base_val, JS::NonnullGCPtr anim_val) diff --git a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 96feea68da3..8a862ae875e 100644 --- a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -63,7 +63,7 @@ ErrorOr> SVGDecodedImageData::create(JS::R MUST(document->append_child(*svg_root)); - return realm.heap().allocate(realm, page, page_client, document, *svg_root); + return realm.create(page, page_client, document, *svg_root); } SVGDecodedImageData::SVGDecodedImageData(JS::NonnullGCPtr page, JS::NonnullGCPtr page_client, JS::NonnullGCPtr document, JS::NonnullGCPtr root_element) diff --git a/Libraries/LibWeb/SVG/SVGLength.cpp b/Libraries/LibWeb/SVG/SVGLength.cpp index 02d3b5152eb..cb9253625c0 100644 --- a/Libraries/LibWeb/SVG/SVGLength.cpp +++ b/Libraries/LibWeb/SVG/SVGLength.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(SVGLength); JS::NonnullGCPtr SVGLength::create(JS::Realm& realm, u8 unit_type, float value) { - return realm.heap().allocate(realm, realm, unit_type, value); + return realm.create(realm, unit_type, value); } JS::NonnullGCPtr SVGLength::from_length_percentage(JS::Realm& realm, CSS::LengthPercentage const& length_percentage) diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 39ea53fb74e..62d8d297a8f 100644 --- a/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -33,7 +33,7 @@ void SVGSVGElement::initialize(JS::Realm& realm) { Base::initialize(realm); WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGSVGElement); - m_view_box_for_bindings = heap().allocate(realm, realm); + m_view_box_for_bindings = realm.create(realm); } void SVGSVGElement::visit_edges(Visitor& visitor) diff --git a/Libraries/LibWeb/SVG/SVGSymbolElement.cpp b/Libraries/LibWeb/SVG/SVGSymbolElement.cpp index 6ac13575f42..662f409cd44 100644 --- a/Libraries/LibWeb/SVG/SVGSymbolElement.cpp +++ b/Libraries/LibWeb/SVG/SVGSymbolElement.cpp @@ -30,7 +30,7 @@ void SVGSymbolElement::initialize(JS::Realm& realm) { Base::initialize(realm); WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGSymbolElement); - m_view_box_for_bindings = heap().allocate(realm, realm); + m_view_box_for_bindings = realm.create(realm); } void SVGSymbolElement::visit_edges(Cell::Visitor& visitor) diff --git a/Libraries/LibWeb/SVG/SVGTransform.cpp b/Libraries/LibWeb/SVG/SVGTransform.cpp index 0c773786f1d..2baf8f3be27 100644 --- a/Libraries/LibWeb/SVG/SVGTransform.cpp +++ b/Libraries/LibWeb/SVG/SVGTransform.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(SVGTransform); JS::NonnullGCPtr SVGTransform::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } SVGTransform::SVGTransform(JS::Realm& realm) diff --git a/Libraries/LibWeb/SVG/SVGTransformList.cpp b/Libraries/LibWeb/SVG/SVGTransformList.cpp index bdd84a6d744..4b60ddee954 100644 --- a/Libraries/LibWeb/SVG/SVGTransformList.cpp +++ b/Libraries/LibWeb/SVG/SVGTransformList.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(SVGTransformList); JS::NonnullGCPtr SVGTransformList::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } SVGTransformList::~SVGTransformList() = default; diff --git a/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Libraries/LibWeb/SVG/SVGUseElement.cpp index ab4bda8bc46..173171e5095 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -36,12 +36,12 @@ void SVGUseElement::initialize(JS::Realm& realm) WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGUseElement); // The shadow tree is open (inspectable by script), but read-only. - auto shadow_root = heap().allocate(realm, document(), *this, Bindings::ShadowRootMode::Open); + auto shadow_root = realm.create(document(), *this, Bindings::ShadowRootMode::Open); // The user agent must create a use-element shadow tree whose host is the ‘use’ element itself set_shadow_root(shadow_root); - m_document_observer = realm.heap().allocate(realm, realm, document()); + m_document_observer = realm.create(realm, document()); m_document_observer->set_document_completely_loaded([this]() { clone_element_tree_as_our_shadow_tree(referenced_element()); }); diff --git a/Libraries/LibWeb/Selection/Selection.cpp b/Libraries/LibWeb/Selection/Selection.cpp index 9c0ad15ae18..af84f872e72 100644 --- a/Libraries/LibWeb/Selection/Selection.cpp +++ b/Libraries/LibWeb/Selection/Selection.cpp @@ -19,7 +19,7 @@ JS_DEFINE_ALLOCATOR(Selection); JS::NonnullGCPtr Selection::create(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) { - return realm->heap().allocate(realm, realm, document); + return realm->create(realm, document); } Selection::Selection(JS::NonnullGCPtr realm, JS::NonnullGCPtr document) diff --git a/Libraries/LibWeb/StorageAPI/StorageManager.cpp b/Libraries/LibWeb/StorageAPI/StorageManager.cpp index 943500559a7..85402947878 100644 --- a/Libraries/LibWeb/StorageAPI/StorageManager.cpp +++ b/Libraries/LibWeb/StorageAPI/StorageManager.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(StorageManager); WebIDL::ExceptionOr> StorageManager::create(JS::Realm& realm) { - return realm.heap().allocate(realm, realm); + return realm.create(realm); } StorageManager::StorageManager(JS::Realm& realm) diff --git a/Libraries/LibWeb/Streams/AbstractOperations.cpp b/Libraries/LibWeb/Streams/AbstractOperations.cpp index 936ab57d228..e32d171c462 100644 --- a/Libraries/LibWeb/Streams/AbstractOperations.cpp +++ b/Libraries/LibWeb/Streams/AbstractOperations.cpp @@ -51,7 +51,7 @@ WebIDL::ExceptionOr> acquire_reada auto& realm = stream.realm(); // 1. Let reader be a new ReadableStreamDefaultReader. - auto reader = realm.heap().allocate(realm, realm); + auto reader = realm.create(realm); // 2. Perform ? SetUpReadableStreamDefaultReader(reader, stream). TRY(set_up_readable_stream_default_reader(reader, stream)); @@ -66,7 +66,7 @@ WebIDL::ExceptionOr> acquire_readable auto& realm = stream.realm(); // 1. Let reader be a new ReadableStreamBYOBReader. - auto reader = realm.heap().allocate(realm, realm); + auto reader = realm.create(realm); // 2. Perform ? SetUpReadableStreamBYOBReader(reader, stream). TRY(set_up_readable_stream_byob_reader(reader, stream)); @@ -535,7 +535,7 @@ WebIDL::ExceptionOr readable_stream_default_tee(JS::Realm& r // 9. Let reason2 be undefined. // 10. Let branch1 be undefined. // 11. Let branch2 be undefined. - auto params = realm.heap().allocate(realm); + auto params = realm.create(); // 12. Let cancelPromise be a new promise. auto cancel_promise = WebIDL::create_promise(realm); @@ -727,7 +727,7 @@ public: // 4. If canceled1 is false and canceled2 is false, if (!m_params->canceled1 && !m_params->canceled2) { // 1. Let cloneResult be CloneAsUint8Array(chunk). - auto chunk_view = m_realm->vm().heap().allocate(m_realm, chunk.as_object()); + auto chunk_view = m_realm->create(chunk.as_object()); auto clone_result = clone_as_uint8_array(m_realm, chunk_view); // 2. If cloneResult is an abrupt completion, @@ -868,7 +868,7 @@ public: // https://streams.spec.whatwg.org/#ref-for-read-into-request-chunk-steps① virtual void on_chunk(JS::Value chunk) override { - auto chunk_view = m_realm->vm().heap().allocate(m_realm, chunk.as_object()); + auto chunk_view = m_realm->create(chunk.as_object()); // 1. Queue a microtask to perform the following steps: HTML::queue_a_microtask(nullptr, JS::create_heap_function(m_realm->heap(), [this, chunk = chunk_view]() { @@ -978,7 +978,7 @@ public: // 2. If byobCanceled is false, perform ! ReadableByteStreamControllerRespondWithNewView(byobBranch.[[controller]], chunk). if (!byob_cancelled) { - auto array_buffer_view = m_realm->vm().heap().allocate(m_realm, chunk.as_object()); + auto array_buffer_view = m_realm->create(chunk.as_object()); MUST(readable_byte_stream_controller_respond_with_new_view(m_realm, byob_controller, array_buffer_view)); } @@ -1044,7 +1044,7 @@ WebIDL::ExceptionOr readable_byte_stream_tee(JS::Realm& real // 10. Let reason2 be undefined. // 11. Let branch1 be undefined. // 12. Let branch2 be undefined. - auto params = realm.heap().allocate(realm, reader); + auto params = realm.create(reader); // 13. Let cancelPromise be a new promise. auto cancel_promise = WebIDL::create_promise(realm); @@ -1386,7 +1386,7 @@ WebIDL::ExceptionOr> readable_stream_from_itera // 1. Let stream be undefined. // NON-STANDARD: We capture 'stream' in a lambda later, so it needs to be allocated now. // 'stream' is still in an uninitialized state and will be initialized / set up at step 6. - auto stream = realm.heap().allocate(realm, realm); + auto stream = realm.create(realm); // 2. Let iteratorRecord be ? GetIterator(asyncIterable, async). auto iterator_record = TRY(JS::get_iterator(vm, async_iterable, JS::IteratorHint::Async)); @@ -2215,13 +2215,13 @@ JS::GCPtr readable_byte_stream_controller_get_byob_re auto view = MUST(JS::construct(vm, *realm.intrinsics().uint8_array_constructor(), first_descriptor.buffer, JS::Value(first_descriptor.byte_offset + first_descriptor.bytes_filled), JS::Value(first_descriptor.byte_length - first_descriptor.bytes_filled))); // 3. Let byobRequest be a new ReadableStreamBYOBRequest. - auto byob_request = realm.heap().allocate(realm, realm); + auto byob_request = realm.create(realm); // 4. Set byobRequest.[[controller]] to controller. byob_request->set_controller(controller); // 5. Set byobRequest.[[view]] to view. - auto array_buffer_view = vm.heap().allocate(realm, view); + auto array_buffer_view = realm.create(view); byob_request->set_view(array_buffer_view); // 6. Set controller.[[byobRequest]] to byobRequest. @@ -2580,7 +2580,7 @@ WebIDL::ExceptionOr set_up_readable_stream_default_controller_from_underly auto& realm = stream.realm(); // 1. Let controller be a new ReadableStreamDefaultController. - auto controller = stream.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 2. Let startAlgorithm be an algorithm that returns undefined. auto start_algorithm = JS::create_heap_function(realm.heap(), []() -> WebIDL::ExceptionOr { @@ -2917,7 +2917,7 @@ WebIDL::ExceptionOr set_up_readable_stream(JS::Realm& realm, ReadableStrea initialize_readable_stream(stream); // 6. Let controller be a new ReadableStreamDefaultController. - auto controller = realm.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 7. Perform ? SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm). TRY(set_up_readable_stream_default_controller(stream, *controller, start_algorithm, pull_algorithm, cancel_algorithm, *high_water_mark, *size_algorithm)); @@ -2940,13 +2940,13 @@ WebIDL::ExceptionOr> create_readable_stream(JS: VERIFY(is_non_negative_number(JS::Value { *high_water_mark })); // 4. Let stream be a new ReadableStream. - auto stream = realm.heap().allocate(realm, realm); + auto stream = realm.create(realm); // 5. Perform ! InitializeReadableStream(stream). initialize_readable_stream(*stream); // 6. Let controller be a new ReadableStreamDefaultController. - auto controller = realm.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 7. Perform ? SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm). TRY(set_up_readable_stream_default_controller(*stream, *controller, start_algorithm, pull_algorithm, cancel_algorithm, *high_water_mark, *size_algorithm)); @@ -2959,13 +2959,13 @@ WebIDL::ExceptionOr> create_readable_stream(JS: WebIDL::ExceptionOr> create_readable_byte_stream(JS::Realm& realm, JS::NonnullGCPtr start_algorithm, JS::NonnullGCPtr pull_algorithm, JS::NonnullGCPtr cancel_algorithm) { // 1. Let stream be a new ReadableStream. - auto stream = realm.heap().allocate(realm, realm); + auto stream = realm.create(realm); // 2. Perform ! InitializeReadableStream(stream). initialize_readable_stream(*stream); // 3. Let controller be a new ReadableByteStreamController. - auto controller = realm.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 4. Perform ? SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, 0, undefined). TRY(set_up_readable_byte_stream_controller(stream, controller, start_algorithm, pull_algorithm, cancel_algorithm, 0, JS::js_undefined())); @@ -2981,13 +2981,13 @@ WebIDL::ExceptionOr> create_writable_stream(JS: VERIFY(is_non_negative_number(JS::Value { high_water_mark })); // 2. Let stream be a new WritableStream. - auto stream = realm.heap().allocate(realm, realm); + auto stream = realm.create(realm); // 3. Perform ! InitializeWritableStream(stream). initialize_writable_stream(*stream); // 4. Let controller be a new WritableStreamDefaultController. - auto controller = realm.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 5. Perform ? SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm). TRY(set_up_writable_stream_default_controller(*stream, *controller, move(start_algorithm), move(write_algorithm), move(close_algorithm), move(abort_algorithm), high_water_mark, move(size_algorithm))); @@ -3039,7 +3039,7 @@ WebIDL::ExceptionOr> acquire_writa auto& realm = stream.realm(); // 1. Let writer be a new WritableStreamDefaultWriter. - auto writer = stream.heap().allocate(realm, realm); + auto writer = realm.create(realm); // 2. Perform ? SetUpWritableStreamDefaultWriter(writer, stream). TRY(set_up_writable_stream_default_writer(*writer, stream)); @@ -3632,7 +3632,7 @@ void set_up_readable_stream_controller_with_byte_reading_support(ReadableStream& // 4. Perform ! InitializeReadableStream(stream). // 5. Let controller be a new ReadableByteStreamController. - auto controller = stream.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 6. Perform ! SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithmWrapper, cancelAlgorithmWrapper, highWaterMark, undefined). MUST(set_up_readable_byte_stream_controller(stream, controller, start_algorithm, pull_algorithm_wrapper, cancel_algorithm_wrapper, high_water_mark, JS::js_undefined())); @@ -4313,7 +4313,7 @@ WebIDL::ExceptionOr set_up_writable_stream_default_controller(WritableStre reset_queue(controller); // 6. Set controller.[[signal]] to a new AbortSignal. - controller.set_signal(realm.heap().allocate(realm, realm)); + controller.set_signal(realm.create(realm)); // 7. Set controller.[[started]] to false. controller.set_started(false); @@ -4384,7 +4384,7 @@ WebIDL::ExceptionOr set_up_writable_stream_default_controller_from_underly auto& realm = stream.realm(); // 1. Let controller be a new WritableStreamDefaultController. - auto controller = realm.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 2. Let startAlgorithm be an algorithm that returns undefined. auto start_algorithm = JS::create_heap_function(realm.heap(), []() -> WebIDL::ExceptionOr { return JS::js_undefined(); }); @@ -4800,7 +4800,7 @@ void set_up_transform_stream_default_controller_from_transformer(TransformStream auto& vm = realm.vm(); // 1. Let controller be a new TransformStreamDefaultController. - auto controller = realm.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 2. Let transformAlgorithm be the following steps, taking a chunk argument: auto transform_algorithm = JS::create_heap_function(realm.heap(), [controller, &realm, &vm](JS::Value chunk) { @@ -5316,7 +5316,7 @@ void transform_stream_set_up(TransformStream& stream, JS::NonnullGCPtr(realm, realm); + auto controller = realm.create(realm); // 11. Perform ! SetUpTransformStreamDefaultController(stream, controller, transformAlgorithmWrapper, flushAlgorithmWrapper, cancelAlgorithmWrapper). set_up_transform_stream_default_controller(stream, controller, transform_algorithm_wrapper, flush_algorithm_wrapper, cancel_algorithm_wrapper); @@ -5437,7 +5437,7 @@ WebIDL::ExceptionOr set_up_readable_byte_stream_controller_from_underlying auto& realm = stream.realm(); // 1. Let controller be a new ReadableByteStreamController. - auto controller = stream.heap().allocate(realm, realm); + auto controller = realm.create(realm); // 2. Let startAlgorithm be an algorithm that returns undefined. auto start_algorithm = JS::create_heap_function(realm.heap(), []() -> WebIDL::ExceptionOr { return JS::js_undefined(); }); diff --git a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp b/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp index 4d9bf5135d7..455dabc1d93 100644 --- a/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp +++ b/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp @@ -19,7 +19,7 @@ JS::NonnullGCPtr ByteLengthQueuingStrategy::construct { // The new ByteLengthQueuingStrategy(init) constructor steps are: // 1. Set this.[[highWaterMark]] to init["highWaterMark"]. - return realm.heap().allocate(realm, realm, init.high_water_mark); + return realm.create(realm, init.high_water_mark); } ByteLengthQueuingStrategy::ByteLengthQueuingStrategy(JS::Realm& realm, double high_water_mark) diff --git a/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp b/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp index e41550a799f..194e2e1a07d 100644 --- a/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp +++ b/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp @@ -19,7 +19,7 @@ JS::NonnullGCPtr CountQueuingStrategy::construct_impl(JS:: { // The new CountQueuingStrategy(init) constructor steps are: // 1. Set this.[[highWaterMark]] to init["highWaterMark"]. - return realm.heap().allocate(realm, realm, init.high_water_mark); + return realm.create(realm, init.high_water_mark); } CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_mark) diff --git a/Libraries/LibWeb/Streams/ReadableStream.cpp b/Libraries/LibWeb/Streams/ReadableStream.cpp index 748aeae8fbb..0d4608bbc12 100644 --- a/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -28,7 +28,7 @@ WebIDL::ExceptionOr> ReadableStream::construct_ { auto& vm = realm.vm(); - auto readable_stream = realm.heap().allocate(realm, realm); + auto readable_stream = realm.create(realm); // 1. If underlyingSource is missing, set it to null. auto underlying_source = underlying_source_object.has_value() ? JS::Value(underlying_source_object.value()) : JS::js_null(); diff --git a/Libraries/LibWeb/Streams/ReadableStreamBYOBReader.cpp b/Libraries/LibWeb/Streams/ReadableStreamBYOBReader.cpp index 8e2dc7f5a5b..7f2379a117d 100644 --- a/Libraries/LibWeb/Streams/ReadableStreamBYOBReader.cpp +++ b/Libraries/LibWeb/Streams/ReadableStreamBYOBReader.cpp @@ -34,7 +34,7 @@ void ReadableStreamBYOBReader::initialize(JS::Realm& realm) // https://streams.spec.whatwg.org/#byob-reader-constructor WebIDL::ExceptionOr> ReadableStreamBYOBReader::construct_impl(JS::Realm& realm, JS::NonnullGCPtr stream) { - auto reader = realm.heap().allocate(realm, realm); + auto reader = realm.create(realm); // 1. Perform ? SetUpReadableStreamBYOBReader(this, stream). TRY(set_up_readable_stream_byob_reader(reader, *stream)); diff --git a/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp b/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp index 40e455a19f5..a26ec131e55 100644 --- a/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp +++ b/Libraries/LibWeb/Streams/ReadableStreamDefaultReader.cpp @@ -40,7 +40,7 @@ void ReadLoopReadRequest::visit_edges(Visitor& visitor) // https://streams.spec.whatwg.org/#default-reader-constructor WebIDL::ExceptionOr> ReadableStreamDefaultReader::construct_impl(JS::Realm& realm, JS::NonnullGCPtr stream) { - auto reader = realm.heap().allocate(realm, realm); + auto reader = realm.create(realm); // 1. Perform ? SetUpReadableStreamDefaultReader(this, stream); TRY(set_up_readable_stream_default_reader(reader, *stream)); diff --git a/Libraries/LibWeb/Streams/TransformStream.cpp b/Libraries/LibWeb/Streams/TransformStream.cpp index 835d2b28784..dee27c37287 100644 --- a/Libraries/LibWeb/Streams/TransformStream.cpp +++ b/Libraries/LibWeb/Streams/TransformStream.cpp @@ -23,7 +23,7 @@ WebIDL::ExceptionOr> TransformStream::construc { auto& vm = realm.vm(); - auto stream = realm.heap().allocate(realm, realm); + auto stream = realm.create(realm); // 1. If transformer is missing, set it to null. auto transformer = transformer_object.has_value() ? JS::Value { transformer_object.value() } : JS::js_null(); diff --git a/Libraries/LibWeb/Streams/WritableStream.cpp b/Libraries/LibWeb/Streams/WritableStream.cpp index 060a42e40d5..8863c079253 100644 --- a/Libraries/LibWeb/Streams/WritableStream.cpp +++ b/Libraries/LibWeb/Streams/WritableStream.cpp @@ -23,7 +23,7 @@ WebIDL::ExceptionOr> WritableStream::construct_ { auto& vm = realm.vm(); - auto writable_stream = realm.heap().allocate(realm, realm); + auto writable_stream = realm.create(realm); // 1. If underlyingSink is missing, set it to null. auto underlying_sink = underlying_sink_object.has_value() ? JS::Value(underlying_sink_object.value()) : JS::js_null(); diff --git a/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp b/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp index 07e55c712f6..080fa32e291 100644 --- a/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp +++ b/Libraries/LibWeb/Streams/WritableStreamDefaultWriter.cpp @@ -18,7 +18,7 @@ JS_DEFINE_ALLOCATOR(WritableStreamDefaultWriter); WebIDL::ExceptionOr> WritableStreamDefaultWriter::construct_impl(JS::Realm& realm, JS::NonnullGCPtr stream) { - auto writer = realm.heap().allocate(realm, realm); + auto writer = realm.create(realm); // 1. Perform ? SetUpWritableStreamDefaultWriter(this, stream). TRY(set_up_writable_stream_default_writer(*writer, stream)); diff --git a/Libraries/LibWeb/UIEvents/CompositionEvent.cpp b/Libraries/LibWeb/UIEvents/CompositionEvent.cpp index 4409ccf88e3..9266859808b 100644 --- a/Libraries/LibWeb/UIEvents/CompositionEvent.cpp +++ b/Libraries/LibWeb/UIEvents/CompositionEvent.cpp @@ -14,12 +14,12 @@ JS_DEFINE_ALLOCATOR(CompositionEvent); JS::NonnullGCPtr CompositionEvent::create(JS::Realm& realm, FlyString const& event_name, CompositionEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> CompositionEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CompositionEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } CompositionEvent::CompositionEvent(JS::Realm& realm, FlyString const& event_name, CompositionEventInit const& event_init) diff --git a/Libraries/LibWeb/UIEvents/FocusEvent.cpp b/Libraries/LibWeb/UIEvents/FocusEvent.cpp index d85625e1fd2..d4858753f75 100644 --- a/Libraries/LibWeb/UIEvents/FocusEvent.cpp +++ b/Libraries/LibWeb/UIEvents/FocusEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(FocusEvent); JS::NonnullGCPtr FocusEvent::create(JS::Realm& realm, FlyString const& event_name, FocusEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> FocusEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, FocusEventInit const& event_init) diff --git a/Libraries/LibWeb/UIEvents/InputEvent.cpp b/Libraries/LibWeb/UIEvents/InputEvent.cpp index b3de6566b82..22d46159acb 100644 --- a/Libraries/LibWeb/UIEvents/InputEvent.cpp +++ b/Libraries/LibWeb/UIEvents/InputEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(InputEvent); JS::NonnullGCPtr InputEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, InputEventInit const& event_init) { - auto event = realm.heap().allocate(realm, realm, event_name, event_init); + auto event = realm.create(realm, event_name, event_init); event->set_bubbles(true); if (event_name == "beforeinput"_fly_string) { event->set_cancelable(true); @@ -24,7 +24,7 @@ JS::NonnullGCPtr InputEvent::create_from_platform_event(JS::Realm& r WebIDL::ExceptionOr> InputEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, InputEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } InputEvent::InputEvent(JS::Realm& realm, FlyString const& event_name, InputEventInit const& event_init) diff --git a/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp b/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp index 84187bfcf7c..d50a217d01b 100644 --- a/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp +++ b/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp @@ -754,7 +754,7 @@ void KeyboardEvent::init_keyboard_event(String const& type, bool bubbles, bool c JS::NonnullGCPtr KeyboardEvent::create(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> KeyboardEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, KeyboardEventInit const& event_init) diff --git a/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 39616a9ebc9..c0f2b980661 100644 --- a/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -125,7 +125,7 @@ void MouseEvent::init_mouse_event(String const& type, bool bubbles, bool cancela JS::NonnullGCPtr MouseEvent::create(JS::Realm& realm, FlyString const& event_name, MouseEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y) { - return realm.heap().allocate(realm, realm, event_name, event_init, page_x, page_y, offset_x, offset_y); + return realm.create(realm, event_name, event_init, page_x, page_y, offset_x, offset_y); } WebIDL::ExceptionOr> MouseEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, MouseEventInit const& event_init) diff --git a/Libraries/LibWeb/UIEvents/PointerEvent.cpp b/Libraries/LibWeb/UIEvents/PointerEvent.cpp index b61b231b577..d37b96e4ae5 100644 --- a/Libraries/LibWeb/UIEvents/PointerEvent.cpp +++ b/Libraries/LibWeb/UIEvents/PointerEvent.cpp @@ -53,7 +53,7 @@ void PointerEvent::visit_edges(Cell::Visitor& visitor) JS::NonnullGCPtr PointerEvent::create(JS::Realm& realm, FlyString const& type, PointerEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y) { - return realm.heap().allocate(realm, realm, type, event_init, page_x, page_y, offset_x, offset_y); + return realm.create(realm, type, event_init, page_x, page_y, offset_x, offset_y); } WebIDL::ExceptionOr> PointerEvent::construct_impl(JS::Realm& realm, FlyString const& type, PointerEventInit const& event_init) diff --git a/Libraries/LibWeb/UIEvents/TextEvent.cpp b/Libraries/LibWeb/UIEvents/TextEvent.cpp index 2d33317d450..8a9e63794bb 100644 --- a/Libraries/LibWeb/UIEvents/TextEvent.cpp +++ b/Libraries/LibWeb/UIEvents/TextEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(TextEvent); JS::NonnullGCPtr TextEvent::create(JS::Realm& realm, FlyString const& event_name) { - return realm.heap().allocate(realm, realm, event_name); + return realm.create(realm, event_name); } TextEvent::TextEvent(JS::Realm& realm, FlyString const& event_name) diff --git a/Libraries/LibWeb/UIEvents/UIEvent.cpp b/Libraries/LibWeb/UIEvents/UIEvent.cpp index b080ec17ac2..bed33e65a28 100644 --- a/Libraries/LibWeb/UIEvents/UIEvent.cpp +++ b/Libraries/LibWeb/UIEvents/UIEvent.cpp @@ -14,12 +14,12 @@ JS_DEFINE_ALLOCATOR(UIEvent); JS::NonnullGCPtr UIEvent::create(JS::Realm& realm, FlyString const& event_name) { - return realm.heap().allocate(realm, realm, event_name); + return realm.create(realm, event_name); } WebIDL::ExceptionOr> UIEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, UIEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } UIEvent::UIEvent(JS::Realm& realm, FlyString const& event_name) diff --git a/Libraries/LibWeb/UIEvents/WheelEvent.cpp b/Libraries/LibWeb/UIEvents/WheelEvent.cpp index 77c8d25696e..8016f8a1f79 100644 --- a/Libraries/LibWeb/UIEvents/WheelEvent.cpp +++ b/Libraries/LibWeb/UIEvents/WheelEvent.cpp @@ -40,7 +40,7 @@ JS::NonnullGCPtr WheelEvent::construct_impl(JS::Realm& realm, FlyStr JS::NonnullGCPtr WheelEvent::create(JS::Realm& realm, FlyString const& event_name, WheelEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y) { - return realm.heap().allocate(realm, realm, event_name, event_init, page_x, page_y, offset_x, offset_y); + return realm.create(realm, event_name, event_init, page_x, page_y, offset_x, offset_y); } WebIDL::ExceptionOr> WheelEvent::create_from_platform_event(JS::Realm& realm, FlyString const& event_name, CSSPixelPoint screen, CSSPixelPoint page, CSSPixelPoint client, CSSPixelPoint offset, double delta_x, double delta_y, unsigned button, unsigned buttons, unsigned modifiers) diff --git a/Libraries/LibWeb/UserTiming/PerformanceMark.cpp b/Libraries/LibWeb/UserTiming/PerformanceMark.cpp index c2f374e3da8..526f44f7ae7 100644 --- a/Libraries/LibWeb/UserTiming/PerformanceMark.cpp +++ b/Libraries/LibWeb/UserTiming/PerformanceMark.cpp @@ -90,7 +90,7 @@ WebIDL::ExceptionOr> PerformanceMark::construc } // 2. Create a new PerformanceMark object (entry) with the current global object's realm. - return realm.heap().allocate(realm, realm, name, start_time, duration, detail); + return realm.create(realm, name, start_time, duration, detail); } FlyString const& PerformanceMark::entry_type() const diff --git a/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp b/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp index 9aab6ebe8f8..7a83c7de33c 100644 --- a/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp +++ b/Libraries/LibWeb/UserTiming/PerformanceMeasure.cpp @@ -28,7 +28,7 @@ PerformanceMeasure::~PerformanceMeasure() = default; JS::NonnullGCPtr PerformanceMeasure::create(JS::Realm& realm, String const& measure_name, HighResolutionTime::DOMHighResTimeStamp start_time, HighResolutionTime::DOMHighResTimeStamp duration, JS::Value detail) { - return realm.heap().allocate(realm, realm, measure_name, start_time, duration, detail); + return realm.create(realm, measure_name, start_time, duration, detail); } FlyString const& PerformanceMeasure::entry_type() const diff --git a/Libraries/LibWeb/WebAssembly/Instance.cpp b/Libraries/LibWeb/WebAssembly/Instance.cpp index c23756a9796..868e685320c 100644 --- a/Libraries/LibWeb/WebAssembly/Instance.cpp +++ b/Libraries/LibWeb/WebAssembly/Instance.cpp @@ -28,7 +28,7 @@ WebIDL::ExceptionOr> Instance::construct_impl(JS::Rea auto& vm = realm.vm(); auto module_instance = TRY(Detail::instantiate_module(vm, module.compiled_module()->module, import_object)); - return vm.heap().allocate(realm, realm, move(module_instance)); + return realm.create(realm, move(module_instance)); } Instance::Instance(JS::Realm& realm, NonnullOwnPtr module_instance) @@ -59,7 +59,7 @@ void Instance::initialize(JS::Realm& realm) [&](Wasm::MemoryAddress const& address) { Optional> object = m_memory_instances.get(address); if (!object.has_value()) { - object = heap().allocate(realm, realm, address); + object = realm.create(realm, address); m_memory_instances.set(address, *object); } @@ -68,7 +68,7 @@ void Instance::initialize(JS::Realm& realm) [&](Wasm::TableAddress const& address) { Optional> object = m_table_instances.get(address); if (!object.has_value()) { - object = heap().allocate(realm, realm, address); + object = realm.create
(realm, address); m_table_instances.set(address, *object); } diff --git a/Libraries/LibWeb/WebAssembly/Memory.cpp b/Libraries/LibWeb/WebAssembly/Memory.cpp index 26842392b22..4485eafb0dd 100644 --- a/Libraries/LibWeb/WebAssembly/Memory.cpp +++ b/Libraries/LibWeb/WebAssembly/Memory.cpp @@ -29,7 +29,7 @@ WebIDL::ExceptionOr> Memory::construct_impl(JS::Realm& if (!address.has_value()) return vm.throw_completion("Wasm Memory allocation failed"sv); - auto memory_object = vm.heap().allocate(realm, realm, *address); + auto memory_object = realm.create(realm, *address); cache.abstract_machine().store().get(*address)->successful_grow_hook = [memory_object] { MUST(memory_object->reset_the_memory_buffer()); }; diff --git a/Libraries/LibWeb/WebAssembly/Module.cpp b/Libraries/LibWeb/WebAssembly/Module.cpp index 5e13d55c055..709ad5cd82d 100644 --- a/Libraries/LibWeb/WebAssembly/Module.cpp +++ b/Libraries/LibWeb/WebAssembly/Module.cpp @@ -30,7 +30,7 @@ WebIDL::ExceptionOr> Module::construct_impl(JS::Realm& auto stable_bytes = stable_bytes_or_error.release_value(); auto compiled_module = TRY(Detail::compile_a_webassembly_module(vm, move(stable_bytes))); - return vm.heap().allocate(realm, realm, move(compiled_module)); + return realm.create(realm, move(compiled_module)); } Module::Module(JS::Realm& realm, NonnullRefPtr compiled_module) diff --git a/Libraries/LibWeb/WebAssembly/Table.cpp b/Libraries/LibWeb/WebAssembly/Table.cpp index 1e07358812b..aeefc809b90 100644 --- a/Libraries/LibWeb/WebAssembly/Table.cpp +++ b/Libraries/LibWeb/WebAssembly/Table.cpp @@ -54,7 +54,7 @@ WebIDL::ExceptionOr> Table::construct_impl(JS::Realm& re for (auto& element : table.elements()) element = reference; - return vm.heap().allocate
(realm, realm, *address); + return realm.create
(realm, *address); } Table::Table(JS::Realm& realm, Wasm::TableAddress address) diff --git a/Libraries/LibWeb/WebAssembly/WebAssembly.cpp b/Libraries/LibWeb/WebAssembly/WebAssembly.cpp index f2f52fed853..e918e5bcef6 100644 --- a/Libraries/LibWeb/WebAssembly/WebAssembly.cpp +++ b/Libraries/LibWeb/WebAssembly/WebAssembly.cpp @@ -456,7 +456,7 @@ JS::Value to_js_value(JS::VM& vm, Wasm::Value& wasm_value, Wasm::ValueType type) auto& realm = *vm.current_realm(); switch (type.kind()) { case Wasm::ValueType::I64: - return realm.heap().allocate(realm, ::Crypto::SignedBigInteger { wasm_value.to() }); + return realm.create(::Crypto::SignedBigInteger { wasm_value.to() }); case Wasm::ValueType::I32: return JS::Value(wasm_value.to()); case Wasm::ValueType::F64: @@ -512,7 +512,7 @@ JS::NonnullGCPtr asynchronously_compile_webassembly_module(JS:: auto module_or_error = Detail::compile_a_webassembly_module(vm, move(bytes)); // 2. Queue a task to perform the following steps. If taskSource was provided, queue the task on that task source. - HTML::queue_a_task(task_source, nullptr, nullptr, JS::create_heap_function(vm.heap(), [&vm, &realm, promise, module_or_error = move(module_or_error)]() mutable { + HTML::queue_a_task(task_source, nullptr, nullptr, JS::create_heap_function(vm.heap(), [&realm, promise, module_or_error = move(module_or_error)]() mutable { HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes); auto& realm = HTML::relevant_realm(*promise->promise()); @@ -525,10 +525,10 @@ JS::NonnullGCPtr asynchronously_compile_webassembly_module(JS:: else { // 1. Construct a WebAssembly module object from module and bytes, and let moduleObject be the result. // FIXME: Save bytes to the Module instance instead of moving into compile_a_webassembly_module - auto module_object = vm.heap().allocate(realm, realm, module_or_error.release_value()); + auto module_object = realm.create(realm, module_or_error.release_value()); // 2. Resolve promise with moduleObject. - WebIDL::resolve_promise(*vm.current_realm(), promise, module_object); + WebIDL::resolve_promise(realm, promise, module_object); } })); })); @@ -570,7 +570,7 @@ JS::NonnullGCPtr asynchronously_instantiate_webassembly_module( // 2. Let instanceObject be a new Instance. // 3. Initialize instanceObject from module and instance. If this throws an exception, catch it, reject promise with the exception, and terminate these substeps. // FIXME: Investigate whether we are doing all the proper steps for "initialize an instance object" - auto instance_object = vm.heap().allocate(realm, realm, move(instance)); + auto instance_object = realm.create(realm, move(instance)); // 4. Resolve promise with instanceObject. WebIDL::resolve_promise(realm, promise, instance_object); diff --git a/Libraries/LibWeb/WebAudio/AudioBuffer.cpp b/Libraries/LibWeb/WebAudio/AudioBuffer.cpp index dc439c925f0..8213e500090 100644 --- a/Libraries/LibWeb/WebAudio/AudioBuffer.cpp +++ b/Libraries/LibWeb/WebAudio/AudioBuffer.cpp @@ -25,15 +25,13 @@ WebIDL::ExceptionOr> AudioBuffer::create(JS::Realm WebIDL::ExceptionOr> AudioBuffer::construct_impl(JS::Realm& realm, AudioBufferOptions const& options) { - auto& vm = realm.vm(); - // 1. If any of the values in options lie outside its nominal range, throw a NotSupportedError exception and abort the following steps. TRY(BaseAudioContext::verify_audio_options_inside_nominal_range(realm, options.number_of_channels, options.length, options.sample_rate)); // 2. Let b be a new AudioBuffer object. // 3. Respectively assign the values of the attributes numberOfChannels, length, sampleRate of the AudioBufferOptions passed in the // constructor to the internal slots [[number of channels]], [[length]], [[sample rate]]. - auto buffer = vm.heap().allocate(realm, realm, options); + auto buffer = realm.create(realm, options); // 4. Set the internal slot [[internal data]] of this AudioBuffer to the result of calling CreateByteDataBlock([[length]] * [[number of channels]]). buffer->m_channels.ensure_capacity(options.number_of_channels); diff --git a/Libraries/LibWeb/WebAudio/AudioBufferSourceNode.cpp b/Libraries/LibWeb/WebAudio/AudioBufferSourceNode.cpp index 277935e718d..1c38059c0a6 100644 --- a/Libraries/LibWeb/WebAudio/AudioBufferSourceNode.cpp +++ b/Libraries/LibWeb/WebAudio/AudioBufferSourceNode.cpp @@ -113,7 +113,7 @@ WebIDL::ExceptionOr> AudioBufferSourceNo // When the constructor is called with a BaseAudioContext c and an option object option, the user agent // MUST initialize the AudioNode this, with context and options as arguments. - auto node = realm.vm().heap().allocate(realm, realm, context, options); + auto node = realm.create(realm, context, options); return node; } diff --git a/Libraries/LibWeb/WebAudio/AudioContext.cpp b/Libraries/LibWeb/WebAudio/AudioContext.cpp index 60cfbad55eb..39e452e19c3 100644 --- a/Libraries/LibWeb/WebAudio/AudioContext.cpp +++ b/Libraries/LibWeb/WebAudio/AudioContext.cpp @@ -20,7 +20,7 @@ JS_DEFINE_ALLOCATOR(AudioContext); // https://webaudio.github.io/web-audio-api/#dom-audiocontext-audiocontext WebIDL::ExceptionOr> AudioContext::construct_impl(JS::Realm& realm, AudioContextOptions const& context_options) { - return realm.heap().allocate(realm, realm, context_options); + return realm.create(realm, context_options); } AudioContext::AudioContext(JS::Realm& realm, AudioContextOptions const& context_options) diff --git a/Libraries/LibWeb/WebAudio/AudioDestinationNode.cpp b/Libraries/LibWeb/WebAudio/AudioDestinationNode.cpp index 192cf2ed3b9..814819ec3a5 100644 --- a/Libraries/LibWeb/WebAudio/AudioDestinationNode.cpp +++ b/Libraries/LibWeb/WebAudio/AudioDestinationNode.cpp @@ -33,7 +33,7 @@ WebIDL::UnsignedLong AudioDestinationNode::max_channel_count() JS::NonnullGCPtr AudioDestinationNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr context) { - return realm.heap().allocate(realm, realm, context); + return realm.create(realm, context); } void AudioDestinationNode::initialize(JS::Realm& realm) diff --git a/Libraries/LibWeb/WebAudio/AudioListener.cpp b/Libraries/LibWeb/WebAudio/AudioListener.cpp index 2df7ce2f565..171e43152f8 100644 --- a/Libraries/LibWeb/WebAudio/AudioListener.cpp +++ b/Libraries/LibWeb/WebAudio/AudioListener.cpp @@ -28,7 +28,7 @@ AudioListener::AudioListener(JS::Realm& realm) JS::NonnullGCPtr AudioListener::create(JS::Realm& realm) { - return realm.vm().heap().allocate(realm, realm); + return realm.create(realm); } AudioListener::~AudioListener() = default; diff --git a/Libraries/LibWeb/WebAudio/AudioParam.cpp b/Libraries/LibWeb/WebAudio/AudioParam.cpp index 8042dac8673..ccf6f2e3713 100644 --- a/Libraries/LibWeb/WebAudio/AudioParam.cpp +++ b/Libraries/LibWeb/WebAudio/AudioParam.cpp @@ -25,7 +25,7 @@ AudioParam::AudioParam(JS::Realm& realm, float default_value, float min_value, f JS::NonnullGCPtr AudioParam::create(JS::Realm& realm, float default_value, float min_value, float max_value, Bindings::AutomationRate automation_rate) { - return realm.vm().heap().allocate(realm, realm, default_value, min_value, max_value, automation_rate); + return realm.create(realm, default_value, min_value, max_value, automation_rate); } AudioParam::~AudioParam() = default; diff --git a/Libraries/LibWeb/WebAudio/BiquadFilterNode.cpp b/Libraries/LibWeb/WebAudio/BiquadFilterNode.cpp index b32869c52ef..1d4ba31c3f4 100644 --- a/Libraries/LibWeb/WebAudio/BiquadFilterNode.cpp +++ b/Libraries/LibWeb/WebAudio/BiquadFilterNode.cpp @@ -83,8 +83,7 @@ WebIDL::ExceptionOr> BiquadFilterNode::constr { // When the constructor is called with a BaseAudioContext c and an option object option, the user agent // MUST initialize the AudioNode this, with context and options as arguments. - - auto node = realm.vm().heap().allocate(realm, realm, context, options); + auto node = realm.create(realm, context, options); // Default options for channel count and interpretation // https://webaudio.github.io/web-audio-api/#BiquadFilterNode diff --git a/Libraries/LibWeb/WebAudio/DynamicsCompressorNode.cpp b/Libraries/LibWeb/WebAudio/DynamicsCompressorNode.cpp index 9812065b712..bdc725bc337 100644 --- a/Libraries/LibWeb/WebAudio/DynamicsCompressorNode.cpp +++ b/Libraries/LibWeb/WebAudio/DynamicsCompressorNode.cpp @@ -24,7 +24,7 @@ WebIDL::ExceptionOr> DynamicsCompressor WebIDL::ExceptionOr> DynamicsCompressorNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr context, DynamicsCompressorOptions const& options) { // Create the node and allocate memory - auto node = realm.vm().heap().allocate(realm, realm, context, options); + auto node = realm.create(realm, context, options); // Default options for channel count and interpretation // https://webaudio.github.io/web-audio-api/#DynamicsCompressorNode diff --git a/Libraries/LibWeb/WebAudio/GainNode.cpp b/Libraries/LibWeb/WebAudio/GainNode.cpp index ffa435746b1..6e4b6eb95db 100644 --- a/Libraries/LibWeb/WebAudio/GainNode.cpp +++ b/Libraries/LibWeb/WebAudio/GainNode.cpp @@ -25,7 +25,7 @@ WebIDL::ExceptionOr> GainNode::create(JS::Realm& real WebIDL::ExceptionOr> GainNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr context, GainOptions const& options) { // Create the node and allocate memory - auto node = realm.vm().heap().allocate(realm, realm, context, options); + auto node = realm.create(realm, context, options); // Default options for channel count and interpretation // https://webaudio.github.io/web-audio-api/#GainNode diff --git a/Libraries/LibWeb/WebAudio/OfflineAudioContext.cpp b/Libraries/LibWeb/WebAudio/OfflineAudioContext.cpp index 9b1f4f120c2..0ac148601b1 100644 --- a/Libraries/LibWeb/WebAudio/OfflineAudioContext.cpp +++ b/Libraries/LibWeb/WebAudio/OfflineAudioContext.cpp @@ -26,7 +26,7 @@ WebIDL::ExceptionOr> OfflineAudioContext:: // A NotSupportedError exception MUST be thrown if any of the arguments is negative, zero, or outside its nominal range. TRY(verify_audio_options_inside_nominal_range(realm, number_of_channels, length, sample_rate)); - return realm.heap().allocate(realm, realm, number_of_channels, length, sample_rate); + return realm.create(realm, number_of_channels, length, sample_rate); } OfflineAudioContext::~OfflineAudioContext() = default; diff --git a/Libraries/LibWeb/WebAudio/OscillatorNode.cpp b/Libraries/LibWeb/WebAudio/OscillatorNode.cpp index 9ff11bf9ae9..272d220356c 100644 --- a/Libraries/LibWeb/WebAudio/OscillatorNode.cpp +++ b/Libraries/LibWeb/WebAudio/OscillatorNode.cpp @@ -26,7 +26,7 @@ WebIDL::ExceptionOr> OscillatorNode::construct_ { // FIXME: Invoke "Initialize the AudioNode" steps. TRY(verify_valid_type(realm, options.type)); - auto node = realm.vm().heap().allocate(realm, realm, context, options); + auto node = realm.create(realm, context, options); return node; } diff --git a/Libraries/LibWeb/WebDriver/ExecuteScript.cpp b/Libraries/LibWeb/WebDriver/ExecuteScript.cpp index ceeb94f3506..56ecb99352d 100644 --- a/Libraries/LibWeb/WebDriver/ExecuteScript.cpp +++ b/Libraries/LibWeb/WebDriver/ExecuteScript.cpp @@ -91,7 +91,7 @@ void execute_script(HTML::BrowsingContext const& browsing_context, ByteString bo auto& vm = document->vm(); // 5. Let timer be a new timer. - auto timer = vm.heap().allocate(realm); + auto timer = realm.create(); // 6. If timeout is not null: if (timeout_ms.has_value()) { @@ -148,7 +148,7 @@ void execute_async_script(HTML::BrowsingContext const& browsing_context, ByteStr auto& vm = document->vm(); // 5. Let timer be a new timer. - auto timer = vm.heap().allocate(realm); + auto timer = realm.create(); // 6. If timeout is not null: if (timeout_ms.has_value()) { diff --git a/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp b/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp index 55d20294375..ccd0a7c0898 100644 --- a/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp +++ b/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(WebGLContextEvent); JS::NonnullGCPtr WebGLContextEvent::create(JS::Realm& realm, FlyString const& event_name, WebGLContextEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> WebGLContextEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, WebGLContextEventInit const& event_init) diff --git a/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp index 0c775caf296..d6d4a09b43b 100644 --- a/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp +++ b/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp @@ -53,7 +53,7 @@ JS::ThrowCompletionOr> WebGLRenderingContext::c return JS::GCPtr { nullptr }; } - return realm.heap().allocate(realm, realm, canvas_element, context.release_nonnull(), context_attributes, context_attributes); + return realm.create(realm, canvas_element, context.release_nonnull(), context_attributes, context_attributes); } WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters) diff --git a/Libraries/LibWeb/WebIDL/DOMException.cpp b/Libraries/LibWeb/WebIDL/DOMException.cpp index dc68666f3d0..3166b41fb8d 100644 --- a/Libraries/LibWeb/WebIDL/DOMException.cpp +++ b/Libraries/LibWeb/WebIDL/DOMException.cpp @@ -14,12 +14,12 @@ JS_DEFINE_ALLOCATOR(DOMException); JS::NonnullGCPtr DOMException::create(JS::Realm& realm, FlyString name, String message) { - return realm.heap().allocate(realm, realm, move(name), move(message)); + return realm.create(realm, move(name), move(message)); } JS::NonnullGCPtr DOMException::construct_impl(JS::Realm& realm, String message, FlyString name) { - return realm.heap().allocate(realm, realm, move(name), move(message)); + return realm.create(realm, move(name), move(message)); } DOMException::DOMException(JS::Realm& realm, FlyString name, String message) diff --git a/Libraries/LibWeb/WebIDL/ObservableArray.cpp b/Libraries/LibWeb/WebIDL/ObservableArray.cpp index 567f1402b92..fe074e5240f 100644 --- a/Libraries/LibWeb/WebIDL/ObservableArray.cpp +++ b/Libraries/LibWeb/WebIDL/ObservableArray.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(ObservableArray); JS::NonnullGCPtr ObservableArray::create(JS::Realm& realm) { auto prototype = realm.intrinsics().array_prototype(); - return realm.heap().allocate(realm, prototype); + return realm.create(prototype); } ObservableArray::ObservableArray(Object& prototype) diff --git a/Libraries/LibWeb/WebIDL/Promise.cpp b/Libraries/LibWeb/WebIDL/Promise.cpp index 0d7a58a6e0b..29f679f8af0 100644 --- a/Libraries/LibWeb/WebIDL/Promise.cpp +++ b/Libraries/LibWeb/WebIDL/Promise.cpp @@ -254,7 +254,7 @@ void wait_for_all(JS::Realm& realm, Vector> const& pro // 8. Let result be a list containing total null values. // Handled in WaitForAllResults - auto results = realm.heap().allocate(realm, JS::create_heap_function(realm.heap(), move(success_steps)), total); + auto results = realm.create(JS::create_heap_function(realm.heap(), move(success_steps)), total); // 9. For each promise of promises: for (auto const& promise : promises) { diff --git a/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Libraries/LibWeb/WebSockets/WebSocket.cpp index e2aebcd5814..e3795725bcc 100644 --- a/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -38,7 +38,7 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::R { auto& vm = realm.vm(); - auto web_socket = realm.heap().allocate(realm, realm); + auto web_socket = realm.create(realm); auto& relevant_settings_object = HTML::relevant_settings_object(*web_socket); // 1. Let baseURL be this's relevant settings object's API base URL. diff --git a/Libraries/LibWeb/WebVTT/VTTCue.cpp b/Libraries/LibWeb/WebVTT/VTTCue.cpp index ea371e54eb6..b1fbdc7c758 100644 --- a/Libraries/LibWeb/WebVTT/VTTCue.cpp +++ b/Libraries/LibWeb/WebVTT/VTTCue.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(VTTCue); WebIDL::ExceptionOr> VTTCue::construct_impl(JS::Realm& realm, double start_time, double end_time, String const& text) { // 1. Create a new WebVTT cue. Let cue be that WebVTT cue. - auto cue = realm.heap().allocate(realm, realm, nullptr); + auto cue = realm.create(realm, nullptr); // 2. Let cue’s text track cue start time be the value of the startTime argument. cue->m_start_time = start_time; diff --git a/Libraries/LibWeb/WebVTT/VTTRegion.cpp b/Libraries/LibWeb/WebVTT/VTTRegion.cpp index 014d480b54d..fb789da3958 100644 --- a/Libraries/LibWeb/WebVTT/VTTRegion.cpp +++ b/Libraries/LibWeb/WebVTT/VTTRegion.cpp @@ -16,7 +16,7 @@ JS_DEFINE_ALLOCATOR(VTTRegion); WebIDL::ExceptionOr> VTTRegion::construct_impl(JS::Realm& realm) { // 1. Create a new WebVTT region. Let region be that WebVTT region. - auto region = realm.heap().allocate(realm, realm); + auto region = realm.create(realm); // 2. Let region’s WebVTT region identifier be the empty string. region->m_identifier = ""_string; diff --git a/Libraries/LibWeb/XHR/FormData.cpp b/Libraries/LibWeb/XHR/FormData.cpp index cf3d2b6cd2c..9573347c553 100644 --- a/Libraries/LibWeb/XHR/FormData.cpp +++ b/Libraries/LibWeb/XHR/FormData.cpp @@ -37,7 +37,7 @@ WebIDL::ExceptionOr> FormData::construct_impl(JS::Rea WebIDL::ExceptionOr> FormData::construct_impl(JS::Realm& realm, Vector entry_list) { - return realm.heap().allocate(realm, realm, move(entry_list)); + return realm.create(realm, move(entry_list)); } WebIDL::ExceptionOr> FormData::create(JS::Realm& realm, Vector entry_list) diff --git a/Libraries/LibWeb/XHR/FormDataIterator.cpp b/Libraries/LibWeb/XHR/FormDataIterator.cpp index eb85b3cd4e1..b4a5295073a 100644 --- a/Libraries/LibWeb/XHR/FormDataIterator.cpp +++ b/Libraries/LibWeb/XHR/FormDataIterator.cpp @@ -16,7 +16,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_prototype_and_constructor(JS::Realm& realm) { - auto prototype = heap().allocate(realm, realm); + auto prototype = realm.create(realm); m_prototypes.set("FormDataIterator"_fly_string, prototype); } @@ -28,7 +28,7 @@ JS_DEFINE_ALLOCATOR(FormDataIterator); JS::NonnullGCPtr FormDataIterator::create(FormData const& form_data, JS::Object::PropertyKind iterator_kind) { - return form_data.heap().allocate(form_data.realm(), form_data, iterator_kind); + return form_data.realm().create(form_data, iterator_kind); } FormDataIterator::FormDataIterator(Web::XHR::FormData const& form_data, JS::Object::PropertyKind iterator_kind) diff --git a/Libraries/LibWeb/XHR/ProgressEvent.cpp b/Libraries/LibWeb/XHR/ProgressEvent.cpp index a064800f8a7..2cf148334de 100644 --- a/Libraries/LibWeb/XHR/ProgressEvent.cpp +++ b/Libraries/LibWeb/XHR/ProgressEvent.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(ProgressEvent); JS::NonnullGCPtr ProgressEvent::create(JS::Realm& realm, FlyString const& event_name, ProgressEventInit const& event_init) { - return realm.heap().allocate(realm, realm, event_name, event_init); + return realm.create(realm, event_name, event_init); } WebIDL::ExceptionOr> ProgressEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ProgressEventInit const& event_init) diff --git a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 9f4d7344894..39c5140e022 100644 --- a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -60,11 +60,11 @@ JS_DEFINE_ALLOCATOR(XMLHttpRequest); WebIDL::ExceptionOr> XMLHttpRequest::construct_impl(JS::Realm& realm) { - auto upload_object = realm.heap().allocate(realm, realm); + auto upload_object = realm.create(realm); auto author_request_headers = Fetch::Infrastructure::HeaderList::create(realm.vm()); auto response = Fetch::Infrastructure::Response::network_error(realm.vm(), "Not sent yet"sv); auto fetch_controller = Fetch::Infrastructure::FetchController::create(realm.vm()); - return realm.heap().allocate(realm, realm, *upload_object, *author_request_headers, *response, *fetch_controller); + return realm.create(realm, *upload_object, *author_request_headers, *response, *fetch_controller); } XMLHttpRequest::XMLHttpRequest(JS::Realm& realm, XMLHttpRequestUpload& upload_object, Fetch::Infrastructure::HeaderList& author_request_headers, Fetch::Infrastructure::Response& response, Fetch::Infrastructure::FetchController& fetch_controller) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 3d1728e7367..f30898f7c55 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -710,7 +710,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (!@js_name@@js_suffix@.is_object() || !(is(@js_name@@js_suffix@.as_object()) || is(@js_name@@js_suffix@.as_object()) || is(@js_name@@js_suffix@.as_object()))) return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@"); - @cpp_name@ = JS::make_handle(vm.heap().allocate(realm, @js_name@@js_suffix@.as_object())); + @cpp_name@ = JS::make_handle(realm.create(@js_name@@js_suffix@.as_object())); )~~~"); if (optional) { @@ -724,7 +724,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (!@js_name@@js_suffix@.is_object() || !(is(@js_name@@js_suffix@.as_object()) || is(@js_name@@js_suffix@.as_object()))) return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@"); - auto @cpp_name@ = JS::make_handle(vm.heap().allocate(realm, @js_name@@js_suffix@.as_object())); + auto @cpp_name@ = JS::make_handle(realm.create(@js_name@@js_suffix@.as_object())); )~~~"); if (optional) { scoped_generator.append(R"~~~( @@ -1227,7 +1227,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (any_of(types, [](auto const& type) { return type->name() == "BufferSource"; }) && !includes_object) { union_generator.append(R"~~~( if (is(@js_name@@js_suffix@_object) || is(@js_name@@js_suffix@_object) || is(@js_name@@js_suffix@_object)) { - JS::NonnullGCPtr source_object = vm.heap().allocate(realm, @js_name@@js_suffix@_object); + JS::NonnullGCPtr source_object = realm.create(@js_name@@js_suffix@_object); return JS::make_handle(source_object); } )~~~"); @@ -2496,7 +2496,7 @@ static void generate_html_constructor(SourceGenerator& generator, IDL::Construct // 3. Set element's namespace to the HTML namespace. // 4. Set element's namespace prefix to null. // 5. Set element's local name to definition's local name. - auto element = realm.heap().allocate<@fully_qualified_name@>(realm, window.associated_document(), DOM::QualifiedName { definition->local_name(), {}, Namespace::HTML }); + auto element = realm.create<@fully_qualified_name@>(window.associated_document(), DOM::QualifiedName { definition->local_name(), {}, Namespace::HTML }); // https://webidl.spec.whatwg.org/#internally-create-a-new-object-implementing-the-interface // Important steps from "internally create a new object implementing the interface" diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 38a38dc9ab1..08573a62a0a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -103,7 +103,7 @@ namespace Web::Bindings { template<> void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm) { - auto namespace_object = heap().allocate<@namespace_class@>(realm, realm); + auto namespace_object = realm.create<@namespace_class@>(realm); m_namespaces.set("@interface_name@"_fly_string, namespace_object); [[maybe_unused]] static constexpr u8 attr = JS::Attribute::Writable | JS::Attribute::Configurable;)~~~"); @@ -139,16 +139,16 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea if (!named_properties_class.is_empty()) { gen.set("named_properties_class", named_properties_class); gen.append(R"~~~( - auto named_properties_object = heap().allocate<@named_properties_class@>(realm, realm); + auto named_properties_object = realm.create<@named_properties_class@>(realm); m_prototypes.set("@named_properties_class@"_fly_string, named_properties_object); )~~~"); } gen.append(R"~~~( - auto prototype = heap().allocate<@prototype_class@>(realm, realm); + auto prototype = realm.create<@prototype_class@>(realm); m_prototypes.set("@interface_name@"_fly_string, prototype); - auto constructor = heap().allocate<@constructor_class@>(realm, realm); + auto constructor = realm.create<@constructor_class@>(realm); m_constructors.set("@interface_name@"_fly_string, constructor); prototype->define_direct_property(vm.names.constructor, constructor.ptr(), JS::Attribute::Writable | JS::Attribute::Configurable); @@ -159,7 +159,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea gen.set("legacy_interface_name", legacy_constructor->name); gen.set("legacy_constructor_class", legacy_constructor->constructor_class); gen.append(R"~~~( - auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm); + auto legacy_constructor = realm.create<@legacy_constructor_class@>(realm); m_constructors.set("@legacy_interface_name@"_fly_string, legacy_constructor); legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"_string), JS::Attribute::Configurable);)~~~"); diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp index 7ad62ce7d1c..11101635b46 100644 --- a/Services/WebContent/ConnectionFromClient.cpp +++ b/Services/WebContent/ConnectionFromClient.cpp @@ -766,7 +766,7 @@ void ConnectionFromClient::create_child_text_node(u64 page_id, Web::UniqueNodeID return; } - auto text_node = dom_node->heap().allocate(dom_node->realm(), dom_node->document(), "text"_string); + auto text_node = dom_node->realm().create(dom_node->document(), "text"_string); dom_node->append_child(text_node).release_value_but_fixme_should_propagate_errors(); async_did_finish_editing_dom_node(page_id, text_node->unique_id()); diff --git a/Services/WebContent/WebContentConsoleClient.cpp b/Services/WebContent/WebContentConsoleClient.cpp index 287517cce47..b29b0377358 100644 --- a/Services/WebContent/WebContentConsoleClient.cpp +++ b/Services/WebContent/WebContentConsoleClient.cpp @@ -31,7 +31,7 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, JS::Realm , m_client(client) { auto& window = verify_cast(realm.global_object()); - m_console_global_environment_extensions = realm.heap().allocate(realm, realm, window); + m_console_global_environment_extensions = realm.create(realm, window); } WebContentConsoleClient::~WebContentConsoleClient() = default; diff --git a/Services/WebContent/WebDriverConnection.cpp b/Services/WebContent/WebDriverConnection.cpp index 44e61f4e4c3..d25e1275a62 100644 --- a/Services/WebContent/WebDriverConnection.cpp +++ b/Services/WebContent/WebDriverConnection.cpp @@ -370,7 +370,7 @@ Messages::WebDriverClient::BackResponse WebDriverConnection::back() auto timeout = m_timeouts_configuration.page_load_timeout; // 4. Let timer be a new timer. - auto timer = realm.heap().allocate(realm); + auto timer = realm.create(); auto on_complete = JS::create_heap_function(realm.heap(), [this, timer]() { timer->stop(); @@ -415,7 +415,7 @@ Messages::WebDriverClient::BackResponse WebDriverConnection::back() } else { auto& realm = document->realm(); - m_document_observer = realm.heap().allocate(realm, realm, *document); + m_document_observer = realm.create(realm, *document); m_document_observer->set_document_page_showing_observer([on_complete](auto) { on_complete->function()(); }); @@ -440,7 +440,7 @@ Messages::WebDriverClient::ForwardResponse WebDriverConnection::forward() auto timeout = m_timeouts_configuration.page_load_timeout; // 4. Let timer be a new timer. - auto timer = realm.heap().allocate(realm); + auto timer = realm.create(); auto on_complete = JS::create_heap_function(realm.heap(), [this, timer]() { timer->stop(); @@ -485,7 +485,7 @@ Messages::WebDriverClient::ForwardResponse WebDriverConnection::forward() } else { auto& realm = document->realm(); - m_document_observer = realm.heap().allocate(realm, realm, *document); + m_document_observer = realm.create(realm, *document); m_document_observer->set_document_page_showing_observer([on_complete](auto) { on_complete->function()(); }); @@ -2719,11 +2719,11 @@ void WebDriverConnection::wait_for_navigation_to_complete(OnNavigationComplete o // 3. Start a timer. If this algorithm has not completed before timer reaches the session’s session page load timeout // in milliseconds, return an error with error code timeout. - m_navigation_timer = realm.heap().allocate(realm); + m_navigation_timer = realm.create(); // 4. If there is an ongoing attempt to navigate the current browsing context that has not yet matured, wait for // navigation to mature. - m_navigation_observer = realm.heap().allocate(realm, realm, *navigable); + m_navigation_observer = realm.create(realm, *navigable); m_navigation_observer->set_navigation_complete([this, &realm, reset_observers]() { reset_observers(*this); @@ -2744,7 +2744,7 @@ void WebDriverConnection::wait_for_navigation_to_complete(OnNavigationComplete o // 6. Wait for the current browsing context’s document readiness state to reach readiness target, // or for the session page load timeout to pass, whichever occurs sooner. if (auto* document = current_browsing_context().active_document(); document->readiness() != readiness_target) { - m_document_observer = realm.heap().allocate(realm, realm, *document); + m_document_observer = realm.create(realm, *document); m_document_observer->set_document_readiness_observer([this, readiness_target](Web::HTML::DocumentReadyState readiness) { if (readiness == readiness_target) @@ -2837,8 +2837,8 @@ void WebDriverConnection::wait_for_visibility_state(JS::NonnullGCPtr(realm); - m_document_observer = realm.heap().allocate(realm, realm, *document); + auto timer = realm.create(); + m_document_observer = realm.create(realm, *document); m_document_observer->set_document_visibility_state_observer([timer, target_visibility_state](Web::HTML::VisibilityState visibility_state) { if (visibility_state == target_visibility_state) @@ -2952,7 +2952,7 @@ void WebDriverConnection::find(Web::WebDriver::LocationStrategy location_strateg auto timeout = m_timeouts_configuration.implicit_wait_timeout; // 4. Let timer be a new timer. - auto timer = realm.heap().allocate(realm); + auto timer = realm.create(); auto wrapped_on_complete = JS::create_heap_function(realm.heap(), [this, on_complete, timer](Web::WebDriver::Response result) { m_element_locator = nullptr; @@ -2971,7 +2971,7 @@ void WebDriverConnection::find(Web::WebDriver::LocationStrategy location_strateg // 6. Let elements returned be an empty List. // 7. While elements returned is empty and timer's timeout fired flag is not set: - m_element_locator = realm.heap().allocate(realm, current_browsing_context(), location_strategy, move(selector), get_start_node, wrapped_on_complete, timer); + m_element_locator = realm.create(current_browsing_context(), location_strategy, move(selector), get_start_node, wrapped_on_complete, timer); m_element_locator->search_for_element(); } diff --git a/Services/WebWorker/DedicatedWorkerHost.cpp b/Services/WebWorker/DedicatedWorkerHost.cpp index 1499b0be024..9daea30eb04 100644 --- a/Services/WebWorker/DedicatedWorkerHost.cpp +++ b/Services/WebWorker/DedicatedWorkerHost.cpp @@ -76,7 +76,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr page, Web::HTML::Trans // FIXME: support for 'owner' set on WorkerGlobalScope // IMPLEMENTATION DEFINED: We need an object to represent the fetch response's client - auto outside_settings = inner_settings->heap().allocate(inner_settings->realm(), inner_settings->realm_execution_context().copy(), outside_settings_snapshot); + auto outside_settings = inner_settings->realm().create(inner_settings->realm_execution_context().copy(), outside_settings_snapshot); // 12. If is shared is true, then: if (is_shared) { @@ -168,7 +168,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr page, Web::HTML::Trans MUST(inside_port->transfer_receiving_steps(message_port_data)); // 6. Create a new WorkerLocation object and associate it with worker global scope. - worker_global_scope->set_location(realm.heap().allocate(realm, *worker_global_scope)); + worker_global_scope->set_location(realm.create(*worker_global_scope)); // FIXME: 7. Closing orphan workers: Start monitoring the worker such that no sooner than it // stops being a protected worker, and no later than it stops being a permissible worker, diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index c9708fa6957..4f8ddc2e229 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -56,7 +56,7 @@ public: static JS::ThrowCompletionOr create(JS::Realm& realm, NonnullRefPtr module, HashMap const& imports) { auto& vm = realm.vm(); - auto instance = realm.heap().allocate(realm, realm.intrinsics().object_prototype()); + auto instance = realm.create(realm.intrinsics().object_prototype()); instance->m_module = move(module); Wasm::Linker linker(*instance->m_module); linker.link(imports);