summaryrefslogtreecommitdiff
path: root/test/lit/ctor-eval/shared-i31.wast
blob: fe79ce4129e7a2270282e287c252f452e374a754 (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
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-ctor-eval %s --ctors=test --kept-exports=test,other --quiet -all -S -o - | filecheck %s

;; We should be able to update `global` with a proper shared i31 reference.

(module
 ;; CHECK:      (type $0 (func (result (ref null (shared any)))))

 ;; CHECK:      (global $global (mut (ref null (shared i31))) (ref.i31_shared
 ;; CHECK-NEXT:  (i32.const 42)
 ;; CHECK-NEXT: ))
 (global $global (mut (ref null (shared i31))) (ref.null (shared none)))

 (func $test (export "test") (result (ref null (shared any)))
  (global.set $global
   (ref.i31_shared
    (i32.const 42)
   )
  )
  ;; Also externalizing and internalizing works: this code can be precomputed
  ;; and hence removed.
  (drop
   (any.convert_extern
    (extern.convert_any
     (global.get $global)
    )
   )
  )
  (global.get $global)
 )

 ;; CHECK:      (export "test" (func $test_2))

 ;; CHECK:      (export "other" (func $other))

 ;; CHECK:      (func $other (type $0) (result (ref null (shared any)))
 ;; CHECK-NEXT:  (global.get $global)
 ;; CHECK-NEXT: )
 (func $other (export "other") (result (ref null (shared any)))
  (global.get $global)
 )
)
;; CHECK:      (func $test_2 (type $0) (result (ref null (shared any)))
;; CHECK-NEXT:  (ref.i31_shared
;; CHECK-NEXT:   (i32.const 42)
;; CHECK-NEXT:  )
;; CHECK-NEXT: )