Debian Codegraph @

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

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots % -f shared-everything-threads
2
3 ;; `func` references.
4 (module
5 ;; Imported (long/short forms, mut, null).
6 (global (import "spectest" "global_funcref") (shared (shared funcref)))
7 (global (import "spectest" "global_mut_funcref") (shared mut (shared funcref)))
8 (global (import "spectest" "global_ref_null_func") (shared (ref null (shared func))))
9 (global (import "spectest" "global_mut_ref_null_func") (shared mut (ref null (shared func))))
10 (global (import "spectest" "global_ref_func") (shared (ref (shared func))))
11 (global (import "spectest" "global_mut_ref_func") (shared mut (ref (shared func))))
12
13 ;; Initialized (long/short form).
14 (global (shared (shared funcref)) (ref.null (shared func)))
15 (global (shared (ref null (shared func))) (ref.null (shared func)))
16 )
17
18 (assert_invalid
19 (module (global (shared funcref)))
20 "shared globals must have a shared value type")
21 (assert_invalid
22 (module (global (shared (ref null func))))
23 "shared globals must have a shared value type")
24 (assert_invalid
25 (module (global (ref (shared func))))
26 "type mismatch")
27
28 ;; `extern` references.
29 (module
30 ;; Imported (long/short forms, mut, null).
31 (global (import "spectest" "global_externref") (shared (shared externref)))
32 (global (import "spectest" "global_mut_externref") (shared mut (shared externref)))
33 (global (import "spectest" "global_ref_null_extern") (shared (ref null (shared extern))))
34 (global (import "spectest" "global_mut_ref_null_extern") (shared mut (ref null (shared extern))))
35 (global (import "spectest" "global_ref_extern") (shared (ref (shared extern))))
36 (global (import "spectest" "global_mut_ref_extern") (shared mut (ref (shared extern))))
37
38 ;; Initialized (long/short form).
39 (global (shared (shared externref)) (ref.null (shared extern)))
40 (global (shared (ref null (shared extern))) (ref.null (shared extern)))
41 )
42
43 (assert_invalid
44 (module (global (shared externref)))
45 "shared globals must have a shared value type")
46 (assert_invalid
47 (module (global (shared (ref null extern))))
48 "shared globals must have a shared value type")
49 (assert_invalid
50 (module (global (ref (shared extern))))
51 "type mismatch")
52
53 ;; `exn` references.
54 (module
55 ;; Imported (long/short forms, mut, null).
56 (global (import "spectest" "global_exnref") (shared (shared exnref)))
57 (global (import "spectest" "global_mut_exnref") (shared mut (shared exnref)))
58 (global (import "spectest" "global_ref_null_exn") (shared (ref null (shared exn))))
59 (global (import "spectest" "global_mut_ref_null_exn") (shared mut (ref null (shared exn))))
60 (global (import "spectest" "global_ref_exn") (shared (ref (shared exn))))
61 (global (import "spectest" "global_mut_ref_exn") (shared mut (ref (shared exn))))
62
63 ;; Initialized (long/short form).
64 (global (shared (shared exnref)) (ref.null (shared exn)))
65 (global (shared (ref null (shared exn))) (ref.null (shared exn)))
66 )
67
68 (assert_invalid
69 (module (global (shared exnref)))
70 "shared globals must have a shared value type")
71 (assert_invalid
72 (module (global (shared (ref null exn))))
73 "shared globals must have a shared value type")
74 (assert_invalid
75 (module (global (ref (shared exn))))
76 "type mismatch")
77
78 ;; `any` references.
79 (module
80 ;; Imported (long/short forms, mut, null).
81 (global (import "spectest" "global_anyref") (shared (shared anyref)))
82 (global (import "spectest" "global_mut_anyref") (shared mut (shared anyref)))
83 (global (import "spectest" "global_ref_null_any") (shared (ref null (shared any))))
84 (global (import "spectest" "global_mut_ref_null_any") (shared mut (ref null (shared any))))
85 (global (import "spectest" "global_ref_any") (shared (ref (shared any))))
86 (global (import "spectest" "global_mut_ref_any") (shared mut (ref (shared any))))
87
88 ;; Initialized (long/short form).
89 (global (shared (shared anyref)) (ref.null (shared any)))
90 (global (shared (ref null (shared any))) (ref.null (shared any)))
91 )
92
93 (assert_invalid
94 (module (global (shared anyref)))
95 "shared globals must have a shared value type")
96 (assert_invalid
97 (module (global (shared (ref null any))))
98 "shared globals must have a shared value type")
99 (assert_invalid
100 (module (global (ref (shared any))))
101 "type mismatch")
102
103 ;; `eq` references.
104 (module
105 ;; Imported (long/short forms, mut, null).
106 (global (import "spectest" "global_eqref") (shared (shared eqref)))
107 (global (import "spectest" "global_mut_eqref") (shared mut (shared eqref)))
108 (global (import "spectest" "global_ref_null_eq") (shared (ref null (shared eq))))
109 (global (import "spectest" "global_mut_ref_null_eq") (shared mut (ref null (shared eq))))
110 (global (import "spectest" "global_ref_eq") (shared (ref (shared eq))))
111 (global (import "spectest" "global_mut_ref_eq") (shared mut (ref (shared eq))))
112
113 ;; Initialized (long/short form).
114 (global (shared (shared eqref)) (ref.null (shared eq)))
115 (global (shared (ref null (shared eq))) (ref.null (shared eq)))
116 )
117
118 (assert_invalid
119 (module (global (shared eqref)))
120 "shared globals must have a shared value type")
121 (assert_invalid
122 (module (global (shared (ref null eq))))
123 "shared globals must have a shared value type")
124 (assert_invalid
125 (module (global (ref (shared eq))))
126 "type mismatch")
127
128 ;; `struct` references.
129 (module
130 ;; Imported (long/short forms, mut, null).
131 (global (import "spectest" "global_structref") (shared (shared structref)))
132 (global (import "spectest" "global_mut_structref") (shared mut (shared structref)))
133 (global (import "spectest" "global_ref_null_struct") (shared (ref null (shared struct))))
134 (global (import "spectest" "global_mut_ref_null_struct") (shared mut (ref null (shared struct))))
135 (global (import "spectest" "global_ref_struct") (shared (ref (shared struct))))
136 (global (import "spectest" "global_mut_ref_struct") (shared mut (ref (shared struct))))
137
138 ;; Initialized (long/short form).
139 (global (shared (shared structref)) (ref.null (shared struct)))
140 (global (shared (ref null (shared struct))) (ref.null (shared struct)))
141 )
142
143 (assert_invalid
144 (module (global (shared structref)))
145 "shared globals must have a shared value type")
146 (assert_invalid
147 (module (global (shared (ref null struct))))
148 "shared globals must have a shared value type")
149 (assert_invalid
150 (module (global (ref (shared struct))))
151 "type mismatch")
152
153 ;; `array` references.
154 (module
155 ;; Imported (long/short forms, mut, null).
156 (global (import "spectest" "global_arrayref") (shared (shared arrayref)))
157 (global (import "spectest" "global_mut_arrayref") (shared mut (shared arrayref)))
158 (global (import "spectest" "global_ref_null_array") (shared (ref null (shared array))))
159 (global (import "spectest" "global_mut_ref_null_array") (shared mut (ref null (shared array))))
160 (global (import "spectest" "global_ref_array") (shared (ref (shared array))))
161 (global (import "spectest" "global_mut_ref_array") (shared mut (ref (shared array))))
162
163 ;; Initialized (long/short form).
164 (global (shared (shared arrayref)) (ref.null (shared array)))
165 (global (shared (ref null (shared array))) (ref.null (shared array)))
166 )
167
168 (assert_invalid
169 (module (global (shared arrayref)))
170 "shared globals must have a shared value type")
171 (assert_invalid
172 (module (global (shared (ref null array))))
173 "shared globals must have a shared value type")
174 (assert_invalid
175 (module (global (ref (shared array))))
176 "type mismatch")
177
178 ;; `i31` references.
179 (module
180 ;; Imported (long/short forms, mut, null).
181 (global (import "spectest" "global_i31ref") (shared (shared i31ref)))
182 (global (import "spectest" "global_mut_i31ref") (shared mut (shared i31ref)))
183 (global (import "spectest" "global_ref_null_i31") (shared (ref null (shared i31))))
184 (global (import "spectest" "global_mut_ref_null_i31") (shared mut (ref null (shared i31))))
185 (global (import "spectest" "global_ref_i31") (shared (ref (shared i31))))
186 (global (import "spectest" "global_mut_ref_i31") (shared mut (ref (shared i31))))
187
188 ;; Initialized (long/short form).
189 (global (shared (shared i31ref)) (ref.null (shared i31)))
190 (global (shared (ref null (shared i31))) (ref.null (shared i31)))
191 )
192
193 (assert_invalid
194 (module (global (shared i31ref)))
195 "shared globals must have a shared value type")
196 (assert_invalid
197 (module (global (shared (ref null i31))))
198 "shared globals must have a shared value type")
199 (assert_invalid
200 (module (global (ref (shared i31))))
201 "type mismatch")
202
203 ;; `nofunc` references.
204 (module
205 ;; Imported (long/short forms, mut, null).
206 (global (import "spectest" "global_nullfuncref") (shared (shared nullfuncref)))
207 (global (import "spectest" "global_mut_nullfuncref") (shared mut (shared nullfuncref)))
208 (global (import "spectest" "global_ref_null_nofunc") (shared (ref null (shared nofunc))))
209 (global (import "spectest" "global_mut_ref_null_nofunc") (shared mut (ref null (shared nofunc))))
210 (global (import "spectest" "global_ref_nofunc") (shared (ref (shared nofunc))))
211 (global (import "spectest" "global_mut_ref_nofunc") (shared mut (ref (shared nofunc))))
212
213 ;; Initialized (long/short form).
214 (global (shared (shared nullfuncref)) (ref.null (shared nofunc)))
215 (global (shared (ref null (shared nofunc))) (ref.null (shared nofunc)))
216 )
217
218 (assert_invalid
219 (module (global (shared nullfuncref)))
220 "shared globals must have a shared value type")
221 (assert_invalid
222 (module (global (shared (ref null nofunc))))
223 "shared globals must have a shared value type")
224 (assert_invalid
225 (module (global (ref (shared nofunc))))
226 "type mismatch")
227
228 ;; `noextern` references.
229 (module
230 ;; Imported (long/short forms, mut, null).
231 (global (import "spectest" "global_nullexternref") (shared (shared nullexternref)))
232 (global (import "spectest" "global_mut_nullexternref") (shared mut (shared nullexternref)))
233 (global (import "spectest" "global_ref_null_noextern") (shared (ref null (shared noextern))))
234 (global (import "spectest" "global_mut_ref_null_noextern") (shared mut (ref null (shared noextern))))
235 (global (import "spectest" "global_ref_noextern") (shared (ref (shared noextern))))
236 (global (import "spectest" "global_mut_ref_noextern") (shared mut (ref (shared noextern))))
237
238 ;; Initialized (long/short form).
239 (global (shared (shared nullexternref)) (ref.null (shared noextern)))
240 (global (shared (ref null (shared noextern))) (ref.null (shared noextern)))
241 )
242
243 (assert_invalid
244 (module (global (shared nullexternref)))
245 "shared globals must have a shared value type")
246 (assert_invalid
247 (module (global (shared (ref null noextern))))
248 "shared globals must have a shared value type")
249 (assert_invalid
250 (module (global (ref (shared noextern))))
251 "type mismatch")
252
253 ;; `noexn` references.
254 (module
255 ;; Imported (long/short forms, mut, null).
256 (global (import "spectest" "global_nullexnref") (shared (shared nullexnref)))
257 (global (import "spectest" "global_mut_nullexnref") (shared mut (shared nullexnref)))
258 (global (import "spectest" "global_ref_null_noexn") (shared (ref null (shared noexn))))
259 (global (import "spectest" "global_mut_ref_null_noexn") (shared mut (ref null (shared noexn))))
260 (global (import "spectest" "global_ref_noexn") (shared (ref (shared noexn))))
261 (global (import "spectest" "global_mut_ref_noexn") (shared mut (ref (shared noexn))))
262
263 ;; Initialized (long/short form).
264 (global (shared (shared nullexnref)) (ref.null (shared noexn)))
265 (global (shared (ref null (shared noexn))) (ref.null (shared noexn)))
266 )
267
268 (assert_invalid
269 (module (global (shared nullexnref)))
270 "shared globals must have a shared value type")
271 (assert_invalid
272 (module (global (shared (ref null noexn))))
273 "shared globals must have a shared value type")
274 (assert_invalid
275 (module (global (ref (shared noexn))))
276 "type mismatch")
277
278 ;; `none` references.
279 (module
280 ;; Imported (long/short forms, mut, null).
281 (global (import "spectest" "global_nullref") (shared (shared nullref)))
282 (global (import "spectest" "global_mut_nullref") (shared mut (shared nullref)))
283 (global (import "spectest" "global_ref_null_none") (shared (ref null (shared none))))
284 (global (import "spectest" "global_mut_ref_null_none") (shared mut (ref null (shared none))))
285 (global (import "spectest" "global_ref_none") (shared (ref (shared none))))
286 (global (import "spectest" "global_mut_ref_none") (shared mut (ref (shared none))))
287
288 ;; Initialized (long/short form).
289 (global (shared (shared nullref)) (ref.null (shared none)))
290 (global (shared (ref null (shared none))) (ref.null (shared none)))
291 )
292
293 (assert_invalid
294 (module (global (shared nullref)))
295 "shared globals must have a shared value type")
296 (assert_invalid
297 (module (global (shared (ref null none))))
298 "shared globals must have a shared value type")
299 (assert_invalid
300 (module (global (ref (shared none))))
301 "type mismatch")
302
303 ;; Concrete `func` references.
304 (module
305 (type $t (shared (func)))
306
307 ;; Imported.
308 (global (import "spectest" "global_t") (shared (ref $t)))
309 (global (import "spectest" "global_mut_t") (shared mut (ref $t)))
310 (global (import "spectest" "global_null_t") (shared (ref null $t)))
311 (global (import "spectest" "global_mut_null_t") (shared mut (ref null $t)))
312
313 ;; Initialized.
314 (global (shared (ref null $t)) (ref.null $t))
315 (global (shared mut (ref null $t)) (ref.null $t))
316 )
317
318 (assert_invalid
319 (module
320 (type $t (func))
321 (global (shared (ref $t))))
322 "shared globals must have a shared value type")
323 (assert_invalid
324 (module
325 (type $t (shared (func)))
326 (global (ref $t)))
327 "type mismatch")
328 (assert_invalid
329 (module (type $t (shared (func (param funcref)))))
330 "shared composite type must contain shared types")
331
332 ;; Concrete `array` references.
333 (module
334 (type $t (shared (array i32)))
335
336 ;; Imported.
337 (global (import "spectest" "global_t") (shared (ref $t)))
338 (global (import "spectest" "global_mut_t") (shared mut (ref $t)))
339 (global (import "spectest" "global_null_t") (shared (ref null $t)))
340 (global (import "spectest" "global_mut_null_t") (shared mut (ref null $t)))
341
342 ;; Initialized.
343 (global (shared (ref null $t)) (ref.null $t))
344 (global (shared mut (ref null $t)) (ref.null $t))
345 )
346
347 (assert_invalid
348 (module
349 (type $t (array i32))
350 (global (shared (ref $t))))
351 "shared globals must have a shared value type")
352 (assert_invalid
353 (module
354 (type $t (shared (array i32)))
355 (global (ref $t)))
356 "type mismatch")
357 (assert_invalid
358 (module (type $t (shared (array funcref))))
359 "shared composite type must contain shared types")
360
361 ;; Concrete `struct` references.
362 (module
363 (type $t (shared (struct (field i32))))
364
365 ;; Imported.
366 (global (import "spectest" "global_t") (shared (ref $t)))
367 (global (import "spectest" "global_mut_t") (shared mut (ref $t)))
368 (global (import "spectest" "global_null_t") (shared (ref null $t)))
369 (global (import "spectest" "global_mut_null_t") (shared mut (ref null $t)))
370
371 ;; Initialized.
372 (global (shared (ref null $t)) (ref.null $t))
373 (global (shared mut (ref null $t)) (ref.null $t))
374 )
375
376 (assert_invalid
377 (module
378 (type $t (struct (field i32)))
379 (global (shared (ref $t))))
380 "shared globals must have a shared value type")
381 (assert_invalid
382 (module
383 (type $t (shared (struct (field i32))))
384 (global (ref $t)))
385 "type mismatch")
386 (assert_invalid
387 (module (type $t (shared (struct (field funcref)))))
388 "shared composite type must contain shared types")