summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/gc/bug-1879096.js
blob: e71d2bac2772b51275242c33f0c8628f7ab11adb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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/);