Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8d33a8ff591daa32c3d2f441d3cfd82197f296c1
https://github.com/WebKit/WebKit/commit/8d33a8ff591daa32c3d2f441d3cfd82197f296c1
Author: Sosuke Suzuki <[email protected]>
Date: 2026-08-12 (Wed, 12 Aug 2026)
Changed paths:
M Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
M Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
M Source/JavaScriptCore/runtime/CachedTypes.cpp
Log Message:
-----------
[JSC] Move `m_parentScopeTDZVariables` into `UnlinkedFunctionExecutable`
itself
https://bugs.webkit.org/show_bug.cgi?id=321497
Reviewed by Yusuke Suzuki.
210869@main moved m_parentScopeTDZVariables into
UnlinkedFunctionExecutable::RareData
because it was non-empty for only ~1% of executables at the time. That no
longer holds:
since 230994@main, BytecodeGenerator::getVariablesUnderTDZ() returns a non-null
TDZEnvironmentLink whenever the enclosing TDZ stack is non-empty, and in
let/const/class-heavy code most closures are created while some lexical binding
of an
enclosing scope is still in its TDZ (the binding being initialized in
`const f = () => ...`, the class name for every method of a named class, any
const/class
declared later in the scope). As a result the 80-byte RareData is malloc'ed for
a large
fraction of the 96-byte executables just to hold this one pointer.
This patch stores m_parentScopeTDZVariables in the cell again without growing
it. The 8
bytes come from m_name/m_ecmaName: FunctionMetadataNode::ecmaName() is ident()
whenever
ident() is non-null, so the two Identifiers only differ for anonymous
functions. Keep a
single m_ecmaName plus an m_hasName bit, which fits in the existing bit-field
padding, and
make name() return vm().propertyNames->nullIdentifier (what the parser already
uses as the
ident of anonymous functions) when the bit is unset.
sizeof(UnlinkedFunctionExecutable)
stays at 96 bytes and RareData goes back to being rare (class constructors,
private name
environments, generator/async body wrapper parameter names, source URL
directives).
RareData allocations, counted at
UnlinkedFunctionExecutable::ensureRareDataSlow():
non-builtin RareData
executables before after
typescript.js 5.9 load + transpileModule 15979 5553 49
JetStream2 chai-wtb 13544 4149 197
JetStream2 prepack-wtb 13622 4061 197
JetStream2 uglify-js-wtb 13434 4061 197
JetStream2 coffeescript-wtb 13192 3817 197
JetStream2 acorn-wtb 13078 3702 197
JetStream2 WSL 2197 1476 136
JetStream2 pdfjs 986 897 17
JetStream2 ML 564 543 30
JetStream2 Air 386 333 30
JetStream2 Babylon 397 376 28
JetStream2 FlightPlanner 223 191 37
JetStream2 Basic 228 162 32
JetStream2 UniPoker 135 111 21
JetStream2 async-fs 138 110 27
JetStream2 driver only (cdjs, gbemu, ...) ~170 88 17
JetStream2 scores are neutral. Per-benchmark Score, patched/baseline over 8
alternating
runs of cli.js: acorn-wtb 1.003, babylon-wtb 1.010, chai-wtb 0.994,
coffeescript-wtb
0.999, espree-wtb 1.006, jshint-wtb 1.002, lebab-wtb 0.994, prepack-wtb 1.000,
uglify-js-wtb 1.006, typescript 1.001, pdfjs 0.997, first-inspector-code-load
1.012,
multi-inspector-code-load 1.037, WSL 1.035, Air 0.991, ML 1.053, Basic 0.997,
async-fs 1.028, UniPoker 1.028; all within the run-to-run confidence intervals.
* Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
(JSC::UnlinkedFunctionExecutable::name const):
* Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h:
* Source/JavaScriptCore/runtime/CachedTypes.cpp:
(JSC::CachedFunctionExecutableRareData::encode):
(JSC::CachedFunctionExecutableRareData::decode const):
(JSC::CachedFunctionExecutable::hasName const):
(JSC::CachedFunctionExecutable::parentScopeTDZVariables const):
(JSC::CachedFunctionExecutable::encode):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
(JSC::CachedFunctionExecutable::name const): Deleted.
Canonical link: https://commits.webkit.org/319021@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications