diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-07 01:06:21 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-07 11:53:18 +0200 |
commit | 41a072bded25b0993f315bc86e11cae8419f3231 (patch) | |
tree | 59de353aa7622da579ecc4e7c5627a07e8370f6e /Meta/screenshot-cdb82f6.png | |
parent | 421845b0cd109d3532beb9dfc06e44169b846505 (diff) | |
download | serenity-41a072bded25b0993f315bc86e11cae8419f3231.zip |
LibJS: Fast non-local variable access :^)
This patch introduces the "environment coordinate" concept, which
encodes the distance from a variable access to the binding it ends up
resolving to.
EnvironmentCoordinate has two fields:
- hops: The number of hops up the lexical environment chain we have
to make before getting to the resolved binding.
- index: The index of the resolved binding within its declarative
environment record.
Whenever a variable lookup resolves somewhere inside a declarative
environment, we now cache the coordinates and reuse them in subsequent
lookups. This is achieved via a coordinate cache in JS::Identifier.
Note that non-strict direct eval() breaks this optimization and so it
will not be performed if the resolved environment has been permanently
screwed by eval().
This makes variable access *significantly* faster. :^)
Diffstat (limited to 'Meta/screenshot-cdb82f6.png')
0 files changed, 0 insertions, 0 deletions