[webkit-changes] [WebKit/WebKit] 3e0dc2: [JSC] Do not declare callee name when it is functi...
Yusuke Suzuki
noreply at github.com
Wed Nov 1 17:41:45 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3e0dc21a287b581aa7645a438b07c3c38745cd51
https://github.com/WebKit/WebKit/commit/3e0dc21a287b581aa7645a438b07c3c38745cd51
Author: Yusuke Suzuki <ysuzuki at apple.com>
Date: 2023-11-01 (Wed, 01 Nov 2023)
Changed paths:
A JSTests/microbenchmarks/function-declaration-name.js
M Source/JavaScriptCore/API/JSScriptRef.cpp
M Source/JavaScriptCore/API/glib/JSCContext.cpp
M Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
M Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
M Source/JavaScriptCore/debugger/DebuggerParseData.cpp
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/Parser.h
M Source/JavaScriptCore/parser/ParserModes.h
M Source/JavaScriptCore/runtime/CodeCache.cpp
M Source/JavaScriptCore/runtime/Completion.cpp
M Source/JavaScriptCore/runtime/JSModuleLoader.cpp
Log Message:
-----------
[JSC] Do not declare callee name when it is function declaration
https://bugs.webkit.org/show_bug.cgi?id=264030
rdar://117786144
Reviewed by Alexey Shvayka.
We should declare callee only when it is not function declarations. Otherwise, we taint the scope with that,
and unnecessarily create a JSLexicalEnvironment when it gets captured.
function test(n) {
if (n) {
(function(n) {
test(n - 1);
}(n));
}
}
In the above code, if `test` function is function declaration, we should define `test` name in the upper scope
and we do not need to declare it inside the function.
We propagate FunctionMode in Parser and use it as the same way to BytecodeGenerator.
Microbenchmark shows improvement since we wipe JSLexicalEnvironment allocations.
ToT Patched
function-declaration-name 32.8020+-0.3279 ^ 27.4767+-0.2500 ^ definitely 1.1938x faster
* Source/JavaScriptCore/API/JSScriptRef.cpp:
(parseScript):
* Source/JavaScriptCore/API/glib/JSCContext.cpp:
(jsc_context_check_syntax):
* Source/JavaScriptCore/builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::generateUnlinkedFunctionCodeBlock):
* Source/JavaScriptCore/debugger/DebuggerParseData.cpp:
(JSC::gatherDebuggerParseData):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::Parser):
(JSC::Parser<LexerType>::parseInner):
* Source/JavaScriptCore/parser/Parser.h:
(JSC::Parser::functionMode const):
(JSC::parse):
(JSC::parseFunctionForFunctionConstructor):
* Source/JavaScriptCore/parser/ParserModes.h:
* Source/JavaScriptCore/runtime/CodeCache.cpp:
(JSC::generateUnlinkedCodeBlockImpl):
* Source/JavaScriptCore/runtime/Completion.cpp:
(JSC::checkSyntaxInternal):
(JSC::checkModuleSyntax):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
Canonical link: https://commits.webkit.org/270095@main
More information about the webkit-changes
mailing list