Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: df289ce5519a13955bd806c44904ce32cca6bcd9
https://github.com/WebKit/WebKit/commit/df289ce5519a13955bd806c44904ce32cca6bcd9
Author: Sosuke Suzuki <[email protected]>
Date: 2026-08-29 (Sat, 29 Aug 2026)
Changed paths:
A JSTests/modules/module-function-declaration-executable-reuse-jettison.js
A JSTests/modules/module-function-declaration-executable-reuse-jettison/a.js
A JSTests/modules/module-function-declaration-executable-reuse.js
A JSTests/modules/module-function-declaration-executable-reuse/a.js
A JSTests/modules/module-function-declaration-executable-reuse/b.js
A JSTests/modules/module-function-declaration-executable-reuse/same-1.js
A JSTests/modules/module-function-declaration-executable-reuse/same-2.js
A
JSTests/modules/module-function-declaration-executable-reuse/same-setter.js
M Source/JavaScriptCore/bytecode/CodeBlock.cpp
Log Message:
-----------
[JSC] Reuse `FunctionExecutables` instantiated for module function
declarations
https://bugs.webkit.org/show_bug.cgi?id=322887
Reviewed by Yusuke Suzuki.
Module-scoped function declarations are instantiated when the module is
linked: CyclicModuleRecord::initializeEnvironment links each
UnlinkedFunctionExecutable into a FunctionExecutable, wraps it in a
JSFunction and stores it in the module environment. When the module is
later evaluated, CodeBlock::finishCreation links every functionDecl of
the module program again and keeps the second FunctionExecutable in
m_functionDecls, even though no op_new_func in the module body ever
reads it. Every heap-allocated function declaration in a module thus
costs two FunctionExecutables, one of which is dead on arrival.
When linking a ModuleCode CodeBlock, look the declaration up in the
module environment first. If the slot still holds a JSFunction whose
executable was linked from the same UnlinkedFunctionExecutable for this
module, reuse that executable; otherwise (stack-allocated declarations,
block-scoped declarations that shadow a module-level name, bindings
reassigned before evaluation) link a new one as before.
Loading 1000 synthetic modules with 17 module-scoped function
declarations each, a heap snapshot after evaluation shows
FunctionExecutable 47,060 -> 30,060 (6.02 MB -> 3.85 MB), and the
number of FunctionExecutables sharing an UnlinkedFunctionExecutable
drops from 17,000 to 0. Peak RSS goes from 92.0 MB to 89.9 MB, and
parse + link + evaluate time for the same modules did not change
(92-97 ms before, 92-95 ms after).
Tests: JSTests/modules/module-function-declaration-executable-reuse-jettison.js
JSTests/modules/module-function-declaration-executable-reuse-jettison/a.js
JSTests/modules/module-function-declaration-executable-reuse.js
JSTests/modules/module-function-declaration-executable-reuse/a.js
JSTests/modules/module-function-declaration-executable-reuse/b.js
JSTests/modules/module-function-declaration-executable-reuse/same-1.js
JSTests/modules/module-function-declaration-executable-reuse/same-2.js
JSTests/modules/module-function-declaration-executable-reuse/same-setter.js
* JSTests/modules/module-function-declaration-executable-reuse-jettison.js:
Added.
* JSTests/modules/module-function-declaration-executable-reuse-jettison/a.js:
Added.
(export.f):
(export.g):
(export.h):
(s):
(h):
(Promise.resolve.then):
(f):
* JSTests/modules/module-function-declaration-executable-reuse.js: Added.
* JSTests/modules/module-function-declaration-executable-reuse/a.js: Added.
(export.f):
(export.g):
(export.h):
(export.k):
(export.setG):
(export.setH):
(export.setK):
(export.gen):
(export.async asyncFn):
(export.async asyncGen):
(captured):
(export.callCaptured):
(local):
(f):
* JSTests/modules/module-function-declaration-executable-reuse/b.js: Added.
(setG):
* JSTests/modules/module-function-declaration-executable-reuse/same-1.js: Added.
(export.f):
(export.setF):
* JSTests/modules/module-function-declaration-executable-reuse/same-2.js: Added.
(export.f):
(export.setF):
* JSTests/modules/module-function-declaration-executable-reuse/same-setter.js:
Added.
* Source/JavaScriptCore/bytecode/CodeBlock.cpp:
(JSC::instantiatedModuleFunctionExecutable):
(JSC::CodeBlock::finishCreation):
Canonical link: https://commits.webkit.org/320111@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications