From ec55490198052f65f3e4ecba61e3d992704a3d9f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 4 Oct 2020 22:56:45 +0200 Subject: [PATCH] LibJS: Make global objects have unique shape from the start There's no point in trying to achieve shape sharing for global objects, so we can simply make the shape unique from the start and avoid making a transition chain. --- Libraries/LibJS/Runtime/GlobalObject.cpp | 2 ++ Libraries/LibJS/Runtime/Object.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/LibJS/Runtime/GlobalObject.cpp b/Libraries/LibJS/Runtime/GlobalObject.cpp index db8bda0962..c4a52a6a80 100644 --- a/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -75,6 +75,8 @@ GlobalObject::GlobalObject() void GlobalObject::initialize() { + ensure_shape_is_unique(); + // These are done first since other prototypes depend on their presence. m_empty_object_shape = heap().allocate(*this, *this); m_object_prototype = heap().allocate_without_global_object(*this); diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h index e8e4b78301..7f55582258 100644 --- a/Libraries/LibJS/Runtime/Object.h +++ b/Libraries/LibJS/Runtime/Object.h @@ -149,6 +149,8 @@ public: Value invoke(const StringOrSymbol& property_name, Optional arguments = {}); + void ensure_shape_is_unique(); + protected: enum class GlobalObjectTag { Tag }; enum class ConstructWithoutPrototypeTag { Tag }; @@ -165,7 +167,6 @@ private: void call_native_property_setter(Object* this_object, Value property, Value) const; void set_shape(Shape&); - void ensure_shape_is_unique(); bool m_is_extensible { true }; Shape* m_shape { nullptr };