| 1 |
;; RUN: wast --assert default --snapshot tests/snapshots % |
| 2 |
|
| 3 |
;; Instantiation is generative |
| 4 |
|
| 5 |
(module definition $M |
| 6 |
(global (export "glob") (mut i32) (i32.const 0)) |
| 7 |
(table (export "tab") 10 funcref (ref.null func)) |
| 8 |
(memory (export "mem") 1) |
| 9 |
(tag (export "tag")) |
| 10 |
) |
| 11 |
|
| 12 |
(module instance $I1 $M) |
| 13 |
(module instance $I2 $M) |
| 14 |
(register "I1" $I1) |
| 15 |
(register "I2" $I2) |
| 16 |
|
| 17 |
(module |
| 18 |
(import "I1" "glob" (global $glob1 (mut i32))) |
| 19 |
(import "I2" "glob" (global $glob2 (mut i32))) |
| 20 |
(import "I1" "tab" (table $tab1 10 funcref)) |
| 21 |
(import "I2" "tab" (table $tab2 10 funcref)) |
| 22 |
(import "I1" "mem" (memory $mem1 1)) |
| 23 |
(import "I2" "mem" (memory $mem2 1)) |
| 24 |
(import "I1" "tag" (tag $tag1)) |
| 25 |
(import "I2" "tag" (tag $tag2)) |
| 26 |
|
| 27 |
(func $f) |
| 28 |
(elem declare func $f) |
| 29 |
|
| 30 |
(func (export "glob") (result i32) |
| 31 |
(global.set $glob1 (i32.const 1)) |
| 32 |
(global.get $glob2) |
| 33 |
) |
| 34 |
(func (export "tab") (result funcref) |
| 35 |
(table.set $tab1 (i32.const 0) (ref.func $f)) |
| 36 |
(table.get $tab2 (i32.const 0)) |
| 37 |
) |
| 38 |
(func (export "mem") (result i32) |
| 39 |
(i32.store $mem1 (i32.const 0) (i32.const 1)) |
| 40 |
(i32.load $mem2 (i32.const 0)) |
| 41 |
) |
| 42 |
(func (export "tag") (result i32) |
| 43 |
(block $on_tag1 |
| 44 |
(block $on_other |
| 45 |
(try_table (catch $tag1 $on_tag1) (catch_all $on_other) |
| 46 |
(throw $tag2) |
| 47 |
) |
| 48 |
(unreachable) |
| 49 |
) |
| 50 |
(return (i32.const 0)) |
| 51 |
) |
| 52 |
(return (i32.const 1)) |
| 53 |
) |
| 54 |
) |
| 55 |
|
| 56 |
(assert_return (invoke "glob") (i32.const 0)) |
| 57 |
(assert_return (invoke "tab") (ref.null)) |
| 58 |
(assert_return (invoke "mem") (i32.const 0)) |
| 59 |
(assert_return (invoke "tag") (i32.const 0)) |
| 60 |
|
| 61 |
|
| 62 |
;; Import is not generative |
| 63 |
|
| 64 |
(module |
| 65 |
(import "I1" "glob" (global $glob1 (mut i32))) |
| 66 |
(import "I1" "glob" (global $glob2 (mut i32))) |
| 67 |
(import "I1" "tab" (table $tab1 10 funcref)) |
| 68 |
(import "I1" "tab" (table $tab2 10 funcref)) |
| 69 |
(import "I1" "mem" (memory $mem1 1)) |
| 70 |
(import "I1" "mem" (memory $mem2 1)) |
| 71 |
(import "I1" "tag" (tag $tag1)) |
| 72 |
(import "I1" "tag" (tag $tag2)) |
| 73 |
|
| 74 |
(func $f) |
| 75 |
(elem declare func $f) |
| 76 |
|
| 77 |
(func (export "glob") (result i32) |
| 78 |
(global.set $glob1 (i32.const 1)) |
| 79 |
(global.get $glob2) |
| 80 |
) |
| 81 |
(func (export "tab") (result funcref) |
| 82 |
(table.set $tab1 (i32.const 0) (ref.func $f)) |
| 83 |
(table.get $tab2 (i32.const 0)) |
| 84 |
) |
| 85 |
(func (export "mem") (result i32) |
| 86 |
(i32.store $mem1 (i32.const 0) (i32.const 1)) |
| 87 |
(i32.load $mem2 (i32.const 0)) |
| 88 |
) |
| 89 |
(func (export "tag") (result i32) |
| 90 |
(block $on_tag1 |
| 91 |
(block $on_other |
| 92 |
(try_table (catch $tag1 $on_tag1) (catch_all $on_other) |
| 93 |
(throw $tag2) |
| 94 |
) |
| 95 |
(unreachable) |
| 96 |
) |
| 97 |
(return (i32.const 0)) |
| 98 |
) |
| 99 |
(return (i32.const 1)) |
| 100 |
) |
| 101 |
) |
| 102 |
|
| 103 |
(assert_return (invoke "glob") (i32.const 1)) |
| 104 |
(assert_return (invoke "tab") (ref.func)) |
| 105 |
(assert_return (invoke "mem") (i32.const 1)) |
| 106 |
(assert_return (invoke "tag") (i32.const 1)) |
| 107 |
|
| 108 |
|
| 109 |
;; Export is not generative |
| 110 |
|
| 111 |
(module definition $N |
| 112 |
(global $glob (mut i32) (i32.const 0)) |
| 113 |
(table $tab 10 funcref (ref.null func)) |
| 114 |
(memory $mem 1) |
| 115 |
(tag $tag) |
| 116 |
|
| 117 |
(export "glob1" (global $glob)) |
| 118 |
(export "glob2" (global $glob)) |
| 119 |
(export "tab1" (table $tab)) |
| 120 |
(export "tab2" (table $tab)) |
| 121 |
(export "mem1" (memory $mem)) |
| 122 |
(export "mem2" (memory $mem)) |
| 123 |
(export "tag1" (tag $tag)) |
| 124 |
(export "tag2" (tag $tag)) |
| 125 |
) |
| 126 |
|
| 127 |
(module instance $I $N) |
| 128 |
(register "I" $I) |
| 129 |
|
| 130 |
(module |
| 131 |
(import "I" "glob1" (global $glob1 (mut i32))) |
| 132 |
(import "I" "glob2" (global $glob2 (mut i32))) |
| 133 |
(import "I" "tab1" (table $tab1 10 funcref)) |
| 134 |
(import "I" "tab2" (table $tab2 10 funcref)) |
| 135 |
(import "I" "mem1" (memory $mem1 1)) |
| 136 |
(import "I" "mem2" (memory $mem2 1)) |
| 137 |
(import "I" "tag1" (tag $tag1)) |
| 138 |
(import "I" "tag2" (tag $tag2)) |
| 139 |
|
| 140 |
(func $f) |
| 141 |
(elem declare func $f) |
| 142 |
|
| 143 |
(func (export "glob") (result i32) |
| 144 |
(global.set $glob1 (i32.const 1)) |
| 145 |
(global.get $glob2) |
| 146 |
) |
| 147 |
(func (export "tab") (result funcref) |
| 148 |
(table.set $tab1 (i32.const 0) (ref.func $f)) |
| 149 |
(table.get $tab2 (i32.const 0)) |
| 150 |
) |
| 151 |
(func (export "mem") (result i32) |
| 152 |
(i32.store $mem1 (i32.const 0) (i32.const 1)) |
| 153 |
(i32.load $mem2 (i32.const 0)) |
| 154 |
) |
| 155 |
(func (export "tag") (result i32) |
| 156 |
(block $on_tag1 |
| 157 |
(block $on_other |
| 158 |
(try_table (catch $tag1 $on_tag1) (catch_all $on_other) |
| 159 |
(throw $tag2) |
| 160 |
) |
| 161 |
(unreachable) |
| 162 |
) |
| 163 |
(return (i32.const 0)) |
| 164 |
) |
| 165 |
(return (i32.const 1)) |
| 166 |
) |
| 167 |
) |
| 168 |
|
| 169 |
(assert_return (invoke "glob") (i32.const 1)) |
| 170 |
(assert_return (invoke "tab") (ref.func)) |
| 171 |
(assert_return (invoke "mem") (i32.const 1)) |
| 172 |
(assert_return (invoke "tag") (i32.const 1)) |