mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +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:
@@ -37,7 +37,7 @@
|
||||
namespace JS {
|
||||
|
||||
ArrayConstructor::ArrayConstructor(GlobalObject& global_object)
|
||||
: NativeFunction("Array", *global_object.function_prototype())
|
||||
: NativeFunction(vm().names.Array, *global_object.function_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,15 +47,16 @@ ArrayConstructor::~ArrayConstructor()
|
||||
|
||||
void ArrayConstructor::initialize(GlobalObject& global_object)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(global_object);
|
||||
|
||||
define_property("prototype", global_object.array_prototype(), 0);
|
||||
define_property("length", Value(1), Attribute::Configurable);
|
||||
define_property(vm.names.prototype, global_object.array_prototype(), 0);
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function("from", from, 1, attr);
|
||||
define_native_function("isArray", is_array, 1, attr);
|
||||
define_native_function("of", of, 0, attr);
|
||||
define_native_function(vm.names.from, from, 1, attr);
|
||||
define_native_function(vm.names.isArray, is_array, 1, attr);
|
||||
define_native_function(vm.names.of, of, 0, attr);
|
||||
}
|
||||
|
||||
Value ArrayConstructor::call()
|
||||
|
||||
Reference in New Issue
Block a user