summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/spec/multi-memory/memory_grow.wast.js
blob: 6cef74d6bae009880276726067850e3c1d5d3977 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
/* Copyright 2021 Mozilla Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// ./test/core/memory_grow.wast

// ./test/core/memory_grow.wast:1
let $0 = instantiate(`(module
  (memory 0)
  (func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
)`);

// ./test/core/memory_grow.wast:6
assert_return(() => invoke($0, `grow`, [0]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:7
assert_return(() => invoke($0, `grow`, [1]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:8
assert_return(() => invoke($0, `grow`, [0]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:9
assert_return(() => invoke($0, `grow`, [2]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:10
assert_return(() => invoke($0, `grow`, [800]), [value("i32", 3)]);

// ./test/core/memory_grow.wast:11
assert_return(() => invoke($0, `grow`, [65536]), [value("i32", -1)]);

// ./test/core/memory_grow.wast:12
assert_return(() => invoke($0, `grow`, [64736]), [value("i32", -1)]);

// ./test/core/memory_grow.wast:13
assert_return(() => invoke($0, `grow`, [1]), [value("i32", 803)]);

// ./test/core/memory_grow.wast:15
let $1 = instantiate(`(module
  (memory 0 10)
  (func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
)`);

// ./test/core/memory_grow.wast:20
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:21
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:22
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:23
assert_return(() => invoke($1, `grow`, [2]), [value("i32", 2)]);

// ./test/core/memory_grow.wast:24
assert_return(() => invoke($1, `grow`, [6]), [value("i32", 4)]);

// ./test/core/memory_grow.wast:25
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 10)]);

// ./test/core/memory_grow.wast:26
assert_return(() => invoke($1, `grow`, [1]), [value("i32", -1)]);

// ./test/core/memory_grow.wast:27
assert_return(() => invoke($1, `grow`, [65536]), [value("i32", -1)]);

// ./test/core/memory_grow.wast:32
let $2 = instantiate(`(module
  (memory 1)
  (func (export "grow") (param i32) (result i32)
    (memory.grow (local.get 0))
  )
  (func (export "check-memory-zero") (param i32 i32) (result i32)
    (local i32)
    (local.set 2 (i32.const 1))
    (block
      (loop
        (local.set 2 (i32.load8_u (local.get 0)))
        (br_if 1 (i32.ne (local.get 2) (i32.const 0)))
        (br_if 1 (i32.ge_u (local.get 0) (local.get 1)))
        (local.set 0 (i32.add (local.get 0) (i32.const 1)))
        (br_if 0 (i32.le_u (local.get 0) (local.get 1)))
      )
    )
    (local.get 2)
  )
)`);

// ./test/core/memory_grow.wast:53
assert_return(() => invoke($2, `check-memory-zero`, [0, 65535]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:54
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:55
assert_return(() => invoke($2, `check-memory-zero`, [65536, 131071]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:56
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 2)]);

// ./test/core/memory_grow.wast:57
assert_return(() => invoke($2, `check-memory-zero`, [131072, 196607]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:58
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 3)]);

// ./test/core/memory_grow.wast:59
assert_return(() => invoke($2, `check-memory-zero`, [196608, 262143]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:60
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 4)]);

// ./test/core/memory_grow.wast:61
assert_return(() => invoke($2, `check-memory-zero`, [262144, 327679]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:62
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 5)]);

// ./test/core/memory_grow.wast:63
assert_return(() => invoke($2, `check-memory-zero`, [327680, 393215]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:68
let $3 = instantiate(`(module
  (memory 0)

  (func (export "load_at_zero") (result i32) (i32.load (i32.const 0)))
  (func (export "store_at_zero") (i32.store (i32.const 0) (i32.const 2)))

  (func (export "load_at_page_size") (result i32)
    (i32.load (i32.const 0x10000))
  )
  (func (export "store_at_page_size")
    (i32.store (i32.const 0x10000) (i32.const 3))
  )

  (func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
  (func (export "size") (result i32) (memory.size))
)`);

// ./test/core/memory_grow.wast:85
assert_return(() => invoke($3, `size`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:86
assert_trap(() => invoke($3, `store_at_zero`, []), `out of bounds memory access`);

// ./test/core/memory_grow.wast:87
assert_trap(() => invoke($3, `load_at_zero`, []), `out of bounds memory access`);

// ./test/core/memory_grow.wast:88
assert_trap(() => invoke($3, `store_at_page_size`, []), `out of bounds memory access`);

// ./test/core/memory_grow.wast:89
assert_trap(() => invoke($3, `load_at_page_size`, []), `out of bounds memory access`);

// ./test/core/memory_grow.wast:90
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:91
assert_return(() => invoke($3, `size`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:92
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:93
assert_return(() => invoke($3, `store_at_zero`, []), []);

// ./test/core/memory_grow.wast:94
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 2)]);

// ./test/core/memory_grow.wast:95
assert_trap(() => invoke($3, `store_at_page_size`, []), `out of bounds memory access`);

// ./test/core/memory_grow.wast:96
assert_trap(() => invoke($3, `load_at_page_size`, []), `out of bounds memory access`);

// ./test/core/memory_grow.wast:97
assert_return(() => invoke($3, `grow`, [4]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:98
assert_return(() => invoke($3, `size`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:99
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 2)]);

// ./test/core/memory_grow.wast:100
assert_return(() => invoke($3, `store_at_zero`, []), []);

// ./test/core/memory_grow.wast:101
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 2)]);

// ./test/core/memory_grow.wast:102
assert_return(() => invoke($3, `load_at_page_size`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:103
assert_return(() => invoke($3, `store_at_page_size`, []), []);

// ./test/core/memory_grow.wast:104
assert_return(() => invoke($3, `load_at_page_size`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:109
let $4 = instantiate(`(module
  (memory (export "mem1") 2 5)
  (memory (export "mem2") 0)
)`);

// ./test/core/memory_grow.wast:113
register($4, `M`);

// ./test/core/memory_grow.wast:115
let $5 = instantiate(`(module
  (memory $$mem1 (import "M" "mem1") 1 6)
  (memory $$mem2 (import "M" "mem2") 0)
  (memory $$mem3 3)
  (memory $$mem4 4 5)

  (func (export "size1") (result i32) (memory.size $$mem1))
  (func (export "size2") (result i32) (memory.size $$mem2))
  (func (export "size3") (result i32) (memory.size $$mem3))
  (func (export "size4") (result i32) (memory.size $$mem4))

  (func (export "grow1") (param i32) (result i32)
    (memory.grow $$mem1 (local.get 0))
  )
  (func (export "grow2") (param i32) (result i32)
    (memory.grow $$mem2 (local.get 0))
  )
  (func (export "grow3") (param i32) (result i32)
    (memory.grow $$mem3 (local.get 0))
  )
  (func (export "grow4") (param i32) (result i32)
    (memory.grow $$mem4 (local.get 0))
  )
)`);

// ./test/core/memory_grow.wast:140
assert_return(() => invoke($5, `size1`, []), [value("i32", 2)]);

// ./test/core/memory_grow.wast:141
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:142
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:143
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);

// ./test/core/memory_grow.wast:145
assert_return(() => invoke($5, `grow1`, [1]), [value("i32", 2)]);

// ./test/core/memory_grow.wast:146
assert_return(() => invoke($5, `size1`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:147
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:148
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:149
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);

// ./test/core/memory_grow.wast:151
assert_return(() => invoke($5, `grow1`, [2]), [value("i32", 3)]);

// ./test/core/memory_grow.wast:152
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:153
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:154
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:155
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);

// ./test/core/memory_grow.wast:157
assert_return(() => invoke($5, `grow1`, [1]), [value("i32", -1)]);

// ./test/core/memory_grow.wast:158
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:159
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:160
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:161
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);

// ./test/core/memory_grow.wast:163
assert_return(() => invoke($5, `grow2`, [10]), [value("i32", 0)]);

// ./test/core/memory_grow.wast:164
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:165
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);

// ./test/core/memory_grow.wast:166
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:167
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);

// ./test/core/memory_grow.wast:169
assert_return(() => invoke($5, `grow3`, [268435456]), [value("i32", -1)]);

// ./test/core/memory_grow.wast:170
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:171
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);

// ./test/core/memory_grow.wast:172
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);

// ./test/core/memory_grow.wast:173
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);

// ./test/core/memory_grow.wast:175
assert_return(() => invoke($5, `grow3`, [3]), [value("i32", 3)]);

// ./test/core/memory_grow.wast:176
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:177
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);

// ./test/core/memory_grow.wast:178
assert_return(() => invoke($5, `size3`, []), [value("i32", 6)]);

// ./test/core/memory_grow.wast:179
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);

// ./test/core/memory_grow.wast:181
assert_return(() => invoke($5, `grow4`, [1]), [value("i32", 4)]);

// ./test/core/memory_grow.wast:182
assert_return(() => invoke($5, `grow4`, [1]), [value("i32", -1)]);

// ./test/core/memory_grow.wast:183
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:184
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);

// ./test/core/memory_grow.wast:185
assert_return(() => invoke($5, `size3`, []), [value("i32", 6)]);

// ./test/core/memory_grow.wast:186
assert_return(() => invoke($5, `size4`, []), [value("i32", 5)]);

// ./test/core/memory_grow.wast:191
let $6 = instantiate(`(module
  (memory 1)

  (func (export "as-br-value") (result i32)
    (block (result i32) (br 0 (memory.grow (i32.const 0))))
  )

  (func (export "as-br_if-cond")
    (block (br_if 0 (memory.grow (i32.const 0))))
  )
  (func (export "as-br_if-value") (result i32)
    (block (result i32)
      (drop (br_if 0 (memory.grow (i32.const 0)) (i32.const 1))) (i32.const 7)
    )
  )
  (func (export "as-br_if-value-cond") (result i32)
    (block (result i32)
      (drop (br_if 0 (i32.const 6) (memory.grow (i32.const 0)))) (i32.const 7)
    )
  )

  (func (export "as-br_table-index")
    (block (br_table 0 0 0 (memory.grow (i32.const 0))))
  )
  (func (export "as-br_table-value") (result i32)
    (block (result i32)
      (br_table 0 0 0 (memory.grow (i32.const 0)) (i32.const 1)) (i32.const 7)
    )
  )
  (func (export "as-br_table-value-index") (result i32)
    (block (result i32)
      (br_table 0 0 (i32.const 6) (memory.grow (i32.const 0))) (i32.const 7)
    )
  )

  (func (export "as-return-value") (result i32)
    (return (memory.grow (i32.const 0)))
  )

  (func (export "as-if-cond") (result i32)
    (if (result i32) (memory.grow (i32.const 0))
      (then (i32.const 0)) (else (i32.const 1))
    )
  )
  (func (export "as-if-then") (result i32)
    (if (result i32) (i32.const 1)
      (then (memory.grow (i32.const 0))) (else (i32.const 0))
    )
  )
  (func (export "as-if-else") (result i32)
    (if (result i32) (i32.const 0)
      (then (i32.const 0)) (else (memory.grow (i32.const 0)))
    )
  )

  (func (export "as-select-first") (param i32 i32) (result i32)
    (select (memory.grow (i32.const 0)) (local.get 0) (local.get 1))
  )
  (func (export "as-select-second") (param i32 i32) (result i32)
    (select (local.get 0) (memory.grow (i32.const 0)) (local.get 1))
  )
  (func (export "as-select-cond") (result i32)
    (select (i32.const 0) (i32.const 1) (memory.grow (i32.const 0)))
  )

  (func $$f (param i32 i32 i32) (result i32) (i32.const -1))
  (func (export "as-call-first") (result i32)
    (call $$f (memory.grow (i32.const 0)) (i32.const 2) (i32.const 3))
  )
  (func (export "as-call-mid") (result i32)
    (call $$f (i32.const 1) (memory.grow (i32.const 0)) (i32.const 3))
  )
  (func (export "as-call-last") (result i32)
    (call $$f (i32.const 1) (i32.const 2) (memory.grow (i32.const 0)))
  )

  (type $$sig (func (param i32 i32 i32) (result i32)))
  (table funcref (elem $$f))
  (func (export "as-call_indirect-first") (result i32)
    (call_indirect (type $$sig)
      (memory.grow (i32.const 0)) (i32.const 2) (i32.const 3) (i32.const 0)
    )
  )
  (func (export "as-call_indirect-mid") (result i32)
    (call_indirect (type $$sig)
      (i32.const 1) (memory.grow (i32.const 0)) (i32.const 3) (i32.const 0)
    )
  )
  (func (export "as-call_indirect-last") (result i32)
    (call_indirect (type $$sig)
      (i32.const 1) (i32.const 2) (memory.grow (i32.const 0)) (i32.const 0)
    )
  )
  (func (export "as-call_indirect-index") (result i32)
    (call_indirect (type $$sig)
      (i32.const 1) (i32.const 2) (i32.const 3) (memory.grow (i32.const 0))
    )
  )

  (func (export "as-local.set-value") (local i32)
    (local.set 0 (memory.grow (i32.const 0)))
  )
  (func (export "as-local.tee-value") (result i32) (local i32)
    (local.tee 0 (memory.grow (i32.const 0)))
  )
  (global $$g (mut i32) (i32.const 0))
  (func (export "as-global.set-value") (local i32)
    (global.set $$g (memory.grow (i32.const 0)))
  )

  (func (export "as-load-address") (result i32)
    (i32.load (memory.grow (i32.const 0)))
  )
  (func (export "as-loadN-address") (result i32)
    (i32.load8_s (memory.grow (i32.const 0)))
  )

  (func (export "as-store-address")
    (i32.store (memory.grow (i32.const 0)) (i32.const 7))
  )
  (func (export "as-store-value")
    (i32.store (i32.const 2) (memory.grow (i32.const 0)))
  )

  (func (export "as-storeN-address")
    (i32.store8 (memory.grow (i32.const 0)) (i32.const 7))
  )
  (func (export "as-storeN-value")
    (i32.store16 (i32.const 2) (memory.grow (i32.const 0)))
  )

  (func (export "as-unary-operand") (result i32)
    (i32.clz (memory.grow (i32.const 0)))
  )

  (func (export "as-binary-left") (result i32)
    (i32.add (memory.grow (i32.const 0)) (i32.const 10))
  )
  (func (export "as-binary-right") (result i32)
    (i32.sub (i32.const 10) (memory.grow (i32.const 0)))
  )

  (func (export "as-test-operand") (result i32)
    (i32.eqz (memory.grow (i32.const 0)))
  )

  (func (export "as-compare-left") (result i32)
    (i32.le_s (memory.grow (i32.const 0)) (i32.const 10))
  )
  (func (export "as-compare-right") (result i32)
    (i32.ne (i32.const 10) (memory.grow (i32.const 0)))
  )

  (func (export "as-memory.grow-size") (result i32)
    (memory.grow (memory.grow (i32.const 0)))
  )
)`);

// ./test/core/memory_grow.wast:349
assert_return(() => invoke($6, `as-br-value`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:351
assert_return(() => invoke($6, `as-br_if-cond`, []), []);

// ./test/core/memory_grow.wast:352
assert_return(() => invoke($6, `as-br_if-value`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:353
assert_return(() => invoke($6, `as-br_if-value-cond`, []), [value("i32", 6)]);

// ./test/core/memory_grow.wast:355
assert_return(() => invoke($6, `as-br_table-index`, []), []);

// ./test/core/memory_grow.wast:356
assert_return(() => invoke($6, `as-br_table-value`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:357
assert_return(() => invoke($6, `as-br_table-value-index`, []), [value("i32", 6)]);

// ./test/core/memory_grow.wast:359
assert_return(() => invoke($6, `as-return-value`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:361
assert_return(() => invoke($6, `as-if-cond`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:362
assert_return(() => invoke($6, `as-if-then`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:363
assert_return(() => invoke($6, `as-if-else`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:365
assert_return(() => invoke($6, `as-select-first`, [0, 1]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:366
assert_return(() => invoke($6, `as-select-second`, [0, 0]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:367
assert_return(() => invoke($6, `as-select-cond`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:369
assert_return(() => invoke($6, `as-call-first`, []), [value("i32", -1)]);

// ./test/core/memory_grow.wast:370
assert_return(() => invoke($6, `as-call-mid`, []), [value("i32", -1)]);

// ./test/core/memory_grow.wast:371
assert_return(() => invoke($6, `as-call-last`, []), [value("i32", -1)]);

// ./test/core/memory_grow.wast:373
assert_return(() => invoke($6, `as-call_indirect-first`, []), [value("i32", -1)]);

// ./test/core/memory_grow.wast:374
assert_return(() => invoke($6, `as-call_indirect-mid`, []), [value("i32", -1)]);

// ./test/core/memory_grow.wast:375
assert_return(() => invoke($6, `as-call_indirect-last`, []), [value("i32", -1)]);

// ./test/core/memory_grow.wast:376
assert_trap(() => invoke($6, `as-call_indirect-index`, []), `undefined element`);

// ./test/core/memory_grow.wast:378
assert_return(() => invoke($6, `as-local.set-value`, []), []);

// ./test/core/memory_grow.wast:379
assert_return(() => invoke($6, `as-local.tee-value`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:380
assert_return(() => invoke($6, `as-global.set-value`, []), []);

// ./test/core/memory_grow.wast:382
assert_return(() => invoke($6, `as-load-address`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:383
assert_return(() => invoke($6, `as-loadN-address`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:384
assert_return(() => invoke($6, `as-store-address`, []), []);

// ./test/core/memory_grow.wast:385
assert_return(() => invoke($6, `as-store-value`, []), []);

// ./test/core/memory_grow.wast:386
assert_return(() => invoke($6, `as-storeN-address`, []), []);

// ./test/core/memory_grow.wast:387
assert_return(() => invoke($6, `as-storeN-value`, []), []);

// ./test/core/memory_grow.wast:389
assert_return(() => invoke($6, `as-unary-operand`, []), [value("i32", 31)]);

// ./test/core/memory_grow.wast:391
assert_return(() => invoke($6, `as-binary-left`, []), [value("i32", 11)]);

// ./test/core/memory_grow.wast:392
assert_return(() => invoke($6, `as-binary-right`, []), [value("i32", 9)]);

// ./test/core/memory_grow.wast:394
assert_return(() => invoke($6, `as-test-operand`, []), [value("i32", 0)]);

// ./test/core/memory_grow.wast:396
assert_return(() => invoke($6, `as-compare-left`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:397
assert_return(() => invoke($6, `as-compare-right`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:399
assert_return(() => invoke($6, `as-memory.grow-size`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:404
let $7 = instantiate(`(module
  (memory $$mem1 1)
  (memory $$mem2 2)

  (func (export "grow1") (param i32) (result i32)
    (memory.grow $$mem1 (local.get 0))
  )
  (func (export "grow2") (param i32) (result i32)
    (memory.grow $$mem2 (local.get 0))
  )

  (func (export "size1") (result i32) (memory.size $$mem1))
  (func (export "size2") (result i32) (memory.size $$mem2))
)`);

// ./test/core/memory_grow.wast:419
assert_return(() => invoke($7, `size1`, []), [value("i32", 1)]);

// ./test/core/memory_grow.wast:420
assert_return(() => invoke($7, `size2`, []), [value("i32", 2)]);

// ./test/core/memory_grow.wast:421
assert_return(() => invoke($7, `grow1`, [3]), [value("i32", 1)]);

// ./test/core/memory_grow.wast:422
assert_return(() => invoke($7, `grow1`, [4]), [value("i32", 4)]);

// ./test/core/memory_grow.wast:423
assert_return(() => invoke($7, `grow1`, [1]), [value("i32", 8)]);

// ./test/core/memory_grow.wast:424
assert_return(() => invoke($7, `grow2`, [1]), [value("i32", 2)]);

// ./test/core/memory_grow.wast:425
assert_return(() => invoke($7, `grow2`, [1]), [value("i32", 3)]);

// ./test/core/memory_grow.wast:430
assert_invalid(
  () => instantiate(`(module
    (memory 1)
    (func $$type-i32-vs-f32 (result i32)
      (memory.grow (f32.const 0))
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:439
assert_invalid(
  () => instantiate(`(module
    (memory 0)
    (func $$type-size-empty-vs-i32 (result i32)
      (memory.grow)
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:448
assert_invalid(
  () => instantiate(`(module
    (memory 0)
    (func $$type-size-empty-vs-i32-in-block (result i32)
      (i32.const 0)
      (block (result i32) (memory.grow))
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:458
assert_invalid(
  () => instantiate(`(module
    (memory 0)
    (func $$type-size-empty-vs-i32-in-loop (result i32)
      (i32.const 0)
      (loop (result i32) (memory.grow))
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:468
assert_invalid(
  () => instantiate(`(module
    (memory 0)
    (func $$type-size-empty-vs-i32-in-then (result i32)
      (i32.const 0) (i32.const 0)
      (if (result i32) (then (memory.grow)))
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:479
assert_invalid(
  () => instantiate(`(module
    (memory 1)
    (func $$type-result-i32-vs-empty
      (memory.grow (i32.const 1))
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:488
assert_invalid(
  () => instantiate(`(module
    (memory 1)
    (func $$type-size-f32-vs-i32 (result i32)
      (memory.grow (f32.const 0))
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:498
assert_invalid(
  () => instantiate(`(module
    (memory 1)
    (func $$type-result-i32-vs-empty
      (memory.grow (i32.const 0))
    )
  )`),
  `type mismatch`,
);

// ./test/core/memory_grow.wast:507
assert_invalid(
  () => instantiate(`(module
    (memory 1)
    (func $$type-result-i32-vs-f32 (result f32)
      (memory.grow (i32.const 0))
    )
  )`),
  `type mismatch`,
);