diff options
Diffstat (limited to 'js/src/jit-test/tests/wasm/gc/bug-1879096.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/gc/bug-1879096.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/gc/bug-1879096.js b/js/src/jit-test/tests/wasm/gc/bug-1879096.js new file mode 100644 index 0000000000..e71d2bac27 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/bug-1879096.js @@ -0,0 +1,65 @@ +// |jit-test| test-also=--setpref=wasm_test_serialization; skip-if: !wasmGcEnabled() + +// Conditional branch instructions need to rewrite their stack types according +// to the destination label types. This loses information but is mandated by +// the spec. + +// br_if +wasmFailValidateText(`(module + (func (result anyref) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + i32.const 0 ;; stack: [arrayref structref i32] + br_if 0 ;; stack: [arrayref anyref] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); + +// br_on_null +wasmFailValidateText(`(module + (func (param externref) (result anyref) + ref.null array ;; stack: [arrayref] + local.get 0 ;; stack: [arrayref externref] + br_on_null 0 ;; stack: [anyref (ref extern)] + drop ;; stack: [anyref] + array.len ;; should fail + unreachable + ) +)`, /type mismatch: expression has type anyref but expected arrayref/); + +// br_on_non_null +wasmFailValidateText(`(module + (func (param externref) (result anyref (ref extern)) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + local.get 0 ;; stack: [arrayref structref externref] + br_on_non_null 0 ;; stack: [arrayref anyref] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); + +// br_on_cast +wasmFailValidateText(`(module + (type $s (struct)) + (func (result anyref (ref $s)) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + br_on_cast 0 structref (ref $s) ;; stack: [anyref structref] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); + +// br_on_cast_fail +wasmFailValidateText(`(module + (type $s (struct)) + (func (result anyref anyref) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + br_on_cast_fail 0 structref (ref $s) ;; stack: [anyref (ref $s)] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); |