From 3ee6ed965f5d41c4d728158b494da407f2ac5b9f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 24 Jul 2020 20:46:55 +0200 Subject: [PATCH] LibJS: Use allocate_without_global_object for primitive cell types More steps towards multiple global object support. Primitive cells like strings, bigints, etc, don't actually have any connection to the global object. Use the explicit API to clarify this. --- Libraries/LibJS/Runtime/Accessor.h | 4 ++-- Libraries/LibJS/Runtime/BigInt.cpp | 2 +- Libraries/LibJS/Runtime/Object.cpp | 6 +++--- Libraries/LibJS/Runtime/PrimitiveString.cpp | 2 +- Libraries/LibJS/Runtime/Symbol.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/LibJS/Runtime/Accessor.h b/Libraries/LibJS/Runtime/Accessor.h index dd6d36fd70b..115a405ffac 100644 --- a/Libraries/LibJS/Runtime/Accessor.h +++ b/Libraries/LibJS/Runtime/Accessor.h @@ -35,9 +35,9 @@ namespace JS { class Accessor final : public Cell { public: - static Accessor* create(Interpreter& interpreter, GlobalObject& global_object, Function* getter, Function* setter) + static Accessor* create(Interpreter& interpreter, Function* getter, Function* setter) { - return interpreter.heap().allocate(global_object, getter, setter); + return interpreter.heap().allocate_without_global_object(getter, setter); } Accessor(Function* getter, Function* setter) diff --git a/Libraries/LibJS/Runtime/BigInt.cpp b/Libraries/LibJS/Runtime/BigInt.cpp index 3b7d97c4d7d..9c7a4a06fdb 100644 --- a/Libraries/LibJS/Runtime/BigInt.cpp +++ b/Libraries/LibJS/Runtime/BigInt.cpp @@ -42,7 +42,7 @@ BigInt::~BigInt() BigInt* js_bigint(Heap& heap, Crypto::SignedBigInteger big_integer) { - return heap.allocate(heap.interpreter().global_object(), move(big_integer)); + return heap.allocate_without_global_object(move(big_integer)); } BigInt* js_bigint(Interpreter& interpreter, Crypto::SignedBigInteger big_integer) diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index 34f36bf2d0a..b026dff3be1 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -392,7 +392,7 @@ bool Object::define_property(const StringOrSymbol& property_name, const Object& << "setter=" << setter.to_string_without_side_effects() << "}"; #endif - return define_property(property_name, Accessor::create(interpreter(), global_object(), getter_function, setter_function), attributes, throw_exceptions); + return define_property(property_name, Accessor::create(interpreter(), getter_function, setter_function), attributes, throw_exceptions); } auto value = descriptor.get("value"); @@ -438,7 +438,7 @@ bool Object::define_accessor(const PropertyName& property_name, Function& getter accessor = &existing_property.as_accessor(); } if (!accessor) { - accessor = Accessor::create(interpreter(), global_object(), nullptr, nullptr); + accessor = Accessor::create(interpreter(), nullptr, nullptr); bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions); if (interpreter().exception()) return {}; @@ -762,7 +762,7 @@ bool Object::define_native_function(const StringOrSymbol& property_name, AK::Fun bool Object::define_native_property(const StringOrSymbol& property_name, AK::Function getter, AK::Function setter, PropertyAttributes attribute) { - return define_property(property_name, heap().allocate(global_object(), move(getter), move(setter)), attribute); + return define_property(property_name, heap().allocate_without_global_object(move(getter), move(setter)), attribute); } void Object::visit_children(Cell::Visitor& visitor) diff --git a/Libraries/LibJS/Runtime/PrimitiveString.cpp b/Libraries/LibJS/Runtime/PrimitiveString.cpp index 428295e8615..cbb58e3fd93 100644 --- a/Libraries/LibJS/Runtime/PrimitiveString.cpp +++ b/Libraries/LibJS/Runtime/PrimitiveString.cpp @@ -41,7 +41,7 @@ PrimitiveString::~PrimitiveString() PrimitiveString* js_string(Heap& heap, String string) { - return heap.allocate(heap.interpreter().global_object(), move(string)); + return heap.allocate_without_global_object(move(string)); } PrimitiveString* js_string(Interpreter& interpreter, String string) diff --git a/Libraries/LibJS/Runtime/Symbol.cpp b/Libraries/LibJS/Runtime/Symbol.cpp index 25975b5c568..c4fa0f3b8e5 100644 --- a/Libraries/LibJS/Runtime/Symbol.cpp +++ b/Libraries/LibJS/Runtime/Symbol.cpp @@ -42,7 +42,7 @@ Symbol::~Symbol() Symbol* js_symbol(Heap& heap, String description, bool is_global) { - return heap.allocate(heap.interpreter().global_object(), move(description), is_global); + return heap.allocate_without_global_object(move(description), is_global); } Symbol* js_symbol(Interpreter& interpreter, String description, bool is_global)