mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibJS: Use a premade shape for normal function object prototypes
This avoids one shape allocation per function instantiation.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
dba1798de7
commit
8af5f25dd0
Notes:
github-actions[bot]
2025-03-27 15:01:47 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/8af5f25dd0f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4119 Reviewed-by: https://github.com/gmta ✅
@@ -354,8 +354,8 @@ void ECMAScriptFunctionObject::initialize(Realm& realm)
|
||||
Object* prototype = nullptr;
|
||||
switch (m_kind) {
|
||||
case FunctionKind::Normal:
|
||||
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 }));
|
||||
prototype = Object::create_with_premade_shape(realm.intrinsics().normal_function_prototype_shape());
|
||||
prototype->put_direct(realm.intrinsics().normal_function_prototype_constructor_offset(), this);
|
||||
break;
|
||||
case FunctionKind::Generator:
|
||||
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
|
||||
|
||||
Reference in New Issue
Block a user