diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index ad1437a68fe..97e9ad4c390 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -354,8 +354,8 @@ void ECMAScriptFunctionObject::initialize(Realm& realm) Object* prototype = nullptr; switch (m_kind) { case FunctionKind::Normal: - prototype = Object::create_with_premade_shape(realm.intrinsics().new_function_object_prototype_shape()); - prototype->put_direct(realm.intrinsics().new_function_object_prototype_constructor_offset(), this); + prototype = Object::create_prototype(realm, realm.intrinsics().object_prototype()); + MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true })); break; case FunctionKind::Generator: // prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png) diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp index 24058b2540d..9016dc4075c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.cpp @@ -188,12 +188,6 @@ ThrowCompletionOr Intrinsics::initialize_intrinsics(Realm& realm) m_new_object_shape = heap().allocate_without_realm(realm); m_new_object_shape->set_prototype_without_transition(m_object_prototype); - m_new_function_object_prototype_shape = heap().allocate_without_realm(realm); - m_new_function_object_prototype_shape->set_prototype_shape(); - m_new_function_object_prototype_shape->set_prototype_without_transition(m_object_prototype); - m_new_function_object_prototype_shape->add_property_without_transition(vm.names.constructor, Attribute::Writable | Attribute::Configurable | Attribute::Enumerable); - m_new_function_object_prototype_constructor_offset = m_new_function_object_prototype_shape->lookup(vm.names.constructor.to_string_or_symbol()).value().offset; - // 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. @@ -373,7 +367,6 @@ void Intrinsics::visit_edges(Visitor& visitor) visitor.visit(m_realm); visitor.visit(m_empty_object_shape); visitor.visit(m_new_object_shape); - visitor.visit(m_new_function_object_prototype_shape); visitor.visit(m_iterator_result_object_shape); visitor.visit(m_proxy_constructor); visitor.visit(m_async_from_sync_iterator_prototype); diff --git a/Userland/Libraries/LibJS/Runtime/Intrinsics.h b/Userland/Libraries/LibJS/Runtime/Intrinsics.h index 9a3a93460f3..5b2ff4f4937 100644 --- a/Userland/Libraries/LibJS/Runtime/Intrinsics.h +++ b/Userland/Libraries/LibJS/Runtime/Intrinsics.h @@ -22,9 +22,6 @@ public: NonnullGCPtr new_object_shape() { return *m_new_object_shape; } - [[nodiscard]] NonnullGCPtr new_function_object_prototype_shape() { return *m_new_function_object_prototype_shape; } - [[nodiscard]] u32 new_function_object_prototype_constructor_offset() { return m_new_function_object_prototype_constructor_offset; } - [[nodiscard]] NonnullGCPtr iterator_result_object_shape() { return *m_iterator_result_object_shape; } [[nodiscard]] u32 iterator_result_object_value_offset() { return m_iterator_result_object_value_offset; } [[nodiscard]] u32 iterator_result_object_done_offset() { return m_iterator_result_object_done_offset; } @@ -128,9 +125,6 @@ private: GCPtr m_empty_object_shape; GCPtr m_new_object_shape; - GCPtr m_new_function_object_prototype_shape; - u32 m_new_function_object_prototype_constructor_offset { 0 }; - GCPtr m_iterator_result_object_shape; u32 m_iterator_result_object_value_offset { 0 }; u32 m_iterator_result_object_done_offset { 0 };