Debian Codegraph @

tests/cli/shared-everything-threads/funcs.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots % -f shared-everything-threads
2
3 ;; Check that shared functions are valid WAT.
4 (module
5 (type $f (shared (func)))
6 (func (import "spectest" "shared-func") (type $f))
7 (func (type $f))
8 )
9
10 ;; Check that unshared functions cannot be called from shared functions.
11 (assert_invalid
12 (module
13 (type $shared (shared (func)))
14 (type $unshared (func))
15 (func (type $shared)
16 call $unshared)
17 (func $unshared (type $unshared))
18 )
19 "shared functions cannot access unshared functions")
20
21 ;; Check that unshared globals cannot be accessed from shared functions.
22 (assert_invalid
23 (module
24 (global $unshared_global i32 (i32.const 0))
25 (type $shared_func (shared (func)))
26 (func (type $shared_func)
27 global.get $unshared_global
28 drop)
29 )
30 "shared functions cannot access unshared globals")
31
32 ;; Check that unshared tables cannot be accessed from shared functions.
33 (assert_invalid
34 (module
35 (table $unshared_table 1 anyref)
36 (type $shared_func (shared (func)))
37 (func (type $shared_func)
38 i32.const 0
39 table.get $unshared_table
40 drop)
41 )
42 "shared functions cannot access unshared tables")
43
44 ;; Check that unshared arrays cannot be accessed from shared functions.
45 (assert_invalid
46 (module
47 (type $unshared_array (array anyref))
48 (type $shared_func (shared (func)))
49 (func (type $shared_func)
50 (array.new $unshared_array (ref.null any) (i32.const 0))
51 (array.get $unshared_array (i32.const 0))
52 drop)
53 )
54 "shared functions cannot access unshared arrays")
55
56 ;; Check that unshared structs cannot be accessed from shared functions.
57 (assert_invalid
58 (module
59 (type $unshared_struct (struct (field i32)))
60 (type $shared_func (shared (func)))
61 (func (type $shared_func)
62 (struct.new $unshared_struct (i32.const 0))
63 (struct.get $unshared_struct 0)
64 drop)
65 )
66 "shared functions cannot access unshared structs")