summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibJS/Runtime/Object.h2
-rw-r--r--Libraries/LibJS/Runtime/Shape.cpp11
-rw-r--r--Libraries/LibJS/Runtime/Shape.h7
3 files changed, 14 insertions, 6 deletions
diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h
index 8f8364d458..dc26719b2c 100644
--- a/Libraries/LibJS/Runtime/Object.h
+++ b/Libraries/LibJS/Runtime/Object.h
@@ -88,7 +88,7 @@ public:
Shape& shape() { return *m_shape; }
const Shape& shape() const { return *m_shape; }
- GlobalObject& global_object() const { return shape().global_object(); }
+ GlobalObject& global_object() const { return *shape().global_object(); }
virtual Value get(const PropertyName&, Value receiver = {}) const;
diff --git a/Libraries/LibJS/Runtime/Shape.cpp b/Libraries/LibJS/Runtime/Shape.cpp
index 0be64ae9c9..85c7af9595 100644
--- a/Libraries/LibJS/Runtime/Shape.cpp
+++ b/Libraries/LibJS/Runtime/Shape.cpp
@@ -32,7 +32,8 @@ namespace JS {
Shape* Shape::create_unique_clone() const
{
- auto* new_shape = heap().allocate_without_global_object<Shape>(m_global_object);
+ ASSERT(m_global_object);
+ auto* new_shape = heap().allocate_without_global_object<Shape>(*m_global_object);
new_shape->m_unique = true;
new_shape->m_prototype = m_prototype;
ensure_property_table();
@@ -67,8 +68,12 @@ Shape* Shape::create_prototype_transition(Object* new_prototype)
return heap().allocate_without_global_object<Shape>(*this, new_prototype);
}
+Shape::Shape(ShapeWithoutGlobalObjectTag)
+{
+}
+
Shape::Shape(GlobalObject& global_object)
- : m_global_object(global_object)
+ : m_global_object(&global_object)
{
}
@@ -99,7 +104,7 @@ Shape::~Shape()
void Shape::visit_children(Cell::Visitor& visitor)
{
Cell::visit_children(visitor);
- visitor.visit(&m_global_object);
+ visitor.visit(m_global_object);
visitor.visit(m_prototype);
visitor.visit(m_previous);
m_property_name.visit_children(visitor);
diff --git a/Libraries/LibJS/Runtime/Shape.h b/Libraries/LibJS/Runtime/Shape.h
index d5464a9eba..279462e927 100644
--- a/Libraries/LibJS/Runtime/Shape.h
+++ b/Libraries/LibJS/Runtime/Shape.h
@@ -62,6 +62,9 @@ public:
Prototype,
};
+ enum class ShapeWithoutGlobalObjectTag { Tag };
+
+ explicit Shape(ShapeWithoutGlobalObjectTag);
explicit Shape(GlobalObject&);
Shape(Shape& previous_shape, const StringOrSymbol& property_name, PropertyAttributes attributes, TransitionType);
Shape(Shape& previous_shape, Object* new_prototype);
@@ -75,7 +78,7 @@ public:
bool is_unique() const { return m_unique; }
Shape* create_unique_clone() const;
- GlobalObject& global_object() const { return m_global_object; }
+ GlobalObject* global_object() const { return m_global_object; }
Object* prototype() { return m_prototype; }
const Object* prototype() const { return m_prototype; }
@@ -107,7 +110,7 @@ private:
TransitionType m_transition_type : 6 { TransitionType::Invalid };
bool m_unique : 1 { false };
- GlobalObject& m_global_object;
+ GlobalObject* m_global_object { nullptr };
mutable OwnPtr<HashMap<StringOrSymbol, PropertyMetadata>> m_property_table;