Skip to content

[JSC] Spread call mixed with other arguments should not call operations when the callee is inlined - #80268

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/JSC-Spread-call-mixed-with-other-arguments-should-not-call-operations-when-the-callee-is-inlined
Nov 13, 2026
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
sosukesuzuki:eng/JSC-Spread-call-mixed-with-other-arguments-should-not-call-operations-when-the-callee-is-inlined

Conversation

@sosukesuzuki

@sosukesuzuki sosukesuzuki commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

33871e8

[JSC] Spread call mixed with other arguments should not call operations when the callee is inlined
https://bugs.webkit.org/show_bug.cgi?id=330851

Reviewed by Tadeu Zagallo.

325863@main removed the C++ calls from `f(...array)` when the callee is inlined, but `f(x, ...array)`
still has them. VarargsLengthWithSpread and LoadVarargsWithSpread store every operand to a scratch
buffer, flush the registers, and call an operation, so the call is slower than the one which is not
inlined, for which CallVarargsWithSpread builds the callee frame without calling operations.

Every spread operand is a JSCellButterfly which holds boxed values and has no holes, unless the FTL
eliminated it. VarargsLengthWithSpread now adds the lengths up, and LoadVarargsWithSpread stores the
operands directly to the frame. For the eliminated spreads, the FTL uses the code ForwardVarargs already
has for them. This makes the four operations unused, so this patch removes them.

                                                   Baseline                  Patched

spread-call-with-prefix-small-arrays-inlined
                                               97.9189+-6.9116     ^     56.1247+-1.8942        ^ definitely 1.7447x faster

Tests: JSTests/microbenchmarks/spread-call-with-prefix-small-arrays-inlined.js
       JSTests/stress/spread-call-with-prefix-inlined-callee-too-many-arguments.js
       JSTests/stress/spread-call-with-prefix-inlined-callee.js

* JSTests/microbenchmarks/spread-call-with-prefix-small-arrays-inlined.js: Added.
(listener):
(notify):
* JSTests/stress/spread-call-with-prefix-inlined-callee-too-many-arguments.js: Added.
(shouldBe):
(count):
(prefix):
(two):
(prefixAndCatch):
(rest):
* JSTests/stress/spread-call-with-prefix-inlined-callee.js: Added.
(shouldBe):
(all):
(last):
(const.receiver.method):
(prefix):
(suffix):
(both):
(two):
(interleaved):
(same):
(lastOfPrefix):
(lastOfSuffix):
(method):
(constants):
(constantPlainArguments):
(unboxedPlainArguments):
(constantDoublesAndMaterialized):
(restAndMaterialized):
(inlinedRestAndMaterialized):
(callInlinedRest0):
(callInlinedRest3):
(callInlinedRestVarargs):
(yieldBetweenSpreads):
(callYieldBetweenSpreads):
(generate):
(createArguments):
* Source/JavaScriptCore/dfg/DFGNode.h:
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
* Source/JavaScriptCore/dfg/DFGOperations.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileVarargsLengthWithSpread):
(JSC::DFG::SpeculativeJIT::compileLoadVarargsWithSpread):
(JSC::DFG::SpeculativeJIT::emitLoadVarargsFromContiguousStorage):
(JSC::DFG::SpeculativeJIT::emitFillMissingVarargsWithUndefined):
(JSC::DFG::SpeculativeJIT::emitCopyVarargs):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileVarargsLengthWithSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileLoadVarargsWithSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileForwardVarargsWithSpread):
(JSC::FTL::DFG::LowerDFGToB3::forwardSpread):
(JSC::FTL::DFG::LowerDFGToB3::copyVarargs):
(JSC::FTL::DFG::LowerDFGToB3::fillMissingVarargsWithUndefined):
(JSC::FTL::DFG::LowerDFGToB3::fillSpreadArgumentsBuffer): Deleted.

Canonical link: https://commits.webkit.org/326594@main

609f564

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
⏳ 🛠 ios-sim-cmake ✅ 🛠 mac-cmake-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ⏳ 🧪 ios-cmake-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
⏳ 🧪 ios-cmake-wk2-wpt ✅ 🧪 api-mac-cmake-debug ✅ 🧪 jsc-wpe
✅ 🧪 jsc-x86-64 ⏳ 🧪 api-ios-cmake ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 🧪 jsc-debug-arm64 ✅ 🛠 ios-safer-cpp ✅ 🧪 mac-cmake-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 gtk-wk2
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim ⏳ 🧪 mac-webdriver
✅ 🛠 watch
✅ 🛠 watch-sim

@sosukesuzuki sosukesuzuki self-assigned this Nov 10, 2026
@sosukesuzuki sosukesuzuki added the JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues. label Nov 10, 2026
@sosukesuzuki
sosukesuzuki force-pushed the eng/JSC-Spread-call-mixed-with-other-arguments-should-not-call-operations-when-the-callee-is-inlined branch from a96116a to 609f564 Compare November 10, 2026 04:09
@sosukesuzuki sosukesuzuki added the merge-queue Applied to send a pull request to merge-queue label Nov 13, 2026
…ns when the callee is inlined

https://bugs.webkit.org/show_bug.cgi?id=330851

Reviewed by Tadeu Zagallo.

325863@main removed the C++ calls from `f(...array)` when the callee is inlined, but `f(x, ...array)`
still has them. VarargsLengthWithSpread and LoadVarargsWithSpread store every operand to a scratch
buffer, flush the registers, and call an operation, so the call is slower than the one which is not
inlined, for which CallVarargsWithSpread builds the callee frame without calling operations.

Every spread operand is a JSCellButterfly which holds boxed values and has no holes, unless the FTL
eliminated it. VarargsLengthWithSpread now adds the lengths up, and LoadVarargsWithSpread stores the
operands directly to the frame. For the eliminated spreads, the FTL uses the code ForwardVarargs already
has for them. This makes the four operations unused, so this patch removes them.

                                                   Baseline                  Patched

spread-call-with-prefix-small-arrays-inlined
                                               97.9189+-6.9116     ^     56.1247+-1.8942        ^ definitely 1.7447x faster

Tests: JSTests/microbenchmarks/spread-call-with-prefix-small-arrays-inlined.js
       JSTests/stress/spread-call-with-prefix-inlined-callee-too-many-arguments.js
       JSTests/stress/spread-call-with-prefix-inlined-callee.js

* JSTests/microbenchmarks/spread-call-with-prefix-small-arrays-inlined.js: Added.
(listener):
(notify):
* JSTests/stress/spread-call-with-prefix-inlined-callee-too-many-arguments.js: Added.
(shouldBe):
(count):
(prefix):
(two):
(prefixAndCatch):
(rest):
* JSTests/stress/spread-call-with-prefix-inlined-callee.js: Added.
(shouldBe):
(all):
(last):
(const.receiver.method):
(prefix):
(suffix):
(both):
(two):
(interleaved):
(same):
(lastOfPrefix):
(lastOfSuffix):
(method):
(constants):
(constantPlainArguments):
(unboxedPlainArguments):
(constantDoublesAndMaterialized):
(restAndMaterialized):
(inlinedRestAndMaterialized):
(callInlinedRest0):
(callInlinedRest3):
(callInlinedRestVarargs):
(yieldBetweenSpreads):
(callYieldBetweenSpreads):
(generate):
(createArguments):
* Source/JavaScriptCore/dfg/DFGNode.h:
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
* Source/JavaScriptCore/dfg/DFGOperations.h:
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileVarargsLengthWithSpread):
(JSC::DFG::SpeculativeJIT::compileLoadVarargsWithSpread):
(JSC::DFG::SpeculativeJIT::emitLoadVarargsFromContiguousStorage):
(JSC::DFG::SpeculativeJIT::emitFillMissingVarargsWithUndefined):
(JSC::DFG::SpeculativeJIT::emitCopyVarargs):
* Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:
* Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileVarargsLengthWithSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileLoadVarargsWithSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileForwardVarargsWithSpread):
(JSC::FTL::DFG::LowerDFGToB3::forwardSpread):
(JSC::FTL::DFG::LowerDFGToB3::copyVarargs):
(JSC::FTL::DFG::LowerDFGToB3::fillMissingVarargsWithUndefined):
(JSC::FTL::DFG::LowerDFGToB3::fillSpreadArgumentsBuffer): Deleted.

Canonical link: https://commits.webkit.org/326594@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/JSC-Spread-call-mixed-with-other-arguments-should-not-call-operations-when-the-callee-is-inlined branch from 609f564 to 33871e8 Compare November 13, 2026 01:26
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 326594@main (33871e8): https://commits.webkit.org/326594@main

Reviewed commits have been landed. Closing PR #80268 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit 33871e8 into WebKit:main Nov 13, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JavaScriptCore For bugs in JavaScriptCore, the JS engine used by WebKit, other than kxmlcore issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants