[webkit-changes] [WebKit/WebKit] cacf00: Add fast path of getting arguments.length for LLIn...
Commit Queue
noreply at github.com
Tue Sep 26 14:10:42 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: cacf00c5fdeedd4db49495feaa674396691def67
https://github.com/WebKit/WebKit/commit/cacf00c5fdeedd4db49495feaa674396691def67
Author: Yijia Huang <yijia_huang at apple.com>
Date: 2023-09-26 (Tue, 26 Sep 2023)
Changed paths:
A JSTests/microbenchmarks/get-arguments-length-fast.js
A JSTests/stress/get-arguments-length-fast.js
M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
M Source/JavaScriptCore/parser/ASTBuilder.h
M Source/JavaScriptCore/parser/Nodes.h
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/Parser.h
M Source/JavaScriptCore/parser/SyntaxChecker.h
Log Message:
-----------
Add fast path of getting arguments.length for LLInt and Baseline
https://bugs.webkit.org/show_bug.cgi?id=261543
rdar://115462355
Reviewed by Yusuke Suzuki.
We observed that `arguments.length` is frequently used for reading only
without accessing/modifying arguments self or its other properties. If that's
the case we should directly get `argumentCountIncludingThis` from CallFrame
without materializing `arguments` object first. So far, DFG and FTL can
handle this well in varargs forwarding phase. This patch adds the fast
path of getting arguments.length for LLInt and Baseline with simple
heuristic in parser layer.
JavaScriptCode:
function test() {
return arguments.length === 3;
}
Bytecode Before:
Predecessors: [ ]
[ 0] enter
[ 1] create_direct_arguments dst:loc5
[ 3] mov dst:loc6, src:loc5
[ 6] get_by_id dst:loc7, base:loc6, property:0, valueProfile:1
[ 12] stricteq dst:loc7, lhs:loc7, rhs:Int32: 3(const0)
[ 16] ret value:loc7
Successors: [ ]
Bytecode After:
Predecessors: [ ]
[ 0] enter
[ 1] argument_count dst:loc5
[ 3] stricteq dst:loc5, lhs:loc5, rhs:Int32: 3(const0)
[ 7] ret value:loc5
Successors: [ ]
Micro Benchmark Result:
without with
get-arguments-length-fast 2.6024+-0.0750 ^ 2.4034+-0.0359 ^ definitely 1.0828x faster
* JSTests/microbenchmarks/get-arguments-length-fast.js: Added.
(test):
* JSTests/stress/get-arguments-length-fast.js: Added.
(shouldBe):
(argumentsWithNestedNormalFunction.nested):
(argumentsWithNestedNormalFunction):
(argumentsNonLengthAccess):
(argumentsLengthAssignment):
(argumentsAssignmentLHS):
(argumentsAssignmentRHS):
(argumentsDestructuringAssignment):
(declareVarArguments):
(declareVarArgumentsWithBlock):
(declareLexicalArguments):
(declareLexicalArgumentsWithBlock):
(declareArrowFunctionArguments):
(declareArrowFunctionArgumentsWithBlock):
(declareFunctionArguments.arguments):
(declareFunctionArguments):
(declareFunctionArgumentsWithBlock.arguments):
(declareFunctionArgumentsWithBlock):
(declareParameterArguments):
(returnArguments):
(helper):
(passArgumentsToFunctionCall):
(ifArguments):
(forInArguments):
(forInVarArguments):
(forInLetArguments):
(forOfArguments):
(forOfVarArguments):
(forOfLetArguments):
(withArguments):
(argumentsWithNestedFunctions.nestedNormalFunction):
(argumentsWithNestedFunctions):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::useGetArgumentsLengthFast):
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::DotAccessorNode::emitBytecode):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::createDotAccess):
(JSC::ASTBuilder::createAssignment):
(JSC::ASTBuilder::createAssignmentElement):
(JSC::ASTBuilder::checkAssignmentForArguments):
(JSC::ASTBuilder::useArgumentsOnlyForReadingLength):
(JSC::ASTBuilder::usesArguments):
* Source/JavaScriptCore/parser/Nodes.h:
(JSC::ExpressionNode::isArgumentsAccess const):
(JSC::ExpressionNode::isArgumentsLengthAccess const):
(JSC::ExpressionNode::isArguments const):
(JSC::ScopeNode::useGetArgumentsLengthFast const):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
* Source/JavaScriptCore/parser/Parser.h:
(JSC::Scope::hasDeclaredArguments const):
(JSC::Scope::setHasDeclaredArguments):
(JSC::Scope::declareCallee):
(JSC::Scope::declareVariable):
(JSC::Scope::declareFunction):
(JSC::Scope::declareLexicalVariable):
(JSC::Scope::addDeclaredVariable):
(JSC::Scope::addDeclareLexicalVariable):
(JSC::Scope::addDeclaredParameters):
(JSC::Scope::declareParameter):
(JSC::Scope::getSloppyModeHoistedFunctions):
(JSC::Scope::setReadArgumentsLengthOnly):
(JSC::Scope::useGetArgumentsLengthFast const):
(JSC::Parser::popScopeInternal):
* Source/JavaScriptCore/parser/ParserModes.h:
* Source/JavaScriptCore/parser/VariableEnvironment.h:
Canonical link: https://commits.webkit.org/268480@main
More information about the webkit-changes
mailing list