|
127 | 127 | (elem $no-trap-get anyref (item (struct.new $struct (global.get $desc)))) |
128 | 128 | ) |
129 | 129 |
|
| 130 | +(module |
| 131 | + ;; CHECK: (type $void (func)) |
| 132 | + (type $void (func)) |
| 133 | + |
| 134 | + (rec |
| 135 | + ;; CHECK: (rec |
| 136 | + ;; CHECK-NEXT: (type $vtable (sub (descriptor $vtable.desc (struct (field (ref $void)))))) |
| 137 | + (type $vtable (sub (descriptor $vtable.desc (struct (field (ref $void)))))) |
| 138 | + ;; CHECK: (type $vtable.desc (sub (describes $vtable (struct (field (ref $void)))))) |
| 139 | + (type $vtable.desc (sub (describes $vtable (struct (field (ref $void)))))) |
| 140 | + ) |
| 141 | + |
| 142 | + ;; CHECK: (global $vtable (ref $vtable) (struct.new $vtable |
| 143 | + ;; CHECK-NEXT: (ref.func $a) |
| 144 | + ;; CHECK-NEXT: (struct.new $vtable.desc |
| 145 | + ;; CHECK-NEXT: (ref.func $b) |
| 146 | + ;; CHECK-NEXT: ) |
| 147 | + ;; CHECK-NEXT: )) |
| 148 | + (global $vtable (ref $vtable) (struct.new $vtable |
| 149 | + (ref.func $a) |
| 150 | + (struct.new $vtable.desc |
| 151 | + (ref.func $b) |
| 152 | + ) |
| 153 | + )) |
| 154 | + |
| 155 | + ;; CHECK: (export "export" (func $export)) |
| 156 | + |
| 157 | + ;; CHECK: (func $export (type $void) |
| 158 | + ;; CHECK-NEXT: (call_ref $void |
| 159 | + ;; CHECK-NEXT: (struct.get $vtable 0 |
| 160 | + ;; CHECK-NEXT: (global.get $vtable) |
| 161 | + ;; CHECK-NEXT: ) |
| 162 | + ;; CHECK-NEXT: ) |
| 163 | + ;; CHECK-NEXT: ) |
| 164 | + (func $export (export "export") |
| 165 | + ;; Read $a and call it. $b, in the descriptor, should not be callable. |
| 166 | + (call_ref $void |
| 167 | + (struct.get $vtable 0 |
| 168 | + (global.get $vtable) |
| 169 | + ) |
| 170 | + ) |
| 171 | + ) |
| 172 | + |
| 173 | + ;; CHECK: (func $a (type $void) |
| 174 | + ;; CHECK-NEXT: (drop |
| 175 | + ;; CHECK-NEXT: (i32.const 42) |
| 176 | + ;; CHECK-NEXT: ) |
| 177 | + ;; CHECK-NEXT: ) |
| 178 | + (func $a (type $void) |
| 179 | + ;; This is reached from above. |
| 180 | + (drop (i32.const 42)) |
| 181 | + ) |
| 182 | + |
| 183 | + ;; CHECK: (func $b (type $void) |
| 184 | + ;; CHECK-NEXT: (unreachable) |
| 185 | + ;; CHECK-NEXT: ) |
| 186 | + (func $b (type $void) |
| 187 | + ;; This is not reached: We never read the descriptor, so we never read field 0 |
| 188 | + ;; in it, leaving this as dead (in closed world). That it itself seems to read |
| 189 | + ;; the descriptor should not confuse us. |
| 190 | + (call_ref $void |
| 191 | + (struct.get $vtable.desc 0 |
| 192 | + (ref.get_desc $vtable |
| 193 | + (global.get $vtable) |
| 194 | + ) |
| 195 | + ) |
| 196 | + ) |
| 197 | + ) |
| 198 | +) |
| 199 | + |
0 commit comments