← All reports

[JSC] BBQ `emitShuffle` v128 stack-move fix

Component: JSC Wasm | f980730

JSTests/wasm/stress/bbq-tail-call-stack-shuffle-cycle.js

+//@ requireOptions("--useWasmSIMD=1", "--useWasmTailCalls=1")
+//@ skip if !$isSIMDPlatform
...
+const overlappingVectors = {
+ params: "i64 i64 i64 i64 i64 i64 i64 i64 v128 v128 v128 v128 v128 v128 v128 v128 i64 v128 v128 v128 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64",
+ calleeBody: `
+ local.get 16
+ i64.const 100
+ i64.mul
+ local.get 17
+ i64x2.extract_lane 0
+ i64.add
...
+ expected: 9010203n,
+};

BBQ is JSC's baseline wasm JIT tier. At a return_call it rebuilds the outgoing argument area in the space the current frame occupies, and emitShuffle implements this as a parallel move that orders moves so no source is overwritten before it's read, breaking cycles through a single scratch register. That only works if each slot overlaps at most one pending destination — but a 16-byte v128 slot spans two 8-byte slots, and when the callee has more parameters the frame extends so parameters shift over the caller's locals.

  FP off  -80  -78  -70  -68  -60  -58  -50  -48  -40
  locals  [   $v3  ][   $v2  ][   $v1  ][   $v0  ]
  params  [p16][   p17  ][   p18  ][   p19  ][p20]
  p17 covers both $v3 and $v2, both still pending
    => 2 scratch regs needed; recursively N moves => N regs
  Fix: v128 stack->stack : split into two 64-bit moves
       v128 stack->reg   : spill src to non-conflicting space first

The fix splits v128 stack-to-stack moves into two 64-bit moves and spills a v128 source before a register destination, only when analysis finds a v128 source under two pending destinations; it mirrors what OMG already does.

Without the split, a SIMD return_call with an attacker-chosen signature could clobber stack values or fp registers during the frame shuffle. That is a miscompilation primitive in the argument area that could corrupt a parameter, a local or saved frame state.

Narrow: check whether the new needs-split analysis is complete — other mixed-size overlaps (v128 against i32/f32 slots) and other sources that can lie under two destinations — and where the register-destination spill space is allocated, in case the spill lands on a pending source or destination. Check whether callee-saved or reserved slots (return address, saved FP) are reachable by the extended-frame layout. Wider: other emitShuffle callers — call/return and block-branch shuffles — that may rely on the same one-scratch assumption, and large-parameter-count tail calls with mixed i64/v128 signatures. Tiers that should agree on layout (OMG and BBQ) are a natural differential-fuzzing target. Tell: a parallel-move resolver with a single scratch register and mixed-width operands.