LibJS: Optimize reading known-to-be-initialized var bindings

`var` bindings are never in the temporal dead zone (TDZ), and so we
know accessing them will not throw.

We now take advantage of this by having a specialized environment
binding value getter that doesn't check for exceptional cases.

1.08x speedup on JetStream.
This commit is contained in:
Andreas Kling 2025-05-04 01:41:49 +02:00 committed by Andreas Kling
parent ad7c1e147f
commit bf1b754e91
Notes: github-actions[bot] 2025-05-04 00:32:11 +00:00
8 changed files with 90 additions and 15 deletions

View file

@ -292,6 +292,12 @@ public:
auto const& identifier_group_name = it.key;
auto& identifier_group = it.value;
if (identifier_group.declaration_kind.has_value()) {
for (auto& identifier : identifier_group.identifiers) {
identifier->set_declaration_kind(identifier_group.declaration_kind.value());
}
}
bool scope_has_declaration = false;
if (is_top_level() && m_var_names.contains(identifier_group_name))
scope_has_declaration = true;