Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7ef470855921ed52f4a67f07e1b89dd664d1d060
https://github.com/WebKit/WebKit/commit/7ef470855921ed52f4a67f07e1b89dd664d1d060
Author: Vassili Bykov <[email protected]>
Date: 2026-08-20 (Thu, 20 Aug 2026)
Changed paths:
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/Parser.h
M Source/JavaScriptCore/parser/SourceProviderCacheItem.h
Log Message:
-----------
[JSC] Stop computing free variables twice when popping a function scope
https://bugs.webkit.org/show_bug.cgi?id=322157
rdar://185383752
Reviewed by Yusuke Suzuki.
When Parser::parseFunctionInfo creates a record for the function in source
provider cache,
the fillParametersForSourceProviderCache function computes the list of the
function's
free variables to save it in the cache. Then, when the function scope is popped,
popScopeInternal calls collectFreeVariables, which effectively computes the
same list
again by iterating over the used variables while skipping the declared and
lexical ones.
This patch makes it so that if the list was computed for the source provider
cache,
the list is given to popScope. collectFreeVariables then avoids repeating the
same work.
Conceptually, the information fed to popScope and eventually to
collectFreeVariables
is a std::optional<std::span>. However, it is passed down that call chain as two
separate parameters, a bool and a span. That is because a bool + span parameter
pair is passed in registers, unlike an optional<span>, and this code is hot
enough
that it makes a difference.
Additionally, collectFreeVariables is renamed to collectFreeVariablesFrom to
better communicate which way the collecting goes.
Covered by existing tests.
Canonical link: https://commits.webkit.org/319535@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications