Bläddra i källkod

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.
Andreas Kling 5 år sedan
förälder
incheckning
3ee6ed965f

+ 2 - 2
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<Accessor>(global_object, getter, setter);
+        return interpreter.heap().allocate_without_global_object<Accessor>(getter, setter);
     }
 
     Accessor(Function* getter, Function* setter)

+ 1 - 1
Libraries/LibJS/Runtime/BigInt.cpp

@@ -42,7 +42,7 @@ BigInt::~BigInt()
 
 BigInt* js_bigint(Heap& heap, Crypto::SignedBigInteger big_integer)
 {
-    return heap.allocate<BigInt>(heap.interpreter().global_object(), move(big_integer));
+    return heap.allocate_without_global_object<BigInt>(move(big_integer));
 }
 
 BigInt* js_bigint(Interpreter& interpreter, Crypto::SignedBigInteger big_integer)

+ 3 - 3
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<Value(Interpreter&, GlobalObject&)> getter, AK::Function<void(Interpreter&, GlobalObject&, Value)> setter, PropertyAttributes attribute)
 {
-    return define_property(property_name, heap().allocate<NativeProperty>(global_object(), move(getter), move(setter)), attribute);
+    return define_property(property_name, heap().allocate_without_global_object<NativeProperty>(move(getter), move(setter)), attribute);
 }
 
 void Object::visit_children(Cell::Visitor& visitor)

+ 1 - 1
Libraries/LibJS/Runtime/PrimitiveString.cpp

@@ -41,7 +41,7 @@ PrimitiveString::~PrimitiveString()
 
 PrimitiveString* js_string(Heap& heap, String string)
 {
-    return heap.allocate<PrimitiveString>(heap.interpreter().global_object(), move(string));
+    return heap.allocate_without_global_object<PrimitiveString>(move(string));
 }
 
 PrimitiveString* js_string(Interpreter& interpreter, String string)

+ 1 - 1
Libraries/LibJS/Runtime/Symbol.cpp

@@ -42,7 +42,7 @@ Symbol::~Symbol()
 
 Symbol* js_symbol(Heap& heap, String description, bool is_global)
 {
-    return heap.allocate<Symbol>(heap.interpreter().global_object(), move(description), is_global);
+    return heap.allocate_without_global_object<Symbol>(move(description), is_global);
 }
 
 Symbol* js_symbol(Interpreter& interpreter, String description, bool is_global)