diff options
author | Andreas Kling <kling@serenityos.org> | 2020-10-13 23:49:19 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-13 23:57:45 +0200 |
commit | 7b863330dc72e5715b17726cdbae95c168015363 (patch) | |
tree | 81d02a3c177d86a3295994ef1c1ccb851686d551 /Libraries/LibJS/Runtime/BigIntConstructor.cpp | |
parent | 9f6c5f68b663442d4197ab7d93b9da4a0249d575 (diff) | |
download | serenity-7b863330dc72e5715b17726cdbae95c168015363.zip |
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.
Diffstat (limited to 'Libraries/LibJS/Runtime/BigIntConstructor.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/BigIntConstructor.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Libraries/LibJS/Runtime/BigIntConstructor.cpp index 25696f4fbb..5eec127b63 100644 --- a/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -35,19 +35,20 @@ namespace JS { BigIntConstructor::BigIntConstructor(GlobalObject& global_object) - : NativeFunction("BigInt", *global_object.function_prototype()) + : NativeFunction(vm().names.BigInt, *global_object.function_prototype()) { } void BigIntConstructor::initialize(GlobalObject& global_object) { + auto& vm = this->vm(); NativeFunction::initialize(global_object); - define_property("prototype", global_object.bigint_prototype(), 0); - define_property("length", Value(1), Attribute::Configurable); + define_property(vm.names.prototype, global_object.bigint_prototype(), 0); + define_property(vm.names.length, Value(1), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; - define_native_function("asIntN", as_int_n, 2, attr); - define_native_function("asUintN", as_uint_n, 2, attr); + define_native_function(vm.names.asIntN, as_int_n, 2, attr); + define_native_function(vm.names.asUintN, as_uint_n, 2, attr); } BigIntConstructor::~BigIntConstructor() |