mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 17:28:30 +00:00
LibJS: Prebake the empty object ({}) with a prototype
Instead of performing a prototype transition for every new object we
create via {}, prebake the object returned by Object::create_empty()
with a shape with ObjectPrototype as the prototype.
We also prebake the shape for the object assigned to the "prototype"
property of new ScriptFunction objects, since those are extremely
common and that code broke from this change anyway.
This avoid a large number of transitions and is a small speed-up on
test-js.
This commit is contained in:
@@ -69,8 +69,8 @@ void ScriptFunction::initialize(GlobalObject& global_object)
|
||||
auto& vm = this->vm();
|
||||
Function::initialize(global_object);
|
||||
if (!m_is_arrow_function) {
|
||||
Object* prototype = Object::create_empty(global_object);
|
||||
prototype->define_property_without_transition(vm.names.constructor, this, Attribute::Writable | Attribute::Configurable);
|
||||
Object* prototype = vm.heap().allocate<Object>(global_object, *global_object.new_script_function_prototype_object_shape());
|
||||
prototype->define_property(vm.names.constructor, this, Attribute::Writable | Attribute::Configurable);
|
||||
define_property(vm.names.prototype, prototype, 0);
|
||||
}
|
||||
define_native_property(vm.names.length, length_getter, nullptr, Attribute::Configurable);
|
||||
|
||||
Reference in New Issue
Block a user