b0e56dc7f5733f40c76a70b4bc615860f1b3bb4f
[platform/framework/web/lwnode.git] /
1 ;; Functions
2
3 (module $Mf
4   (func (export "call") (result i32) (call $g))
5   (func $g (result i32) (i32.const 2))
6 )
7 (register "Mf" $Mf)
8
9 (module $Nf
10   (func $f (import "Mf" "call") (result i32))
11   (export "Mf.call" (func $f))
12   (func (export "call Mf.call") (result i32) (call $f))
13   (func (export "call") (result i32) (call $g))
14   (func $g (result i32) (i32.const 3))
15 )
16
17 (assert_return (invoke $Mf "call") (i32.const 2))
18 (assert_return (invoke $Nf "Mf.call") (i32.const 2))
19 (assert_return (invoke $Nf "call") (i32.const 3))
20 (assert_return (invoke $Nf "call Mf.call") (i32.const 2))
21
22 (module
23   (import "spectest" "print_i32" (func $f (param i32)))
24   (export "print" (func $f))
25 )
26 (register "reexport_f")
27 (assert_unlinkable
28   (module (import "reexport_f" "print" (func (param i64))))
29   "incompatible import type"
30 )
31 (assert_unlinkable
32   (module (import "reexport_f" "print" (func (param i32) (result i32))))
33   "incompatible import type"
34 )
35
36
37 ;; Globals
38
39 (module $Mg
40   (global $glob (export "glob") i32 (i32.const 42))
41   (func (export "get") (result i32) (global.get $glob))
42
43   ;; export mutable globals
44   (global $mut_glob (export "mut_glob") (mut i32) (i32.const 142))
45   (func (export "get_mut") (result i32) (global.get $mut_glob))
46   (func (export "set_mut") (param i32) (global.set $mut_glob (local.get 0)))
47 )
48 (register "Mg" $Mg)
49
50 (module $Ng
51   (global $x (import "Mg" "glob") i32)
52   (global $mut_glob (import "Mg" "mut_glob") (mut i32))
53   (func $f (import "Mg" "get") (result i32))
54   (func $get_mut (import "Mg" "get_mut") (result i32))
55   (func $set_mut (import "Mg" "set_mut") (param i32))
56
57   (export "Mg.glob" (global $x))
58   (export "Mg.get" (func $f))
59   (global $glob (export "glob") i32 (i32.const 43))
60   (func (export "get") (result i32) (global.get $glob))
61
62   (export "Mg.mut_glob" (global $mut_glob))
63   (export "Mg.get_mut" (func $get_mut))
64   (export "Mg.set_mut" (func $set_mut))
65 )
66
67 (assert_return (get $Mg "glob") (i32.const 42))
68 (assert_return (get $Ng "Mg.glob") (i32.const 42))
69 (assert_return (get $Ng "glob") (i32.const 43))
70 (assert_return (invoke $Mg "get") (i32.const 42))
71 (assert_return (invoke $Ng "Mg.get") (i32.const 42))
72 (assert_return (invoke $Ng "get") (i32.const 43))
73
74 (assert_return (get $Mg "mut_glob") (i32.const 142))
75 (assert_return (get $Ng "Mg.mut_glob") (i32.const 142))
76 (assert_return (invoke $Mg "get_mut") (i32.const 142))
77 (assert_return (invoke $Ng "Mg.get_mut") (i32.const 142))
78
79 (assert_return (invoke $Mg "set_mut" (i32.const 241)))
80 (assert_return (get $Mg "mut_glob") (i32.const 241))
81 (assert_return (get $Ng "Mg.mut_glob") (i32.const 241))
82 (assert_return (invoke $Mg "get_mut") (i32.const 241))
83 (assert_return (invoke $Ng "Mg.get_mut") (i32.const 241))
84
85
86 (assert_unlinkable
87   (module (import "Mg" "mut_glob" (global i32)))
88   "incompatible import type"
89 )
90 (assert_unlinkable
91   (module (import "Mg" "glob" (global (mut i32))))
92   "incompatible import type"
93 )
94
95
96 (module $Mref_ex
97   (type $t (func))
98   (func $f) (elem declare func $f)
99   (global (export "g-const-funcnull") (ref null func) (ref.null func))
100   (global (export "g-const-func") (ref func) (ref.func $f))
101   (global (export "g-const-refnull") (ref null $t) (ref.null $t))
102   (global (export "g-const-ref") (ref $t) (ref.func $f))
103   (global (export "g-const-extern") externref (ref.null extern))
104   (global (export "g-var-funcnull") (mut (ref null func)) (ref.null func))
105   (global (export "g-var-func") (mut (ref func)) (ref.func $f))
106   (global (export "g-var-refnull") (mut (ref null $t)) (ref.null $t))
107   (global (export "g-var-ref") (mut (ref $t)) (ref.func $f))
108   (global (export "g-var-extern") (mut externref) (ref.null extern))
109 )
110 (register "Mref_ex" $Mref_ex)
111
112 (module $Mref_im
113   (type $t (func))
114   (global (import "Mref_ex" "g-const-funcnull") (ref null func))
115   (global (import "Mref_ex" "g-const-func") (ref null func))
116   (global (import "Mref_ex" "g-const-refnull") (ref null func))
117   (global (import "Mref_ex" "g-const-ref") (ref null func))
118   (global (import "Mref_ex" "g-const-func") (ref func))
119   (global (import "Mref_ex" "g-const-ref") (ref func))
120   (global (import "Mref_ex" "g-const-refnull") (ref null $t))
121   (global (import "Mref_ex" "g-const-ref") (ref null $t))
122   (global (import "Mref_ex" "g-const-ref") (ref $t))
123   (global (import "Mref_ex" "g-const-extern") externref)
124
125   (global (import "Mref_ex" "g-var-funcnull") (mut (ref null func)))
126   (global (import "Mref_ex" "g-var-func") (mut (ref func)))
127   (global (import "Mref_ex" "g-var-refnull") (mut (ref null $t)))
128   (global (import "Mref_ex" "g-var-ref") (mut (ref $t)))
129   (global (import "Mref_ex" "g-var-extern") (mut externref))
130 )
131
132 (assert_unlinkable
133   (module (global (import "Mref_ex" "g-const-extern") (ref null func)))
134   "incompatible import type"
135 )
136
137 (assert_unlinkable
138   (module (type $t (func)) (global (import "Mref_ex" "g-const-funcnull") (ref func)))
139   "incompatible import type"
140 )
141 (assert_unlinkable
142   (module (type $t (func)) (global (import "Mref_ex" "g-const-refnull") (ref func)))
143   "incompatible import type"
144 )
145 (assert_unlinkable
146   (module (type $t (func)) (global (import "Mref_ex" "g-const-extern") (ref func)))
147   "incompatible import type"
148 )
149
150 (assert_unlinkable
151   (module (type $t (func)) (global (import "Mref_ex" "g-const-funcnull") (ref null $t)))
152   "incompatible import type"
153 )
154 (assert_unlinkable
155   (module (type $t (func)) (global (import "Mref_ex" "g-const-func") (ref null $t)))
156   "incompatible import type"
157 )
158 (assert_unlinkable
159   (module (type $t (func)) (global (import "Mref_ex" "g-const-extern") (ref null $t)))
160   "incompatible import type"
161 )
162
163 (assert_unlinkable
164   (module (type $t (func)) (global (import "Mref_ex" "g-const-funcnull") (ref $t)))
165   "incompatible import type"
166 )
167 (assert_unlinkable
168   (module (type $t (func)) (global (import "Mref_ex" "g-const-func") (ref $t)))
169   "incompatible import type"
170 )
171 (assert_unlinkable
172   (module (type $t (func)) (global (import "Mref_ex" "g-const-refnull") (ref $t)))
173   "incompatible import type"
174 )
175 (assert_unlinkable
176   (module (type $t (func)) (global (import "Mref_ex" "g-const-extern") (ref $t)))
177   "incompatible import type"
178 )
179
180 (assert_unlinkable
181   (module (global (import "Mref_ex" "g-const-funcnull") externref))
182   "incompatible import type"
183 )
184 (assert_unlinkable
185   (module (global (import "Mref_ex" "g-const-func") externref))
186   "incompatible import type"
187 )
188 (assert_unlinkable
189   (module (global (import "Mref_ex" "g-const-refnull") externref))
190   "incompatible import type"
191 )
192 (assert_unlinkable
193   (module (global (import "Mref_ex" "g-const-ref") externref))
194   "incompatible import type"
195 )
196
197
198 (assert_unlinkable
199   (module (global (import "Mref_ex" "g-var-func") (mut (ref null func))))
200   "incompatible import type"
201 )
202 (assert_unlinkable
203   (module (global (import "Mref_ex" "g-var-refnull") (mut (ref null func))))
204   "incompatible import type"
205 )
206 (assert_unlinkable
207   (module (global (import "Mref_ex" "g-var-ref") (mut (ref null func))))
208   "incompatible import type"
209 )
210 (assert_unlinkable
211   (module (global (import "Mref_ex" "g-var-extern") (mut (ref null func))))
212   "incompatible import type"
213 )
214
215 (assert_unlinkable
216   (module (global (import "Mref_ex" "g-var-funcnull") (mut (ref func))))
217   "incompatible import type"
218 )
219 (assert_unlinkable
220   (module (global (import "Mref_ex" "g-var-refnull") (mut (ref func))))
221   "incompatible import type"
222 )
223 (assert_unlinkable
224   (module (global (import "Mref_ex" "g-var-ref") (mut (ref func))))
225   "incompatible import type"
226 )
227 (assert_unlinkable
228   (module (global (import "Mref_ex" "g-var-extern") (mut (ref func))))
229   "incompatible import type"
230 )
231
232 (assert_unlinkable
233   (module (type $t (func)) (global (import "Mref_ex" "g-var-funcnull") (mut (ref null $t))))
234   "incompatible import type"
235 )
236 (assert_unlinkable
237   (module (type $t (func)) (global (import "Mref_ex" "g-var-func") (mut (ref null $t))))
238   "incompatible import type"
239 )
240 (assert_unlinkable
241   (module (type $t (func)) (global (import "Mref_ex" "g-var-ref") (mut (ref null $t))))
242   "incompatible import type"
243 )
244 (assert_unlinkable
245   (module (type $t (func)) (global (import "Mref_ex" "g-var-extern") (mut (ref null $t))))
246   "incompatible import type"
247 )
248
249 (assert_unlinkable
250   (module (type $t (func)) (global (import "Mref_ex" "g-var-funcnull") (mut (ref $t))))
251   "incompatible import type"
252 )
253 (assert_unlinkable
254   (module (type $t (func)) (global (import "Mref_ex" "g-var-func") (mut (ref $t))))
255   "incompatible import type"
256 )
257 (assert_unlinkable
258   (module (type $t (func)) (global (import "Mref_ex" "g-var-refnull") (mut (ref $t))))
259   "incompatible import type"
260 )
261 (assert_unlinkable
262   (module (type $t (func)) (global (import "Mref_ex" "g-var-extern") (mut (ref $t))))
263   "incompatible import type"
264 )
265
266 (assert_unlinkable
267   (module (global (import "Mref_ex" "g-var-funcnull") (mut externref)))
268   "incompatible import type"
269 )
270 (assert_unlinkable
271   (module (global (import "Mref_ex" "g-var-func") (mut externref)))
272   "incompatible import type"
273 )
274 (assert_unlinkable
275   (module (global (import "Mref_ex" "g-var-refnull") (mut externref)))
276   "incompatible import type"
277 )
278 (assert_unlinkable
279   (module (global (import "Mref_ex" "g-var-ref") (mut externref)))
280   "incompatible import type"
281 )
282
283
284 ;; Tables
285
286 (module $Mt
287   (type (func (result i32)))
288   (type (func))
289
290   (table (export "tab") 10 funcref)
291   (elem (i32.const 2) $g $g $g $g)
292   (func $g (result i32) (i32.const 4))
293   (func (export "h") (result i32) (i32.const -4))
294
295   (func (export "call") (param i32) (result i32)
296     (call_indirect (type 0) (local.get 0))
297   )
298 )
299 (register "Mt" $Mt)
300
301 (module $Nt
302   (type (func))
303   (type (func (result i32)))
304
305   (func $f (import "Mt" "call") (param i32) (result i32))
306   (func $h (import "Mt" "h") (result i32))
307
308   (table funcref (elem $g $g $g $h $f))
309   (func $g (result i32) (i32.const 5))
310
311   (export "Mt.call" (func $f))
312   (func (export "call Mt.call") (param i32) (result i32)
313     (call $f (local.get 0))
314   )
315   (func (export "call") (param i32) (result i32)
316     (call_indirect (type 1) (local.get 0))
317   )
318 )
319
320 (assert_return (invoke $Mt "call" (i32.const 2)) (i32.const 4))
321 (assert_return (invoke $Nt "Mt.call" (i32.const 2)) (i32.const 4))
322 (assert_return (invoke $Nt "call" (i32.const 2)) (i32.const 5))
323 (assert_return (invoke $Nt "call Mt.call" (i32.const 2)) (i32.const 4))
324
325 (assert_trap (invoke $Mt "call" (i32.const 1)) "uninitialized")
326 (assert_trap (invoke $Nt "Mt.call" (i32.const 1)) "uninitialized")
327 (assert_return (invoke $Nt "call" (i32.const 1)) (i32.const 5))
328 (assert_trap (invoke $Nt "call Mt.call" (i32.const 1)) "uninitialized")
329
330 (assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized")
331 (assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized")
332 (assert_return (invoke $Nt "call" (i32.const 0)) (i32.const 5))
333 (assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized")
334
335 (assert_trap (invoke $Mt "call" (i32.const 20)) "undefined")
336 (assert_trap (invoke $Nt "Mt.call" (i32.const 20)) "undefined")
337 (assert_trap (invoke $Nt "call" (i32.const 7)) "undefined")
338 (assert_trap (invoke $Nt "call Mt.call" (i32.const 20)) "undefined")
339
340 (assert_return (invoke $Nt "call" (i32.const 3)) (i32.const -4))
341 (assert_trap (invoke $Nt "call" (i32.const 4)) "indirect call")
342
343 (module $Ot
344   (type (func (result i32)))
345
346   (func $h (import "Mt" "h") (result i32))
347   (table (import "Mt" "tab") 5 funcref)
348   (elem (i32.const 1) $i $h)
349   (func $i (result i32) (i32.const 6))
350
351   (func (export "call") (param i32) (result i32)
352     (call_indirect (type 0) (local.get 0))
353   )
354 )
355
356 (assert_return (invoke $Mt "call" (i32.const 3)) (i32.const 4))
357 (assert_return (invoke $Nt "Mt.call" (i32.const 3)) (i32.const 4))
358 (assert_return (invoke $Nt "call Mt.call" (i32.const 3)) (i32.const 4))
359 (assert_return (invoke $Ot "call" (i32.const 3)) (i32.const 4))
360
361 (assert_return (invoke $Mt "call" (i32.const 2)) (i32.const -4))
362 (assert_return (invoke $Nt "Mt.call" (i32.const 2)) (i32.const -4))
363 (assert_return (invoke $Nt "call" (i32.const 2)) (i32.const 5))
364 (assert_return (invoke $Nt "call Mt.call" (i32.const 2)) (i32.const -4))
365 (assert_return (invoke $Ot "call" (i32.const 2)) (i32.const -4))
366
367 (assert_return (invoke $Mt "call" (i32.const 1)) (i32.const 6))
368 (assert_return (invoke $Nt "Mt.call" (i32.const 1)) (i32.const 6))
369 (assert_return (invoke $Nt "call" (i32.const 1)) (i32.const 5))
370 (assert_return (invoke $Nt "call Mt.call" (i32.const 1)) (i32.const 6))
371 (assert_return (invoke $Ot "call" (i32.const 1)) (i32.const 6))
372
373 (assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized")
374 (assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized")
375 (assert_return (invoke $Nt "call" (i32.const 0)) (i32.const 5))
376 (assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized")
377 (assert_trap (invoke $Ot "call" (i32.const 0)) "uninitialized")
378
379 (assert_trap (invoke $Ot "call" (i32.const 20)) "undefined")
380
381 (module
382   (table (import "Mt" "tab") 0 funcref)
383   (elem (i32.const 9) $f)
384   (func $f)
385 )
386
387 (module $G1 (global (export "g") i32 (i32.const 5)))
388 (register "G1" $G1)
389 (module $G2
390   (global (import "G1" "g") i32)
391   (global (export "g") i32 (global.get 0))
392 )
393 (assert_return (get $G2 "g") (i32.const 5))
394
395 (assert_trap
396   (module
397     (table (import "Mt" "tab") 0 funcref)
398     (elem (i32.const 10) $f)
399     (func $f)
400   )
401   "out of bounds"
402 )
403
404 (assert_unlinkable
405   (module
406     (table (import "Mt" "tab") 10 funcref)
407     (memory (import "Mt" "mem") 1)  ;; does not exist
408     (func $f (result i32) (i32.const 0))
409     (elem (i32.const 7) $f)
410     (elem (i32.const 9) $f)
411   )
412   "unknown import"
413 )
414 (assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized")
415
416 ;; Unlike in the v1 spec, active element segments stored before an
417 ;; out-of-bounds access persist after the instantiation failure.
418 (assert_trap
419   (module
420     (table (import "Mt" "tab") 10 funcref)
421     (func $f (result i32) (i32.const 0))
422     (elem (i32.const 7) $f)
423     (elem (i32.const 8) $f $f $f $f $f)  ;; (partially) out of bounds
424   )
425   "out of bounds"
426 )
427 (assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0))
428 (assert_trap (invoke $Mt "call" (i32.const 8)) "uninitialized")
429
430 (assert_trap
431   (module
432     (table (import "Mt" "tab") 10 funcref)
433     (func $f (result i32) (i32.const 0))
434     (elem (i32.const 7) $f)
435     (memory 1)
436     (data (i32.const 0x10000) "d")  ;; out of bounds
437   )
438   "out of bounds"
439 )
440 (assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0))
441
442
443 (module $Mtable_ex
444   (type $t (func))
445   (table (export "t-funcnull") 1 (ref null func))
446   (table (export "t-refnull") 1 (ref null $t))
447   (table (export "t-extern") 1 externref)
448 )
449 (register "Mtable_ex" $Mtable_ex)
450
451 (module
452   (type $t (func))
453   (table (import "Mtable_ex" "t-funcnull") 1 (ref null func))
454   (table (import "Mtable_ex" "t-refnull") 1 (ref null $t))
455   (table (import "Mtable_ex" "t-extern") 1 externref)
456 )
457
458 (assert_unlinkable
459   (module (table (import "Mtable_ex" "t-refnull") 1 (ref null func)))
460   "incompatible import type"
461 )
462 (assert_unlinkable
463   (module (table (import "Mtable_ex" "t-extern") 1 (ref null func)))
464   "incompatible import type"
465 )
466
467 (assert_unlinkable
468   (module (type $t (func)) (table (import "Mtable_ex" "t-funcnull") 1 (ref null $t)))
469   "incompatible import type"
470 )
471 (assert_unlinkable
472   (module (type $t (func)) (table (import "Mtable_ex" "t-extern") 1 (ref null $t)))
473   "incompatible import type"
474 )
475
476 (assert_unlinkable
477   (module (table (import "Mtable_ex" "t-funcnull") 1 externref))
478   "incompatible import type"
479 )
480 (assert_unlinkable
481   (module (table (import "Mtable_ex" "t-refnull") 1 externref))
482   "incompatible import type"
483 )
484
485
486 ;; Memories
487
488 (module $Mm
489   (memory (export "mem") 1 5)
490   (data (i32.const 10) "\00\01\02\03\04\05\06\07\08\09")
491
492   (func (export "load") (param $a i32) (result i32)
493     (i32.load8_u (local.get 0))
494   )
495 )
496 (register "Mm" $Mm)
497
498 (module $Nm
499   (func $loadM (import "Mm" "load") (param i32) (result i32))
500
501   (memory 1)
502   (data (i32.const 10) "\f0\f1\f2\f3\f4\f5")
503
504   (export "Mm.load" (func $loadM))
505   (func (export "load") (param $a i32) (result i32)
506     (i32.load8_u (local.get 0))
507   )
508 )
509
510 (assert_return (invoke $Mm "load" (i32.const 12)) (i32.const 2))
511 (assert_return (invoke $Nm "Mm.load" (i32.const 12)) (i32.const 2))
512 (assert_return (invoke $Nm "load" (i32.const 12)) (i32.const 0xf2))
513
514 (module $Om
515   (memory (import "Mm" "mem") 1)
516   (data (i32.const 5) "\a0\a1\a2\a3\a4\a5\a6\a7")
517
518   (func (export "load") (param $a i32) (result i32)
519     (i32.load8_u (local.get 0))
520   )
521 )
522
523 (assert_return (invoke $Mm "load" (i32.const 12)) (i32.const 0xa7))
524 (assert_return (invoke $Nm "Mm.load" (i32.const 12)) (i32.const 0xa7))
525 (assert_return (invoke $Nm "load" (i32.const 12)) (i32.const 0xf2))
526 (assert_return (invoke $Om "load" (i32.const 12)) (i32.const 0xa7))
527
528 (module
529   (memory (import "Mm" "mem") 0)
530   (data (i32.const 0xffff) "a")
531 )
532
533 (assert_trap
534   (module
535     (memory (import "Mm" "mem") 0)
536     (data (i32.const 0x10000) "a")
537   )
538   "out of bounds"
539 )
540
541 (module $Pm
542   (memory (import "Mm" "mem") 1 8)
543
544   (func (export "grow") (param $a i32) (result i32)
545     (memory.grow (local.get 0))
546   )
547 )
548
549 (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 1))
550 (assert_return (invoke $Pm "grow" (i32.const 2)) (i32.const 1))
551 (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 3))
552 (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const 3))
553 (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const 4))
554 (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5))
555 (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const -1))
556 (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5))
557
558 (assert_unlinkable
559   (module
560     (func $host (import "spectest" "print"))
561     (memory (import "Mm" "mem") 1)
562     (table (import "Mm" "tab") 0 funcref)  ;; does not exist
563     (data (i32.const 0) "abc")
564   )
565   "unknown import"
566 )
567 (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0))
568
569 ;; Unlike in v1 spec, active data segments written before an
570 ;; out-of-bounds access persist after the instantiation failure.
571 (assert_trap
572   (module
573     ;; Note: the memory is 5 pages large by the time we get here.
574     (memory (import "Mm" "mem") 1)
575     (data (i32.const 0) "abc")
576     (data (i32.const 327670) "zzzzzzzzzzzzzzzzzz") ;; (partially) out of bounds
577   )
578   "out of bounds"
579 )
580 (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97))
581 (assert_return (invoke $Mm "load" (i32.const 327670)) (i32.const 0))
582
583 (assert_trap
584   (module
585     (memory (import "Mm" "mem") 1)
586     (data (i32.const 0) "abc")
587     (table 0 funcref)
588     (func)
589     (elem (i32.const 0) 0)  ;; out of bounds
590   )
591   "out of bounds"
592 )
593 (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97))
594
595 ;; Store is modified if the start function traps.
596 (module $Ms
597   (type $t (func (result i32)))
598   (memory (export "memory") 1)
599   (table (export "table") 1 funcref)
600   (func (export "get memory[0]") (type $t)
601     (i32.load8_u (i32.const 0))
602   )
603   (func (export "get table[0]") (type $t)
604     (call_indirect (type $t) (i32.const 0))
605   )
606 )
607 (register "Ms" $Ms)
608
609 (assert_trap
610   (module
611     (import "Ms" "memory" (memory 1))
612     (import "Ms" "table" (table 1 funcref))
613     (data (i32.const 0) "hello")
614     (elem (i32.const 0) $f)
615     (func $f (result i32)
616       (i32.const 0xdead)
617     )
618     (func $main
619       (unreachable)
620     )
621     (start $main)
622   )
623   "unreachable"
624 )
625
626 (assert_return (invoke $Ms "get memory[0]") (i32.const 104))  ;; 'h'
627 (assert_return (invoke $Ms "get table[0]") (i32.const 0xdead))