1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 18:15:06 +00:00

LibJS: Cache commonly used FlyStrings in the VM

Roughly 7% of test-js runtime was spent creating FlyStrings from string
literals. This patch frontloads that work and caches all the commonly
used names in LibJS on a CommonPropertyNames struct that hangs off VM.
This commit is contained in:
Andreas Kling 2020-10-13 23:49:19 +02:00
parent 9f6c5f68b6
commit 7b863330dc
45 changed files with 651 additions and 392 deletions

View file

@ -66,14 +66,15 @@ ScriptFunction::ScriptFunction(GlobalObject& global_object, const FlyString& nam
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("constructor", this, Attribute::Writable | Attribute::Configurable);
define_property("prototype", prototype, 0);
prototype->define_property_without_transition(vm.names.constructor, this, Attribute::Writable | Attribute::Configurable);
define_property(vm.names.prototype, prototype, 0);
}
define_native_property("length", length_getter, nullptr, Attribute::Configurable);
define_native_property("name", name_getter, nullptr, Attribute::Configurable);
define_native_property(vm.names.length, length_getter, nullptr, Attribute::Configurable);
define_native_property(vm.names.name, name_getter, nullptr, Attribute::Configurable);
}
ScriptFunction::~ScriptFunction()