[JSC] `op_call_varargs_with_spread` new opcode
Component: JSC | c3b920b
JSTests/stress/varargs-spread-fusion-checkpoint-length-overflow.js
A mixed spread call like f(a, ...b, c) used to compile to op_new_array_with_spread, materializing a temporary array that op_call_varargs then copied into the callee frame (a bare f(...x) passes the spread butterfly straight through and never took this path). op_call_varargs is checkpointed: it can OSR-exit partway through, after computing the argument count but before populating the frame. The DFG's arguments-elimination phase can remove a NewArrayWithSpread by tracking each spread operand as forwarded rest parameters, a constant butterfly, or a materialized array.
The new bytecode takes the interleaved argv/argc plus a spread bitVector and builds the callee frame directly, keeping op_call_varargs' checkpoints. The DFG gains CallVarargsWithSpread, VarargsLengthWithSpread and LoadVarargsWithSpread, with FTL lowering and a new inline frame-setup fast path for small dense contiguous arrays; arguments elimination now handles each spread operand individually.
Before: After:
f(a, ...b, c) f(a, ...b, c)
└─► NewArrayWithSpread └─► CallVarargsWithSpread(argv, argc, bits)
└─► temp heap array ├─► size frame from operands (ckpt)
└─► CallVarargs └─► copy operands into callee frame
└─► copy into frame (inline: small dense contiguous)
Significance
The change removes a throwaway array allocation on mixed spread calls in LLInt, Baseline and DFG, where previously only the FTL eliminated it. It also reimplements varargs frame construction in every tier — historically one of JSC's most bug-prone areas.
Audit directions
The inline fast path copies butterfly slots verbatim into argument slots: check gating for indexing type (Int32/Contiguous vs Double/ArrayStorage), holes, length bounds and COW literal butterflies, and whether shape or length can change between check and copy via spread-operand side effects, getters, iterators or array mutation. For checkpoints, verify that bytecode liveness for tmpLivenessForCheckpoint, OSR availability analysis and handleVarargsWithSpreadCheckpoint agree on live tmps and operands, including the inlined-call exit path (callerReturnPC, llint_slow_path_checkpoint_osr_exit_from_inlined_call). Summing many operands and spread lengths can overflow argument count or frame size before the stack-limit check — the dedicated length-overflow test (1024 spreads of a shared COW butterfly reaching 2^32 arguments) shows this was already a concern. Wider: arguments elimination mixing eliminated and materialized spreads (varargsSpreadScratchBufferSize, varargsSpreadForwardDescriptors, length-pass vs load-pass consistency), and abstract-interpreter, clobberize, doesGC, mayExit and safeToExecute entries for the three new nodes — a wrong clobber set or GC flag leads to type confusion across the node. Also stress the bitVector encoding for calls with many operands (the tests exercise 10 to 20). Tell: a new DFG node whose clobberize entry is narrower than the operations its slow path can perform.