1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:08:11 +00:00

LibJS: Add optimized GetGlobal instruction to access global variables

Using a special instruction to access global variables allows skipping
the environment chain traversal for them and going directly to the
module/global environment. Currently, this instruction only caches the
offset for bindings that belong to the global object environment.
However, there is also an opportunity to cache the offset in the global
declarative record.

This change results in a 57% increase in speed for
imaging-gaussian-blur.js in Kraken.
This commit is contained in:
Aliaksandr Kalenik 2023-07-12 04:06:59 +02:00 committed by Andreas Kling
parent a27c4cf63c
commit 3661d674ae
7 changed files with 95 additions and 1 deletions

View file

@ -57,9 +57,13 @@ CodeGenerationErrorOr<NonnullOwnPtr<Executable>> Generator::generate(ASTNode con
Vector<PropertyLookupCache> property_lookup_caches;
property_lookup_caches.resize(generator.m_next_property_lookup_cache);
Vector<GlobalVariableCache> global_variable_caches;
global_variable_caches.resize(generator.m_next_global_variable_cache);
return adopt_own(*new Executable {
.name = {},
.property_lookup_caches = move(property_lookup_caches),
.global_variable_caches = move(global_variable_caches),
.basic_blocks = move(generator.m_root_basic_blocks),
.string_table = move(generator.m_string_table),
.identifier_table = move(generator.m_identifier_table),