mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +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:
parent
919fc7a814
commit
d3dfd55472
Notes:
sideshowbarker
2024-07-19 01:52:02 +09:00
Author: https://github.com/awesomekling
Commit: d3dfd55472
5 changed files with 24 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue