mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +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:
parent
9f6c5f68b6
commit
7b863330dc
45 changed files with 651 additions and 392 deletions
|
@ -62,7 +62,7 @@ Object* iterator_next(Object& iterator, Value value)
|
|||
{
|
||||
auto& vm = iterator.vm();
|
||||
auto& global_object = iterator.global_object();
|
||||
auto next_method = iterator.get("next");
|
||||
auto next_method = iterator.get(vm.names.next);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
|
@ -95,9 +95,10 @@ void iterator_close(Object& iterator)
|
|||
|
||||
Value create_iterator_result_object(GlobalObject& global_object, Value value, bool done)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto* object = Object::create_empty(global_object);
|
||||
object->define_property("value", value);
|
||||
object->define_property("done", Value(done));
|
||||
object->define_property(vm.names.value, value);
|
||||
object->define_property(vm.names.done, Value(done));
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -114,14 +115,14 @@ void get_iterator_values(GlobalObject& global_object, Value value, AK::Function<
|
|||
if (!next_object)
|
||||
return;
|
||||
|
||||
auto done_property = next_object->get("done");
|
||||
auto done_property = next_object->get(vm.names.done);
|
||||
if (vm.exception())
|
||||
return;
|
||||
|
||||
if (!done_property.is_empty() && done_property.to_boolean())
|
||||
return;
|
||||
|
||||
auto next_value = next_object->get("value");
|
||||
auto next_value = next_object->get(vm.names.value);
|
||||
if (vm.exception())
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue