From 1e54003cb1ced57f3b46d97b44d17b170e2736cb Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Thu, 14 Nov 2024 06:13:46 +1300 Subject: [PATCH] LibJS+LibWeb: Rename Heap::allocate_without_realm to Heap::allocate Now that the heap has no knowledge about a JavaScript realm and is purely for managing the memory of the heap, it does not make sense to name this function to say that it is a non-realm variant. --- Libraries/LibJS/Bytecode/Generator.cpp | 2 +- Libraries/LibJS/Contrib/Test262/262Object.cpp | 2 +- Libraries/LibJS/CyclicModule.cpp | 2 +- Libraries/LibJS/Heap/Heap.h | 2 +- Libraries/LibJS/Heap/HeapFunction.h | 2 +- .../LibJS/Runtime/AbstractOperations.cpp | 8 +++--- Libraries/LibJS/Runtime/Accessor.h | 2 +- Libraries/LibJS/Runtime/BigInt.cpp | 2 +- .../LibJS/Runtime/DeclarativeEnvironment.cpp | 2 +- Libraries/LibJS/Runtime/GlobalEnvironment.cpp | 4 +-- Libraries/LibJS/Runtime/Intrinsics.cpp | 14 +++++----- Libraries/LibJS/Runtime/JobCallback.cpp | 2 +- Libraries/LibJS/Runtime/Object.cpp | 6 ++-- Libraries/LibJS/Runtime/PrimitiveString.cpp | 8 +++--- Libraries/LibJS/Runtime/Promise.cpp | 2 +- Libraries/LibJS/Runtime/PromiseCapability.cpp | 2 +- .../LibJS/Runtime/PromiseConstructor.cpp | 4 +-- Libraries/LibJS/Runtime/PromiseReaction.cpp | 2 +- Libraries/LibJS/Runtime/Realm.cpp | 6 ++-- Libraries/LibJS/Runtime/Realm.h | 2 +- Libraries/LibJS/Runtime/Shape.cpp | 24 ++++++++-------- Libraries/LibJS/Runtime/Symbol.cpp | 2 +- Libraries/LibJS/Runtime/VM.cpp | 20 ++++++------- Libraries/LibJS/Runtime/VM.h | 2 +- Libraries/LibJS/Script.cpp | 2 +- Libraries/LibJS/SourceTextModule.cpp | 4 +-- Libraries/LibJS/SyntheticModule.cpp | 4 +-- Libraries/LibWeb/Bindings/MainThreadVM.cpp | 4 +-- Libraries/LibWeb/DOM/Document.cpp | 2 +- Libraries/LibWeb/DOM/DocumentLoading.h | 2 +- Libraries/LibWeb/DOM/Element.cpp | 26 ++++++++--------- Libraries/LibWeb/DOM/EventTarget.cpp | 12 ++++---- Libraries/LibWeb/DOM/MutationObserver.cpp | 4 +-- .../LibWeb/Fetch/Fetching/PendingResponse.cpp | 4 +-- .../Infrastructure/ConnectionTimingInfo.cpp | 2 +- .../Fetch/Infrastructure/FetchAlgorithms.cpp | 2 +- .../Fetch/Infrastructure/FetchController.cpp | 2 +- .../Fetch/Infrastructure/FetchParams.cpp | 2 +- .../Fetch/Infrastructure/FetchRecord.cpp | 4 +-- .../Fetch/Infrastructure/FetchTimingInfo.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Bodies.cpp | 4 +-- .../Fetch/Infrastructure/HTTP/Headers.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Requests.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Responses.cpp | 10 +++---- Libraries/LibWeb/HTML/BrowsingContext.cpp | 2 +- .../LibWeb/HTML/BrowsingContextGroup.cpp | 2 +- .../CustomElements/CustomElementRegistry.cpp | 2 +- Libraries/LibWeb/HTML/DocumentState.cpp | 2 +- Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp | 4 +-- Libraries/LibWeb/HTML/EventLoop/Task.cpp | 2 +- Libraries/LibWeb/HTML/HTMLAudioElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLBRElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLCanvasElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLDialogElement.cpp | 4 +-- Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLImageElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLInputElement.cpp | 26 ++++++++--------- Libraries/LibWeb/HTML/HTMLLabelElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLObjectElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLVideoElement.cpp | 2 +- Libraries/LibWeb/HTML/Navigable.cpp | 28 +++++++++---------- Libraries/LibWeb/HTML/NavigableContainer.cpp | 4 +-- Libraries/LibWeb/HTML/Navigation.cpp | 4 +-- Libraries/LibWeb/HTML/Parser/HTMLParser.cpp | 8 +++--- .../LibWeb/HTML/Scripting/ClassicScript.cpp | 2 +- .../LibWeb/HTML/Scripting/Environments.cpp | 2 +- Libraries/LibWeb/HTML/Scripting/Fetching.cpp | 2 +- Libraries/LibWeb/HTML/SessionHistoryEntry.cpp | 2 +- .../HTML/SessionHistoryTraversalQueue.cpp | 2 +- Libraries/LibWeb/HTML/Timer.cpp | 2 +- .../LibWeb/HTML/TraversableNavigable.cpp | 8 +++--- Libraries/LibWeb/Layout/Node.cpp | 2 +- Libraries/LibWeb/Layout/TreeBuilder.cpp | 24 ++++++++-------- Libraries/LibWeb/Page/Page.cpp | 2 +- Libraries/LibWeb/Painting/AudioPaintable.cpp | 2 +- Libraries/LibWeb/Painting/CanvasPaintable.cpp | 2 +- .../LibWeb/Painting/CheckBoxPaintable.cpp | 2 +- Libraries/LibWeb/Painting/ImagePaintable.cpp | 4 +-- Libraries/LibWeb/Painting/MarkerPaintable.cpp | 2 +- .../NestedBrowsingContextPaintable.cpp | 2 +- Libraries/LibWeb/Painting/PaintableBox.cpp | 8 +++--- .../LibWeb/Painting/RadioButtonPaintable.cpp | 2 +- .../LibWeb/Painting/SVGClipPaintable.cpp | 2 +- .../Painting/SVGForeignObjectPaintable.cpp | 2 +- .../LibWeb/Painting/SVGGraphicsPaintable.cpp | 2 +- .../LibWeb/Painting/SVGMaskPaintable.cpp | 2 +- .../LibWeb/Painting/SVGPathPaintable.cpp | 2 +- Libraries/LibWeb/Painting/SVGSVGPaintable.cpp | 2 +- Libraries/LibWeb/Painting/TextPaintable.cpp | 2 +- Libraries/LibWeb/Painting/VideoPaintable.cpp | 2 +- .../LibWeb/Painting/ViewportPaintable.cpp | 2 +- Libraries/LibWeb/Platform/TimerSerenity.cpp | 2 +- Libraries/LibWeb/SVG/SVGAElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGDecodedImageData.cpp | 2 +- Libraries/LibWeb/SVG/SVGDecodedImageData.h | 2 +- .../LibWeb/SVG/SVGForeignObjectElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGGElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGGeometryElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGImageElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGSVGElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGSymbolElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGTSpanElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGTextElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGTextPathElement.cpp | 2 +- Libraries/LibWeb/SVG/SVGUseElement.cpp | 2 +- Libraries/LibWeb/ServiceWorker/Job.cpp | 4 +-- .../LibWeb/Streams/AbstractOperations.cpp | 8 +++--- .../Streams/ReadableStreamBYOBReader.cpp | 2 +- .../Streams/ReadableStreamDefaultReader.cpp | 6 ++-- Libraries/LibWeb/WebDriver/Actions.cpp | 2 +- .../BindingsGenerator/IDLGenerators.cpp | 10 +++---- Services/WebContent/PageClient.cpp | 4 +-- Services/WebWorker/DedicatedWorkerHost.cpp | 4 +-- Services/WebWorker/PageHost.cpp | 2 +- Tests/LibJS/test262-runner.cpp | 2 +- 115 files changed, 243 insertions(+), 243 deletions(-) diff --git a/Libraries/LibJS/Bytecode/Generator.cpp b/Libraries/LibJS/Bytecode/Generator.cpp index 7e916f78abc..7ae318c1e1d 100644 --- a/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Libraries/LibJS/Bytecode/Generator.cpp @@ -422,7 +422,7 @@ CodeGenerationErrorOr> Generator::compile(VM& vm, ASTNo label.set_address(block_offsets.get(block).value()); } - auto executable = vm.heap().allocate_without_realm( + auto executable = vm.heap().allocate( move(bytecode), move(generator.m_identifier_table), move(generator.m_string_table), diff --git a/Libraries/LibJS/Contrib/Test262/262Object.cpp b/Libraries/LibJS/Contrib/Test262/262Object.cpp index 5b1a1c477f9..d6ee152070a 100644 --- a/Libraries/LibJS/Contrib/Test262/262Object.cpp +++ b/Libraries/LibJS/Contrib/Test262/262Object.cpp @@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm) auto root_execution_context = MUST(JS::Realm::initialize_host_defined_realm( vm, [&](JS::Realm& realm) -> JS::GlobalObject* { - global_object = vm.heap().allocate_without_realm(realm); + global_object = vm.heap().allocate(realm); return global_object; }, nullptr)); diff --git a/Libraries/LibJS/CyclicModule.cpp b/Libraries/LibJS/CyclicModule.cpp index 9fd15a9049c..b7b020638a2 100644 --- a/Libraries/LibJS/CyclicModule.cpp +++ b/Libraries/LibJS/CyclicModule.cpp @@ -54,7 +54,7 @@ PromiseCapability& CyclicModule::load_requested_modules(GCPtrintrinsics().promise_constructor())); // 3. Let state be the GraphLoadingState Record { [[IsLoading]]: true, [[PendingModulesCount]]: 1, [[Visited]]: « », [[PromiseCapability]]: pc, [[HostDefined]]: hostDefined }. - auto state = heap().allocate_without_realm(promise_capability, true, 1, HashTable> {}, move(host_defined)); + auto state = heap().allocate(promise_capability, true, 1, HashTable> {}, move(host_defined)); // 4. Perform InnerModuleLoading(state, module). inner_module_loading(state); diff --git a/Libraries/LibJS/Heap/Heap.h b/Libraries/LibJS/Heap/Heap.h index 7e75d0eac64..5a38dd25f9d 100644 --- a/Libraries/LibJS/Heap/Heap.h +++ b/Libraries/LibJS/Heap/Heap.h @@ -36,7 +36,7 @@ public: ~Heap(); template - NonnullGCPtr allocate_without_realm(Args&&... args) + NonnullGCPtr allocate(Args&&... args) { auto* memory = allocate_cell(); defer_gc(); diff --git a/Libraries/LibJS/Heap/HeapFunction.h b/Libraries/LibJS/Heap/HeapFunction.h index e381c883836..d541026ea25 100644 --- a/Libraries/LibJS/Heap/HeapFunction.h +++ b/Libraries/LibJS/Heap/HeapFunction.h @@ -19,7 +19,7 @@ class HeapFunction final : public Cell { public: static NonnullGCPtr create(Heap& heap, Function function) { - return heap.allocate_without_realm(move(function)); + return heap.allocate(move(function)); } virtual ~HeapFunction() override = default; diff --git a/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Libraries/LibJS/Runtime/AbstractOperations.cpp index 83dbf6021c8..7ed69824f1e 100644 --- a/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -394,7 +394,7 @@ NonnullGCPtr new_declarative_environment(Environment& en // 1. Let env be a new Declarative Environment Record containing no bindings. // 2. Set env.[[OuterEnv]] to E. // 3. Return env. - return heap.allocate_without_realm(&environment); + return heap.allocate(&environment); } // 9.1.2.3 NewObjectEnvironment ( O, W, E ), https://tc39.es/ecma262/#sec-newobjectenvironment @@ -407,7 +407,7 @@ NonnullGCPtr new_object_environment(Object& object, bool is_w // 3. Set env.[[IsWithEnvironment]] to W. // 4. Set env.[[OuterEnv]] to E. // 5. Return env. - return heap.allocate_without_realm(object, is_with_environment ? ObjectEnvironment::IsWithEnvironment::Yes : ObjectEnvironment::IsWithEnvironment::No, environment); + return heap.allocate(object, is_with_environment ? ObjectEnvironment::IsWithEnvironment::Yes : ObjectEnvironment::IsWithEnvironment::No, environment); } // 9.1.2.4 NewFunctionEnvironment ( F, newTarget ), https://tc39.es/ecma262/#sec-newfunctionenvironment @@ -416,7 +416,7 @@ NonnullGCPtr new_function_environment(ECMAScriptFunctionObj auto& heap = function.heap(); // 1. Let env be a new function Environment Record containing no bindings. - auto env = heap.allocate_without_realm(function.environment()); + auto env = heap.allocate(function.environment()); // 2. Set env.[[FunctionObject]] to F. env->set_function_object(function); @@ -443,7 +443,7 @@ NonnullGCPtr new_private_environment(VM& vm, PrivateEnvironm { // 1. Let names be a new empty List. // 2. Return the PrivateEnvironment Record { [[OuterPrivateEnvironment]]: outerPrivEnv, [[Names]]: names }. - return vm.heap().allocate_without_realm(outer); + return vm.heap().allocate(outer); } // 9.4.3 GetThisEnvironment ( ), https://tc39.es/ecma262/#sec-getthisenvironment diff --git a/Libraries/LibJS/Runtime/Accessor.h b/Libraries/LibJS/Runtime/Accessor.h index 51a7cacdcec..29a181e5b24 100644 --- a/Libraries/LibJS/Runtime/Accessor.h +++ b/Libraries/LibJS/Runtime/Accessor.h @@ -20,7 +20,7 @@ class Accessor final : public Cell { public: static NonnullGCPtr create(VM& vm, FunctionObject* getter, FunctionObject* setter) { - return vm.heap().allocate_without_realm(getter, setter); + return vm.heap().allocate(getter, setter); } FunctionObject* getter() const { return m_getter; } diff --git a/Libraries/LibJS/Runtime/BigInt.cpp b/Libraries/LibJS/Runtime/BigInt.cpp index 9026b0d0a56..f7b3428c5dd 100644 --- a/Libraries/LibJS/Runtime/BigInt.cpp +++ b/Libraries/LibJS/Runtime/BigInt.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(BigInt); NonnullGCPtr BigInt::create(VM& vm, Crypto::SignedBigInteger big_integer) { - return vm.heap().allocate_without_realm(move(big_integer)); + return vm.heap().allocate(move(big_integer)); } BigInt::BigInt(Crypto::SignedBigInteger big_integer) diff --git a/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp b/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp index 303f8704b7f..abb77f151ce 100644 --- a/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp +++ b/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp @@ -20,7 +20,7 @@ DeclarativeEnvironment* DeclarativeEnvironment::create_for_per_iteration_binding auto bindings = other.m_bindings.span().slice(0, bindings_size); auto* parent_environment = other.outer_environment(); - return parent_environment->heap().allocate_without_realm(parent_environment, bindings); + return parent_environment->heap().allocate(parent_environment, bindings); } DeclarativeEnvironment::DeclarativeEnvironment() diff --git a/Libraries/LibJS/Runtime/GlobalEnvironment.cpp b/Libraries/LibJS/Runtime/GlobalEnvironment.cpp index cce2fef6c7c..18600fc8e8f 100644 --- a/Libraries/LibJS/Runtime/GlobalEnvironment.cpp +++ b/Libraries/LibJS/Runtime/GlobalEnvironment.cpp @@ -21,8 +21,8 @@ GlobalEnvironment::GlobalEnvironment(Object& global_object, Object& this_value) : Environment(nullptr) , m_global_this_value(&this_value) { - m_object_record = global_object.heap().allocate_without_realm(global_object, ObjectEnvironment::IsWithEnvironment::No, nullptr); - m_declarative_record = global_object.heap().allocate_without_realm(); + m_object_record = global_object.heap().allocate(global_object, ObjectEnvironment::IsWithEnvironment::No, nullptr); + m_declarative_record = global_object.heap().allocate(); } void GlobalEnvironment::visit_edges(Cell::Visitor& visitor) diff --git a/Libraries/LibJS/Runtime/Intrinsics.cpp b/Libraries/LibJS/Runtime/Intrinsics.cpp index 75f9570f783..ea9a793154d 100644 --- a/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -148,7 +148,7 @@ ThrowCompletionOr> Intrinsics::create(Realm& realm) auto& vm = realm.vm(); // 1. Set realmRec.[[Intrinsics]] to a new Record. - auto intrinsics = vm.heap().allocate_without_realm(realm); + auto intrinsics = vm.heap().allocate(realm); realm.set_intrinsics({}, intrinsics); // 2. Set fields of realmRec.[[Intrinsics]] with the values listed in Table 6. @@ -179,26 +179,26 @@ ThrowCompletionOr Intrinsics::initialize_intrinsics(Realm& realm) auto& vm = this->vm(); // These are done first since other prototypes depend on their presence. - m_empty_object_shape = heap().allocate_without_realm(realm); - m_object_prototype = heap().allocate_without_realm(realm); + m_empty_object_shape = heap().allocate(realm); + m_object_prototype = heap().allocate(realm); m_object_prototype->convert_to_prototype_if_needed(); - m_function_prototype = heap().allocate_without_realm(realm); + m_function_prototype = heap().allocate(realm); m_function_prototype->convert_to_prototype_if_needed(); - m_new_object_shape = heap().allocate_without_realm(realm); + m_new_object_shape = heap().allocate(realm); m_new_object_shape->set_prototype_without_transition(m_object_prototype); // OPTIMIZATION: A lot of runtime algorithms create an "iterator result" object. // We pre-bake a shape for these objects and remember the property offsets. // This allows us to construct them very quickly. - m_iterator_result_object_shape = heap().allocate_without_realm(realm); + m_iterator_result_object_shape = heap().allocate(realm); m_iterator_result_object_shape->set_prototype_without_transition(m_object_prototype); m_iterator_result_object_shape->add_property_without_transition(vm.names.value, Attribute::Writable | Attribute::Configurable | Attribute::Enumerable); m_iterator_result_object_shape->add_property_without_transition(vm.names.done, Attribute::Writable | Attribute::Configurable | Attribute::Enumerable); 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 Realm::create() takes care of this, but these are allocated via Heap::allocate_without_realm(). + // Normally Realm::create() takes care of this, but these are allocated via Heap::allocate(). m_function_prototype->initialize(realm); m_object_prototype->initialize(realm); diff --git a/Libraries/LibJS/Runtime/JobCallback.cpp b/Libraries/LibJS/Runtime/JobCallback.cpp index be1cf4e19c2..ea22ce88473 100644 --- a/Libraries/LibJS/Runtime/JobCallback.cpp +++ b/Libraries/LibJS/Runtime/JobCallback.cpp @@ -13,7 +13,7 @@ JS_DEFINE_ALLOCATOR(JobCallback); JS::NonnullGCPtr JobCallback::create(JS::VM& vm, FunctionObject& callback, OwnPtr custom_data) { - return vm.heap().allocate_without_realm(callback, move(custom_data)); + return vm.heap().allocate(callback, move(custom_data)); } void JobCallback::visit_edges(Visitor& visitor) diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index 21a9cf78bc7..aa6450cca7f 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -39,7 +39,7 @@ NonnullGCPtr Object::create(Realm& realm, Object* prototype) NonnullGCPtr Object::create_prototype(Realm& realm, Object* prototype) { - auto shape = realm.heap().allocate_without_realm(realm); + auto shape = realm.heap().allocate(realm); if (prototype) shape->set_prototype_without_transition(prototype); return realm.create(shape); @@ -54,13 +54,13 @@ Object::Object(GlobalObjectTag, Realm& realm, MayInterfereWithIndexedPropertyAcc : m_may_interfere_with_indexed_property_access(may_interfere_with_indexed_property_access == MayInterfereWithIndexedPropertyAccess::Yes) { // This is the global object - m_shape = heap().allocate_without_realm(realm); + m_shape = heap().allocate(realm); } Object::Object(ConstructWithoutPrototypeTag, Realm& realm, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access) : m_may_interfere_with_indexed_property_access(may_interfere_with_indexed_property_access == MayInterfereWithIndexedPropertyAccess::Yes) { - m_shape = heap().allocate_without_realm(realm); + m_shape = heap().allocate(realm); } Object::Object(Realm& realm, Object* prototype, MayInterfereWithIndexedPropertyAccess may_interfere_with_indexed_property_access) diff --git a/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Libraries/LibJS/Runtime/PrimitiveString.cpp index 8eeb3c602e2..558152cc08c 100644 --- a/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -173,7 +173,7 @@ NonnullGCPtr PrimitiveString::create(VM& vm, Utf16String string if (auto it = string_cache.find(string); it != string_cache.end()) return *it->value; - auto new_string = vm.heap().allocate_without_realm(string); + auto new_string = vm.heap().allocate(string); string_cache.set(move(string), new_string); return *new_string; } @@ -193,7 +193,7 @@ NonnullGCPtr PrimitiveString::create(VM& vm, String string) if (auto it = string_cache.find(string); it != string_cache.end()) return *it->value; - auto new_string = vm.heap().allocate_without_realm(string); + auto new_string = vm.heap().allocate(string); string_cache.set(move(string), new_string); return *new_string; } @@ -222,7 +222,7 @@ NonnullGCPtr PrimitiveString::create(VM& vm, ByteString string) auto& string_cache = vm.byte_string_cache(); auto it = string_cache.find(string); if (it == string_cache.end()) { - auto new_string = vm.heap().allocate_without_realm(string); + auto new_string = vm.heap().allocate(string); string_cache.set(move(string), new_string); return *new_string; } @@ -251,7 +251,7 @@ NonnullGCPtr PrimitiveString::create(VM& vm, PrimitiveString& l if (rhs_empty) return lhs; - return vm.heap().allocate_without_realm(lhs, rhs); + return vm.heap().allocate(lhs, rhs); } void PrimitiveString::resolve_rope_if_needed(EncodingPreference preference) const diff --git a/Libraries/LibJS/Runtime/Promise.cpp b/Libraries/LibJS/Runtime/Promise.cpp index df000581c44..0d5a860b8d1 100644 --- a/Libraries/LibJS/Runtime/Promise.cpp +++ b/Libraries/LibJS/Runtime/Promise.cpp @@ -64,7 +64,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions() auto& realm = *vm.current_realm(); // 1. Let alreadyResolved be the Record { [[Value]]: false }. - auto already_resolved = vm.heap().allocate_without_realm(); + auto already_resolved = vm.heap().allocate(); // 2. Let stepsResolve be the algorithm steps defined in Promise Resolve Functions. // 3. Let lengthResolve be the number of non-optional parameters of the function definition in Promise Resolve Functions. diff --git a/Libraries/LibJS/Runtime/PromiseCapability.cpp b/Libraries/LibJS/Runtime/PromiseCapability.cpp index 11d3750eb07..a374ab2705d 100644 --- a/Libraries/LibJS/Runtime/PromiseCapability.cpp +++ b/Libraries/LibJS/Runtime/PromiseCapability.cpp @@ -15,7 +15,7 @@ JS_DEFINE_ALLOCATOR(PromiseCapability); NonnullGCPtr PromiseCapability::create(VM& vm, NonnullGCPtr promise, NonnullGCPtr resolve, NonnullGCPtr reject) { - return vm.heap().allocate_without_realm(promise, resolve, reject); + return vm.heap().allocate(promise, resolve, reject); } PromiseCapability::PromiseCapability(NonnullGCPtr promise, NonnullGCPtr resolve, NonnullGCPtr reject) diff --git a/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Libraries/LibJS/Runtime/PromiseConstructor.cpp index 435114daaed..996ad495750 100644 --- a/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -46,10 +46,10 @@ static ThrowCompletionOr perform_promise_common(VM& vm, IteratorRecord& i VERIFY(promise_resolve.is_function()); // 1. Let values be a new empty List. - auto values = vm.heap().allocate_without_realm(); + auto values = vm.heap().allocate(); // 2. Let remainingElementsCount be the Record { [[Value]]: 1 }. - auto remaining_elements_count = vm.heap().allocate_without_realm(1); + auto remaining_elements_count = vm.heap().allocate(1); // 3. Let index be 0. size_t index = 0; diff --git a/Libraries/LibJS/Runtime/PromiseReaction.cpp b/Libraries/LibJS/Runtime/PromiseReaction.cpp index b2893dd0b67..a861db78d1c 100644 --- a/Libraries/LibJS/Runtime/PromiseReaction.cpp +++ b/Libraries/LibJS/Runtime/PromiseReaction.cpp @@ -14,7 +14,7 @@ JS_DEFINE_ALLOCATOR(PromiseReaction); NonnullGCPtr PromiseReaction::create(VM& vm, Type type, GCPtr capability, GCPtr handler) { - return vm.heap().allocate_without_realm(type, capability, move(handler)); + return vm.heap().allocate(type, capability, move(handler)); } PromiseReaction::PromiseReaction(Type type, GCPtr capability, GCPtr handler) diff --git a/Libraries/LibJS/Runtime/Realm.cpp b/Libraries/LibJS/Runtime/Realm.cpp index 4c9d7a44142..5604e7fbe66 100644 --- a/Libraries/LibJS/Runtime/Realm.cpp +++ b/Libraries/LibJS/Runtime/Realm.cpp @@ -22,7 +22,7 @@ ThrowCompletionOr> Realm::initialize_host_define DeferGC defer_gc(vm.heap()); // 1. Let realm be a new Realm Record - auto realm = vm.heap().allocate_without_realm(); + auto realm = vm.heap().allocate(); // 2. Perform CreateIntrinsics(realm). MUST(Intrinsics::create(*realm)); @@ -61,7 +61,7 @@ ThrowCompletionOr> Realm::initialize_host_define // a. Let global be OrdinaryObjectCreate(realm.[[Intrinsics]].[[%Object.prototype%]]). // NOTE: We allocate a proper GlobalObject directly as this plain object is // turned into one via SetDefaultGlobalBindings in the spec. - global = vm.heap().allocate_without_realm(realm); + global = vm.heap().allocate(realm); } // 14. If the host requires that the this binding in realm's global scope return an object other than the global object, then @@ -80,7 +80,7 @@ ThrowCompletionOr> Realm::initialize_host_define realm->m_global_object = global; // 17. Set realm.[[GlobalEnv]] to NewGlobalEnvironment(global, thisValue). - realm->m_global_environment = vm.heap().allocate_without_realm(*global, *this_value); + realm->m_global_environment = vm.heap().allocate(*global, *this_value); // 18. Perform ? SetDefaultGlobalBindings(realm). set_default_global_bindings(*realm); diff --git a/Libraries/LibJS/Runtime/Realm.h b/Libraries/LibJS/Runtime/Realm.h index 8f8f3940c2d..dcbe5536ebf 100644 --- a/Libraries/LibJS/Runtime/Realm.h +++ b/Libraries/LibJS/Runtime/Realm.h @@ -35,7 +35,7 @@ public: template NonnullGCPtr create(Args&&... args) { - auto object = heap().allocate_without_realm(forward(args)...); + auto object = heap().allocate(forward(args)...); static_cast(object)->initialize(*this); return *object; } diff --git a/Libraries/LibJS/Runtime/Shape.cpp b/Libraries/LibJS/Runtime/Shape.cpp index 73e8e679254..5367e993fd3 100644 --- a/Libraries/LibJS/Runtime/Shape.cpp +++ b/Libraries/LibJS/Runtime/Shape.cpp @@ -23,7 +23,7 @@ Shape::~Shape() NonnullGCPtr Shape::create_cacheable_dictionary_transition() { - auto new_shape = heap().allocate_without_realm(m_realm); + auto new_shape = heap().allocate(m_realm); new_shape->m_dictionary = true; new_shape->m_cacheable = true; new_shape->m_prototype = m_prototype; @@ -37,7 +37,7 @@ NonnullGCPtr Shape::create_cacheable_dictionary_transition() NonnullGCPtr Shape::create_uncacheable_dictionary_transition() { - auto new_shape = heap().allocate_without_realm(m_realm); + auto new_shape = heap().allocate(m_realm); new_shape->m_dictionary = true; new_shape->m_cacheable = true; new_shape->m_prototype = m_prototype; @@ -105,7 +105,7 @@ NonnullGCPtr Shape::create_put_transition(StringOrSymbol const& property_ TransitionKey key { property_key, attributes }; if (auto existing_shape = get_or_prune_cached_forward_transition(key)) return *existing_shape; - auto new_shape = heap().allocate_without_realm(*this, property_key, attributes, TransitionType::Put); + auto new_shape = heap().allocate(*this, property_key, attributes, TransitionType::Put); invalidate_prototype_if_needed_for_new_prototype(new_shape); if (!m_is_prototype_shape) { if (!m_forward_transitions) @@ -120,7 +120,7 @@ NonnullGCPtr Shape::create_configure_transition(StringOrSymbol const& pro TransitionKey key { property_key, attributes }; if (auto existing_shape = get_or_prune_cached_forward_transition(key)) return *existing_shape; - auto new_shape = heap().allocate_without_realm(*this, property_key, attributes, TransitionType::Configure); + auto new_shape = heap().allocate(*this, property_key, attributes, TransitionType::Configure); invalidate_prototype_if_needed_for_new_prototype(new_shape); if (!m_is_prototype_shape) { if (!m_forward_transitions) @@ -136,7 +136,7 @@ NonnullGCPtr Shape::create_prototype_transition(Object* new_prototype) new_prototype->convert_to_prototype_if_needed(); if (auto existing_shape = get_or_prune_cached_prototype_transition(new_prototype)) return *existing_shape; - auto new_shape = heap().allocate_without_realm(*this, new_prototype); + auto new_shape = heap().allocate(*this, new_prototype); invalidate_prototype_if_needed_for_new_prototype(new_shape); if (!m_is_prototype_shape) { if (!m_prototype_transitions) @@ -274,7 +274,7 @@ NonnullGCPtr Shape::create_delete_transition(StringOrSymbol const& proper { if (auto existing_shape = get_or_prune_cached_delete_transition(property_key)) return *existing_shape; - auto new_shape = heap().allocate_without_realm(*this, property_key, TransitionType::Delete); + auto new_shape = heap().allocate(*this, property_key, TransitionType::Delete); invalidate_prototype_if_needed_for_new_prototype(new_shape); if (!m_delete_transitions) m_delete_transitions = make>>(); @@ -321,11 +321,11 @@ void Shape::remove_property_without_transition(StringOrSymbol const& property_ke NonnullGCPtr Shape::create_for_prototype(NonnullGCPtr realm, GCPtr prototype) { - auto new_shape = realm->heap().allocate_without_realm(realm); + auto new_shape = realm->heap().allocate(realm); s_all_prototype_shapes.set(new_shape); new_shape->m_is_prototype_shape = true; new_shape->m_prototype = prototype; - new_shape->m_prototype_chain_validity = realm->heap().allocate_without_realm(); + new_shape->m_prototype_chain_validity = realm->heap().allocate(); return new_shape; } @@ -333,7 +333,7 @@ NonnullGCPtr Shape::clone_for_prototype() { VERIFY(!m_is_prototype_shape); VERIFY(!m_prototype_chain_validity); - auto new_shape = heap().allocate_without_realm(m_realm); + auto new_shape = heap().allocate(m_realm); s_all_prototype_shapes.set(new_shape); new_shape->m_is_prototype_shape = true; new_shape->m_prototype = m_prototype; @@ -341,7 +341,7 @@ NonnullGCPtr Shape::clone_for_prototype() new_shape->ensure_property_table(); (*new_shape->m_property_table) = *m_property_table; new_shape->m_property_count = new_shape->m_property_table->size(); - new_shape->m_prototype_chain_validity = heap().allocate_without_realm(); + new_shape->m_prototype_chain_validity = heap().allocate(); return new_shape; } @@ -357,7 +357,7 @@ void Shape::set_prototype_shape() VERIFY(!m_is_prototype_shape); s_all_prototype_shapes.set(this); m_is_prototype_shape = true; - m_prototype_chain_validity = heap().allocate_without_realm(); + m_prototype_chain_validity = heap().allocate(); } void Shape::invalidate_prototype_if_needed_for_new_prototype(NonnullGCPtr new_prototype_shape) @@ -388,7 +388,7 @@ void Shape::invalidate_all_prototype_chains_leading_to_this() return; for (auto* shape : shapes_to_invalidate) { shape->m_prototype_chain_validity->set_valid(false); - shape->m_prototype_chain_validity = heap().allocate_without_realm(); + shape->m_prototype_chain_validity = heap().allocate(); } } diff --git a/Libraries/LibJS/Runtime/Symbol.cpp b/Libraries/LibJS/Runtime/Symbol.cpp index 2737adeacab..c22f5c2c7b5 100644 --- a/Libraries/LibJS/Runtime/Symbol.cpp +++ b/Libraries/LibJS/Runtime/Symbol.cpp @@ -21,7 +21,7 @@ Symbol::Symbol(Optional description, bool is_global) NonnullGCPtr Symbol::create(VM& vm, Optional description, bool is_global) { - return vm.heap().allocate_without_realm(move(description), is_global); + return vm.heap().allocate(move(description), is_global); } // 20.4.3.3.1 SymbolDescriptiveString ( sym ), https://tc39.es/ecma262/#sec-symboldescriptivestring diff --git a/Libraries/LibJS/Runtime/VM.cpp b/Libraries/LibJS/Runtime/VM.cpp index 2f91b97639a..111bf8ad760 100644 --- a/Libraries/LibJS/Runtime/VM.cpp +++ b/Libraries/LibJS/Runtime/VM.cpp @@ -68,21 +68,21 @@ VM::VM(OwnPtr custom_data, ErrorMessages error_messages) { m_bytecode_interpreter = make(*this); - m_empty_string = m_heap.allocate_without_realm(String {}); + m_empty_string = m_heap.allocate(String {}); typeof_strings = { - .number = m_heap.allocate_without_realm("number"), - .undefined = m_heap.allocate_without_realm("undefined"), - .object = m_heap.allocate_without_realm("object"), - .string = m_heap.allocate_without_realm("string"), - .symbol = m_heap.allocate_without_realm("symbol"), - .boolean = m_heap.allocate_without_realm("boolean"), - .bigint = m_heap.allocate_without_realm("bigint"), - .function = m_heap.allocate_without_realm("function"), + .number = m_heap.allocate("number"), + .undefined = m_heap.allocate("undefined"), + .object = m_heap.allocate("object"), + .string = m_heap.allocate("string"), + .symbol = m_heap.allocate("symbol"), + .boolean = m_heap.allocate("boolean"), + .bigint = m_heap.allocate("bigint"), + .function = m_heap.allocate("function"), }; for (size_t i = 0; i < single_ascii_character_strings.size(); ++i) - m_single_ascii_character_strings[i] = m_heap.allocate_without_realm(single_ascii_character_strings[i]); + m_single_ascii_character_strings[i] = m_heap.allocate(single_ascii_character_strings[i]); // Default hook implementations. These can be overridden by the host, for example, LibWeb overrides the default hooks to place promise jobs on the microtask queue. host_promise_rejection_tracker = [this](Promise& promise, Promise::RejectionOperation operation) { diff --git a/Libraries/LibJS/Runtime/VM.h b/Libraries/LibJS/Runtime/VM.h index 20343ce635e..dbc14701879 100644 --- a/Libraries/LibJS/Runtime/VM.h +++ b/Libraries/LibJS/Runtime/VM.h @@ -358,7 +358,7 @@ template auto root_execution_context = MUST(Realm::initialize_host_defined_realm( vm, [&](Realm& realm_) -> GlobalObject* { - return vm.heap().allocate_without_realm(realm_, forward(args)...); + return vm.heap().allocate(realm_, forward(args)...); }, nullptr)); return root_execution_context; diff --git a/Libraries/LibJS/Script.cpp b/Libraries/LibJS/Script.cpp index eb6933ca8f7..80a93cccf61 100644 --- a/Libraries/LibJS/Script.cpp +++ b/Libraries/LibJS/Script.cpp @@ -26,7 +26,7 @@ Result, Vector> Script::parse(StringView sourc return parser.errors(); // 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }. - return realm.heap().allocate_without_realm