mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:37:34 +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:
parent
a27c4cf63c
commit
3661d674ae
7 changed files with 95 additions and 1 deletions
|
@ -202,6 +202,8 @@ public:
|
|||
void emit_get_by_id(IdentifierTableIndex);
|
||||
void emit_get_by_id_with_this(IdentifierTableIndex, Register);
|
||||
|
||||
[[nodiscard]] size_t next_global_variable_cache() { return m_next_global_variable_cache++; }
|
||||
|
||||
private:
|
||||
Generator();
|
||||
~Generator() = default;
|
||||
|
@ -222,6 +224,7 @@ private:
|
|||
u32 m_next_register { 2 };
|
||||
u32 m_next_block { 1 };
|
||||
u32 m_next_property_lookup_cache { 0 };
|
||||
u32 m_next_global_variable_cache { 0 };
|
||||
FunctionKind m_enclosing_function_kind { FunctionKind::Normal };
|
||||
Vector<LabelableScope> m_continuable_scopes;
|
||||
Vector<LabelableScope> m_breakable_scopes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue