← All issues

Relaxed Wasm SIMD implementation

85da494

Source/JavaScriptCore/wasm/WasmSIMDOpcodes.h

+macro(RelaxedMin, relaxed_min, ...)
+macro(RelaxedMax, relaxed_max, ...)
+macro(RelaxedQ15Mulr, relaxed_q15mulr_s, ...)
+macro(RelaxedDotI8x16I7x16, relaxed_dot_i8x16_i7x16_s, ...)
+macro(RelaxedDotI8x16I7x16Add, relaxed_dot_i8x16_i7x16_add_s, ...)

JSTests/wasm/stress/simd-const-relaxed-f32-madd.js

-//@ requireOptions("--useWasmSIMD=1", "--useWasmRelaxedSIMD=1", "--useWasmIPIntSIMD=0")
+//@ requireOptions("--useWasmSIMD=1", "--useWasmRelaxedSIMD=1")
-//@ $skipModes << "wasm-no-jit".to_sym
-//@ $skipModes << "wasm-no-wasm-jit".to_sym
-// FIXME: IPInt 지원이 구현되면 --useWasmIPIntSIMD=0 옵션을 제거하고 no-jit skip을 해제할 것

JSC는 계층형 파이프라인을 통해 Wasm을 컴파일합니다. IPInt는 바이트코드를 직접 해석하고, BBQ는 최적화되지 않은 빠른 머신 코드를 생성하며, OMG는 B3 기반의 완전한 최적화 컴파일러를 실행합니다. Relaxed SIMD는 지정된 범위 안에서 구현 정의 동작(implementation-defined behavior)을 의도적으로 허용하는 Wasm 제안입니다. relaxed_min이나 lane_select 같은 연산은 하드웨어 명령어에 따라 결과가 달라질 수 있습니다.

이 commit은 x64와 ARM64 모두에서 세 계층 전체에 걸쳐 relaxed Wasm SIMD를 구현합니다. 새로 추가된 연산은 dot product 변형(i16x8.relaxed_dot_i8x16_i7x16_s, i32x4.relaxed_dot_i8x16_i7x16_add_s), relaxed min/max, Q15 multiply-rounding입니다. FMA와 truncation 연산은 이미 존재하고 있었지만 --useWasmIPIntSIMD=0 플래그와 no-jit skip flag 뒤에 가려져 있었는데, 이 commit에서 해당 제약이 제거되었습니다.

Wasm relaxed SIMD opcode
        │
        ▼
  FunctionParser.h (decode)
        │
   ┌────┴────────────────┐
   │                     │
   ▼                     ▼
IPInt                  BBQ / OMG
(InPlaceInterpreter    (WasmBBQJIT64.cpp /
 .asm)                  WasmOMGIRGenerator.cpp)
                              │
                         B3 SIMDValue
                         (new opcodes)
                              │
                         B3LowerToAir
                              │
                         Air opcodes
                              │
                    MacroAssembler layer
                  (ARM64 / x86_64 SIMD insns)

네 개의 새로운 SIMD 연산 계열이 추가되었으며, 각각 세 개의 독립적인 계층 구현을 갖습니다. 새로운 B3 IR opcode, Air opcode, assembler primitive도 포함됩니다. 한편 relaxed SIMD 명세의 의도적인 non-determinism은 버그가 드러나지 않도록 은폐하는 구조를 만들어냅니다. 잘못된 결과도 명세상으로는 "within spec"으로 처리될 수 있기 때문입니다.

🔒

New multi-tier SIMD paths and a CPU feature-gated fallback — several edge cases across tiers warrant close investigation.

더 확인하려면 구독해 주세요