| 1 |
;; RUN: wast --assert default --snapshot tests/snapshots % -f shared-everything-threads |
| 2 |
|
| 3 |
;; Shared struct declaration syntax. |
| 4 |
(module |
| 5 |
(type (shared (struct))) |
| 6 |
(type (sub final (shared (struct)))) |
| 7 |
(rec |
| 8 |
(type (sub final (shared (struct)))) |
| 9 |
) |
| 10 |
|
| 11 |
(global (ref 0) (struct.new 1)) |
| 12 |
(global (ref 1) (struct.new 2)) |
| 13 |
(global (ref 2) (struct.new 0)) |
| 14 |
) |
| 15 |
|
| 16 |
;; Shared structs are distinct from non-shared structs. |
| 17 |
(assert_invalid |
| 18 |
(module |
| 19 |
(type (shared (struct))) |
| 20 |
(type (struct)) |
| 21 |
|
| 22 |
(global (ref 0) (struct.new 1)) |
| 23 |
) |
| 24 |
"type mismatch" |
| 25 |
) |
| 26 |
|
| 27 |
(assert_invalid |
| 28 |
(module |
| 29 |
(type (shared (struct))) |
| 30 |
(type (struct)) |
| 31 |
|
| 32 |
(global (ref 1) (struct.new 0)) |
| 33 |
) |
| 34 |
"type mismatch" |
| 35 |
) |
| 36 |
|
| 37 |
;; Shared structs may not be subtypes of non-shared structs. |
| 38 |
(assert_invalid |
| 39 |
(module |
| 40 |
(type (sub (struct))) |
| 41 |
(type (sub 0 (shared (struct)))) |
| 42 |
) |
| 43 |
"must match super type" |
| 44 |
) |
| 45 |
|
| 46 |
;; Non-shared structs may not be subtypes of shared structs. |
| 47 |
(assert_invalid |
| 48 |
(module |
| 49 |
(type (sub (shared (struct)))) |
| 50 |
(type (sub 0 (struct))) |
| 51 |
) |
| 52 |
"must match super type" |
| 53 |
) |
| 54 |
|
| 55 |
;; Shared structs may not contain non-shared references. |
| 56 |
(assert_invalid |
| 57 |
(module |
| 58 |
(type (shared (struct (field anyref)))) |
| 59 |
) |
| 60 |
"must contain shared type" |
| 61 |
) |
| 62 |
|
| 63 |
;; But they may contain shared references. |
| 64 |
(module |
| 65 |
(type (shared (struct (field (ref null (shared any)))))) |
| 66 |
) |
| 67 |
|
| 68 |
;; Non-shared structs may contain shared references. |
| 69 |
(module |
| 70 |
(type (struct (field (ref null (shared any))))) |
| 71 |
) |
| 72 |
|
| 73 |
;; Struct instructions work on shared structs. |
| 74 |
(module |
| 75 |
(type $i8 (shared (struct (field (mut i8))))) |
| 76 |
(type $i32 (shared (struct (field (mut i32))))) |
| 77 |
(type $unshared (struct (field (mut i8)))) |
| 78 |
|
| 79 |
(func (struct.new $i8 (i32.const 0)) (drop)) |
| 80 |
|
| 81 |
(func (struct.new_default $i8) (drop)) |
| 82 |
|
| 83 |
(func (param (ref null $i8)) |
| 84 |
(struct.get_s $i8 0 (local.get 0)) (drop)) |
| 85 |
|
| 86 |
(func (param (ref null $i8)) |
| 87 |
(struct.get_u $i8 0 (local.get 0)) (drop)) |
| 88 |
|
| 89 |
(func (param (ref null $i32)) |
| 90 |
(struct.get $i32 0 (local.get 0)) (drop)) |
| 91 |
|
| 92 |
(func (param (ref null $i8)) |
| 93 |
(struct.set $i8 0 (local.get 0) (i32.const 0))) |
| 94 |
) |
| 95 |
|
| 96 |
;; Bottom types can be used as shared structs. |
| 97 |
(module |
| 98 |
(type $i8 (shared (struct (field (mut i8))))) |
| 99 |
(func (drop (struct.get_s $i8 0 (ref.null (shared none))))) |
| 100 |
(func (drop (struct.get_u $i8 0 (ref.null (shared none))))) |
| 101 |
(func (struct.set $i8 0 (ref.null (shared none)) (i32.const 0))) |
| 102 |
) |
| 103 |
|
| 104 |
;; Check that field-modifying instructions only work on mutable fields. |
| 105 |
(assert_invalid |
| 106 |
(module |
| 107 |
(type $s (shared (struct (field (ref (shared any)))))) |
| 108 |
(func (param $s (ref $s)) (param $a (ref (shared any))) (result (ref (shared any))) |
| 109 |
(struct.atomic.set seq_cst $s 0 (local.get $s) (local.get $a)) |
| 110 |
) |
| 111 |
) |
| 112 |
"field is immutable" |
| 113 |
) |
| 114 |
(assert_invalid |
| 115 |
(module |
| 116 |
(type $s (shared (struct (field i32)))) |
| 117 |
(func (param $s (ref $s)) (result i32) |
| 118 |
(struct.atomic.rmw.add seq_cst $s 0 (local.get $s) (i32.const 1)) |
| 119 |
) |
| 120 |
) |
| 121 |
"field is immutable" |
| 122 |
) |
| 123 |
(assert_invalid |
| 124 |
(module |
| 125 |
(type $s (shared (struct (field i64)))) |
| 126 |
(func (param $s (ref $s)) (result i64) |
| 127 |
(struct.atomic.rmw.sub seq_cst $s 0 (local.get $s) (i64.const 1)) |
| 128 |
) |
| 129 |
) |
| 130 |
"field is immutable" |
| 131 |
) |
| 132 |
(assert_invalid |
| 133 |
(module |
| 134 |
(type $s (shared (struct (field i32)))) |
| 135 |
(func (param $s (ref $s)) (result i32) |
| 136 |
(struct.atomic.rmw.and acq_rel $s 0 (local.get $s) (i32.const 1)) |
| 137 |
) |
| 138 |
) |
| 139 |
"field is immutable" |
| 140 |
) |
| 141 |
(assert_invalid |
| 142 |
(module |
| 143 |
(type $s (shared (struct (field i64)))) |
| 144 |
(func (param $s (ref $s)) (result i64) |
| 145 |
(struct.atomic.rmw.or acq_rel $s 0 (local.get $s) (i64.const 1)) |
| 146 |
) |
| 147 |
) |
| 148 |
"field is immutable" |
| 149 |
) |
| 150 |
(assert_invalid |
| 151 |
(module |
| 152 |
(type $s (shared (struct (field i32)))) |
| 153 |
(func (param $s (ref $s)) (result i32) |
| 154 |
(struct.atomic.rmw.xor seq_cst $s 0 (local.get $s) (i32.const 1)) |
| 155 |
) |
| 156 |
) |
| 157 |
"field is immutable" |
| 158 |
) |
| 159 |
(assert_invalid |
| 160 |
(module |
| 161 |
(type $s (shared (struct (field (ref (shared any)))))) |
| 162 |
(func (param $s (ref $s)) (param $a (ref (shared any))) (result (ref (shared any))) |
| 163 |
(struct.atomic.rmw.xchg seq_cst $s 0 (local.get $s) (local.get $a)) |
| 164 |
) |
| 165 |
) |
| 166 |
"field is immutable" |
| 167 |
) |
| 168 |
(assert_invalid |
| 169 |
(module |
| 170 |
(type $s (shared (struct (field (ref (shared eq)))))) |
| 171 |
(func (param $s (ref $s)) (param $e1 (ref (shared eq))) (param $e2 (ref (shared eq))) (result (ref (shared eq))) |
| 172 |
(struct.atomic.rmw.cmpxchg acq_rel $s 0 (local.get $s) (local.get $e1) (local.get $e2)) |
| 173 |
) |
| 174 |
) |
| 175 |
"field is immutable" |
| 176 |
) |
| 177 |
|
| 178 |
;; Exhaustively check `struct.atomic.rmw.*` instructions. |
| 179 |
(module |
| 180 |
(type $s (shared (struct |
| 181 |
(field $i8 (mut i8)) |
| 182 |
(field $i16 (mut i16)) |
| 183 |
(field $i32 (mut i32)) |
| 184 |
(field $i64 (mut i64)) |
| 185 |
(field $anyref (mut (ref null (shared any)))) |
| 186 |
(field $eqref (mut (ref null (shared eq))))))) |
| 187 |
(func (export "struct-atomic-get-i32-seq_cst") (param $x (ref null $s)) (result i32) |
| 188 |
local.get $x |
| 189 |
struct.atomic.get seq_cst $s $i32) |
| 190 |
(func (export "struct-atomic-get-i64-seq_cst") (param $x (ref null $s)) (result i64) |
| 191 |
local.get $x |
| 192 |
struct.atomic.get seq_cst $s $i64) |
| 193 |
(func (export "struct-atomic-get-anyref-seq_cst") (param $x (ref null $s)) (result (ref null (shared any))) |
| 194 |
local.get $x |
| 195 |
struct.atomic.get seq_cst $s $anyref) |
| 196 |
(func (export "struct-atomic-get-i32-acq_rel") (param $x (ref null $s)) (result i32) |
| 197 |
local.get $x |
| 198 |
struct.atomic.get acq_rel $s $i32) |
| 199 |
(func (export "struct-atomic-get-i64-acq_rel") (param $x (ref null $s)) (result i64) |
| 200 |
local.get $x |
| 201 |
struct.atomic.get acq_rel $s $i64) |
| 202 |
(func (export "struct-atomic-get-anyref-acq_rel") (param $x (ref null $s)) (result (ref null (shared any))) |
| 203 |
local.get $x |
| 204 |
struct.atomic.get acq_rel $s $anyref) |
| 205 |
(func (export "struct-atomic-get_s-i8-seq_cst") (param $x (ref null $s)) (result i32) |
| 206 |
local.get $x |
| 207 |
struct.atomic.get_s seq_cst $s $i8) |
| 208 |
(func (export "struct-atomic-get_s-i16-seq_cst") (param $x (ref null $s)) (result i32) |
| 209 |
local.get $x |
| 210 |
struct.atomic.get_s seq_cst $s $i16) |
| 211 |
(func (export "struct-atomic-get_s-i8-acq_rel") (param $x (ref null $s)) (result i32) |
| 212 |
local.get $x |
| 213 |
struct.atomic.get_s acq_rel $s $i8) |
| 214 |
(func (export "struct-atomic-get_s-i16-acq_rel") (param $x (ref null $s)) (result i32) |
| 215 |
local.get $x |
| 216 |
struct.atomic.get_s acq_rel $s $i16) |
| 217 |
(func (export "struct-atomic-get_u-i8-seq_cst") (param $x (ref null $s)) (result i32) |
| 218 |
local.get $x |
| 219 |
struct.atomic.get_u seq_cst $s $i8) |
| 220 |
(func (export "struct-atomic-get_u-i16-seq_cst") (param $x (ref null $s)) (result i32) |
| 221 |
local.get $x |
| 222 |
struct.atomic.get_u seq_cst $s $i16) |
| 223 |
(func (export "struct-atomic-get_u-i8-acq_rel") (param $x (ref null $s)) (result i32) |
| 224 |
local.get $x |
| 225 |
struct.atomic.get_u acq_rel $s $i8) |
| 226 |
(func (export "struct-atomic-get_u-i16-acq_rel") (param $x (ref null $s)) (result i32) |
| 227 |
local.get $x |
| 228 |
struct.atomic.get_u acq_rel $s $i16) |
| 229 |
(func (export "struct-atomic-set-i8-seq_cst") (param $x (ref null $s)) (param $y i32) |
| 230 |
local.get $x |
| 231 |
local.get $y |
| 232 |
struct.atomic.set seq_cst $s $i8) |
| 233 |
(func (export "struct-atomic-set-i16-seq_cst") (param $x (ref null $s)) (param $y i32) |
| 234 |
local.get $x |
| 235 |
local.get $y |
| 236 |
struct.atomic.set seq_cst $s $i16) |
| 237 |
(func (export "struct-atomic-set-i32-seq_cst") (param $x (ref null $s)) (param $y i32) |
| 238 |
local.get $x |
| 239 |
local.get $y |
| 240 |
struct.atomic.set seq_cst $s $i32) |
| 241 |
(func (export "struct-atomic-set-i64-seq_cst") (param $x (ref null $s)) (param $y i64) |
| 242 |
local.get $x |
| 243 |
local.get $y |
| 244 |
struct.atomic.set seq_cst $s $i64) |
| 245 |
(func (export "struct-atomic-set-anyref-seq_cst") (param $x (ref null $s)) (param $y (ref null (shared any))) |
| 246 |
local.get $x |
| 247 |
local.get $y |
| 248 |
struct.atomic.set seq_cst $s $anyref) |
| 249 |
(func (export "struct-atomic-set-i8-acq_rel") (param $x (ref null $s)) (param $y i32) |
| 250 |
local.get $x |
| 251 |
local.get $y |
| 252 |
struct.atomic.set acq_rel $s $i8) |
| 253 |
(func (export "struct-atomic-set-i16-acq_rel") (param $x (ref null $s)) (param $y i32) |
| 254 |
local.get $x |
| 255 |
local.get $y |
| 256 |
struct.atomic.set acq_rel $s $i16) |
| 257 |
(func (export "struct-atomic-set-i32-acq_rel") (param $x (ref null $s)) (param $y i32) |
| 258 |
local.get $x |
| 259 |
local.get $y |
| 260 |
struct.atomic.set acq_rel $s $i32) |
| 261 |
(func (export "struct-atomic-set-i64-acq_rel") (param $x (ref null $s)) (param $y i64) |
| 262 |
local.get $x |
| 263 |
local.get $y |
| 264 |
struct.atomic.set acq_rel $s $i64) |
| 265 |
(func (export "struct-atomic-set-anyref-acq_rel") (param $x (ref null $s)) (param $y (ref null (shared any))) |
| 266 |
local.get $x |
| 267 |
local.get $y |
| 268 |
struct.atomic.set acq_rel $s $anyref) |
| 269 |
(func (export "struct-atomic-rmw.add-i32-seq_cst") (param $x (ref null $s)) (param $y i32) (result i32) |
| 270 |
local.get $x |
| 271 |
local.get $y |
| 272 |
struct.atomic.rmw.add seq_cst $s $i32) |
| 273 |
(func (export "struct-atomic-rmw.add-i64-seq_cst") (param $x (ref null $s)) (param $y i64) (result i64) |
| 274 |
local.get $x |
| 275 |
local.get $y |
| 276 |
struct.atomic.rmw.add seq_cst $s $i64) |
| 277 |
(func (export "struct-atomic-rmw.add-i32-acq_rel") (param $x (ref null $s)) (param $y i32) (result i32) |
| 278 |
local.get $x |
| 279 |
local.get $y |
| 280 |
struct.atomic.rmw.add acq_rel $s $i32) |
| 281 |
(func (export "struct-atomic-rmw.add-i64-acq_rel") (param $x (ref null $s)) (param $y i64) (result i64) |
| 282 |
local.get $x |
| 283 |
local.get $y |
| 284 |
struct.atomic.rmw.add acq_rel $s $i64) |
| 285 |
(func (export "struct-atomic-rmw.sub-i32-seq_cst") (param $x (ref null $s)) (param $y i32) (result i32) |
| 286 |
local.get $x |
| 287 |
local.get $y |
| 288 |
struct.atomic.rmw.sub seq_cst $s $i32) |
| 289 |
(func (export "struct-atomic-rmw.sub-i64-seq_cst") (param $x (ref null $s)) (param $y i64) (result i64) |
| 290 |
local.get $x |
| 291 |
local.get $y |
| 292 |
struct.atomic.rmw.sub seq_cst $s $i64) |
| 293 |
(func (export "struct-atomic-rmw.sub-i32-acq_rel") (param $x (ref null $s)) (param $y i32) (result i32) |
| 294 |
local.get $x |
| 295 |
local.get $y |
| 296 |
struct.atomic.rmw.sub acq_rel $s $i32) |
| 297 |
(func (export "struct-atomic-rmw.sub-i64-acq_rel") (param $x (ref null $s)) (param $y i64) (result i64) |
| 298 |
local.get $x |
| 299 |
local.get $y |
| 300 |
struct.atomic.rmw.sub acq_rel $s $i64) |
| 301 |
(func (export "struct-atomic-rmw.and-i32-seq_cst") (param $x (ref null $s)) (param $y i32) (result i32) |
| 302 |
local.get $x |
| 303 |
local.get $y |
| 304 |
struct.atomic.rmw.and seq_cst $s $i32) |
| 305 |
(func (export "struct-atomic-rmw.and-i64-seq_cst") (param $x (ref null $s)) (param $y i64) (result i64) |
| 306 |
local.get $x |
| 307 |
local.get $y |
| 308 |
struct.atomic.rmw.and seq_cst $s $i64) |
| 309 |
(func (export "struct-atomic-rmw.and-i32-acq_rel") (param $x (ref null $s)) (param $y i32) (result i32) |
| 310 |
local.get $x |
| 311 |
local.get $y |
| 312 |
struct.atomic.rmw.and acq_rel $s $i32) |
| 313 |
(func (export "struct-atomic-rmw.and-i64-acq_rel") (param $x (ref null $s)) (param $y i64) (result i64) |
| 314 |
local.get $x |
| 315 |
local.get $y |
| 316 |
struct.atomic.rmw.and acq_rel $s $i64) |
| 317 |
(func (export "struct-atomic-rmw.or-i32-seq_cst") (param $x (ref null $s)) (param $y i32) (result i32) |
| 318 |
local.get $x |
| 319 |
local.get $y |
| 320 |
struct.atomic.rmw.or seq_cst $s $i32) |
| 321 |
(func (export "struct-atomic-rmw.or-i64-seq_cst") (param $x (ref null $s)) (param $y i64) (result i64) |
| 322 |
local.get $x |
| 323 |
local.get $y |
| 324 |
struct.atomic.rmw.or seq_cst $s $i64) |
| 325 |
(func (export "struct-atomic-rmw.or-i32-acq_rel") (param $x (ref null $s)) (param $y i32) (result i32) |
| 326 |
local.get $x |
| 327 |
local.get $y |
| 328 |
struct.atomic.rmw.or acq_rel $s $i32) |
| 329 |
(func (export "struct-atomic-rmw.or-i64-acq_rel") (param $x (ref null $s)) (param $y i64) (result i64) |
| 330 |
local.get $x |
| 331 |
local.get $y |
| 332 |
struct.atomic.rmw.or acq_rel $s $i64) |
| 333 |
(func (export "struct-atomic-rmw.xor-i32-seq_cst") (param $x (ref null $s)) (param $y i32) (result i32) |
| 334 |
local.get $x |
| 335 |
local.get $y |
| 336 |
struct.atomic.rmw.xor seq_cst $s $i32) |
| 337 |
(func (export "struct-atomic-rmw.xor-i64-seq_cst") (param $x (ref null $s)) (param $y i64) (result i64) |
| 338 |
local.get $x |
| 339 |
local.get $y |
| 340 |
struct.atomic.rmw.xor seq_cst $s $i64) |
| 341 |
(func (export "struct-atomic-rmw.xor-i32-acq_rel") (param $x (ref null $s)) (param $y i32) (result i32) |
| 342 |
local.get $x |
| 343 |
local.get $y |
| 344 |
struct.atomic.rmw.xor acq_rel $s $i32) |
| 345 |
(func (export "struct-atomic-rmw.xor-i64-acq_rel") (param $x (ref null $s)) (param $y i64) (result i64) |
| 346 |
local.get $x |
| 347 |
local.get $y |
| 348 |
struct.atomic.rmw.xor acq_rel $s $i64) |
| 349 |
(func (export "struct-atomic-rmw.xchg-i32-seq_cst") (param $x (ref null $s)) (param $y i32) (result i32) |
| 350 |
local.get $x |
| 351 |
local.get $y |
| 352 |
struct.atomic.rmw.xchg seq_cst $s $i32) |
| 353 |
(func (export "struct-atomic-rmw.xchg-i64-seq_cst") (param $x (ref null $s)) (param $y i64) (result i64) |
| 354 |
local.get $x |
| 355 |
local.get $y |
| 356 |
struct.atomic.rmw.xchg seq_cst $s $i64) |
| 357 |
(func (export "struct-atomic-rmw.xchg-anyref-seq_cst") (param $x (ref null $s)) (param $y (ref null (shared any))) (result (ref null (shared any))) |
| 358 |
local.get $x |
| 359 |
local.get $y |
| 360 |
struct.atomic.rmw.xchg seq_cst $s $anyref) |
| 361 |
(func (export "struct-atomic-rmw.xchg-i32-acq_rel") (param $x (ref null $s)) (param $y i32) (result i32) |
| 362 |
local.get $x |
| 363 |
local.get $y |
| 364 |
struct.atomic.rmw.xchg acq_rel $s $i32) |
| 365 |
(func (export "struct-atomic-rmw.xchg-i64-acq_rel") (param $x (ref null $s)) (param $y i64) (result i64) |
| 366 |
local.get $x |
| 367 |
local.get $y |
| 368 |
struct.atomic.rmw.xchg acq_rel $s $i64) |
| 369 |
(func (export "struct-atomic-rmw.xchg-anyref-acq_rel") (param $x (ref null $s)) (param $y (ref null (shared any))) (result (ref null (shared any))) |
| 370 |
local.get $x |
| 371 |
local.get $y |
| 372 |
struct.atomic.rmw.xchg acq_rel $s $anyref) |
| 373 |
(func (export "struct-atomic-rmw.cmpxchg-i32-seq_cst") (param $x (ref null $s)) (param $y i32) (param $z i32) (result i32) |
| 374 |
local.get $x |
| 375 |
local.get $y |
| 376 |
local.get $z |
| 377 |
struct.atomic.rmw.cmpxchg seq_cst $s $i32) |
| 378 |
(func (export "struct-atomic-rmw.cmpxchg-i64-seq_cst") (param $x (ref null $s)) (param $y i64) (param $z i64) (result i64) |
| 379 |
local.get $x |
| 380 |
local.get $y |
| 381 |
local.get $z |
| 382 |
struct.atomic.rmw.cmpxchg seq_cst $s $i64) |
| 383 |
(func (export "struct-atomic-rmw.cmpxchg-eqref-seq_cst") (param $x (ref null $s)) (param $y (ref null (shared eq))) (param $z (ref null (shared eq))) (result (ref null (shared eq))) |
| 384 |
local.get $x |
| 385 |
local.get $y |
| 386 |
local.get $z |
| 387 |
struct.atomic.rmw.cmpxchg seq_cst $s $eqref) |
| 388 |
(func (export "struct-atomic-rmw.cmpxchg-i32-acq_rel") (param $x (ref null $s)) (param $y i32) (param $z i32) (result i32) |
| 389 |
local.get $x |
| 390 |
local.get $y |
| 391 |
local.get $z |
| 392 |
struct.atomic.rmw.cmpxchg acq_rel $s $i32) |
| 393 |
(func (export "struct-atomic-rmw.cmpxchg-i64-acq_rel") (param $x (ref null $s)) (param $y i64) (param $z i64) (result i64) |
| 394 |
local.get $x |
| 395 |
local.get $y |
| 396 |
local.get $z |
| 397 |
struct.atomic.rmw.cmpxchg acq_rel $s $i64) |
| 398 |
(func (export "struct-atomic-rmw.cmpxchg-eqref-acq_rel") (param $x (ref null $s)) (param $y (ref null (shared eq))) (param $z (ref null (shared eq))) (result (ref null (shared eq))) |
| 399 |
local.get $x |
| 400 |
local.get $y |
| 401 |
local.get $z |
| 402 |
struct.atomic.rmw.cmpxchg acq_rel $s $eqref) |
| 403 |
) |
| 404 |
|
| 405 |
(assert_invalid (; get, i8 ;) |
| 406 |
(module |
| 407 |
(type $s (shared (struct (field $i8 (mut i8))))) |
| 408 |
(func (param $x (ref null $s)) (result i32) |
| 409 |
local.get $x |
| 410 |
struct.atomic.get seq_cst $s $i8) |
| 411 |
) |
| 412 |
"non-packed storage type" |
| 413 |
) |
| 414 |
(assert_invalid (; get_s, i32 ;) |
| 415 |
(module |
| 416 |
(type $s (shared (struct (field $i32 (mut i32))))) |
| 417 |
(func (param $x (ref null $s)) (result i32) |
| 418 |
local.get $x |
| 419 |
struct.atomic.get_s seq_cst $s $i32) |
| 420 |
) |
| 421 |
"non-packed storage types" |
| 422 |
) |
| 423 |
(assert_invalid (; get_s, anyref ;) |
| 424 |
(module |
| 425 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 426 |
(func (param $x (ref null $s)) (result (ref null (shared any))) |
| 427 |
local.get $x |
| 428 |
struct.atomic.get_s seq_cst $s $anyref) |
| 429 |
) |
| 430 |
"non-packed storage types" |
| 431 |
) |
| 432 |
(assert_invalid (; get_u, i32 ;) |
| 433 |
(module |
| 434 |
(type $s (shared (struct (field $i32 (mut i32))))) |
| 435 |
(func (param $x (ref null $s)) (result i32) |
| 436 |
local.get $x |
| 437 |
struct.atomic.get_u seq_cst $s $i32) |
| 438 |
) |
| 439 |
"non-packed storage types" |
| 440 |
) |
| 441 |
(assert_invalid (; get_u, anyref ;) |
| 442 |
(module |
| 443 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 444 |
(func (param $x (ref null $s)) (result (ref null (shared any))) |
| 445 |
local.get $x |
| 446 |
struct.atomic.get_u seq_cst $s $anyref) |
| 447 |
) |
| 448 |
"non-packed storage types" |
| 449 |
) |
| 450 |
(assert_invalid (; rmw.add, anyref ;) |
| 451 |
(module |
| 452 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 453 |
(func (param $x (ref null $s)) (param $y (ref null (shared any))) (result (ref null (shared any))) |
| 454 |
local.get $x |
| 455 |
local.get $y |
| 456 |
struct.atomic.rmw.add seq_cst $s $anyref) |
| 457 |
) |
| 458 |
"invalid type" |
| 459 |
) |
| 460 |
(assert_invalid (; rmw.sub, anyref ;) |
| 461 |
(module |
| 462 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 463 |
(func (param $x (ref null $s)) (param $y (ref null (shared any))) (result (ref null (shared any))) |
| 464 |
local.get $x |
| 465 |
local.get $y |
| 466 |
struct.atomic.rmw.sub seq_cst $s $anyref) |
| 467 |
) |
| 468 |
"invalid type" |
| 469 |
) |
| 470 |
(assert_invalid (; rmw.and, anyref ;) |
| 471 |
(module |
| 472 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 473 |
(func (param $x (ref null $s)) (param $y (ref null (shared any))) (result (ref null (shared any))) |
| 474 |
local.get $x |
| 475 |
local.get $y |
| 476 |
struct.atomic.rmw.and seq_cst $s $anyref) |
| 477 |
) |
| 478 |
"invalid type" |
| 479 |
) |
| 480 |
(assert_invalid (; rmw.or, anyref ;) |
| 481 |
(module |
| 482 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 483 |
(func (param $x (ref null $s)) (param $y (ref null (shared any))) (result (ref null (shared any))) |
| 484 |
local.get $x |
| 485 |
local.get $y |
| 486 |
struct.atomic.rmw.or seq_cst $s $anyref) |
| 487 |
) |
| 488 |
"invalid type" |
| 489 |
) |
| 490 |
(assert_invalid (; rmw.xor, anyref ;) |
| 491 |
(module |
| 492 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 493 |
(func (param $x (ref null $s)) (param $y (ref null (shared any))) (result (ref null (shared any))) |
| 494 |
local.get $x |
| 495 |
local.get $y |
| 496 |
struct.atomic.rmw.xor seq_cst $s $anyref) |
| 497 |
) |
| 498 |
"invalid type" |
| 499 |
) |
| 500 |
(assert_invalid (; rmw.xchg, i8 ;) |
| 501 |
(module |
| 502 |
(type $s (shared (struct (field $i8 (mut i8))))) |
| 503 |
(func (param $x (ref null $s)) (param $y i32) (result i32) |
| 504 |
local.get $x |
| 505 |
local.get $y |
| 506 |
struct.atomic.rmw.xchg seq_cst $s $i8) |
| 507 |
) |
| 508 |
"invalid type" |
| 509 |
) |
| 510 |
(assert_invalid (; rmw.cmpxchg, i8 ;) |
| 511 |
(module |
| 512 |
(type $s (shared (struct (field $i8 (mut i8))))) |
| 513 |
(func (param $x (ref null $s)) (param $y i32) (param $z i32) (result i32) |
| 514 |
local.get $x |
| 515 |
local.get $y |
| 516 |
local.get $z |
| 517 |
struct.atomic.rmw.cmpxchg seq_cst $s $i8) |
| 518 |
) |
| 519 |
"invalid type" |
| 520 |
) |
| 521 |
(assert_invalid (; rmw.cmpxchg, anyref ;) |
| 522 |
(module |
| 523 |
(type $s (shared (struct (field $anyref (mut (ref null (shared any))))))) |
| 524 |
(func (param $x (ref null $s)) (param $y (ref null (shared any))) (param $z (ref null (shared any))) (result (ref null (shared any))) |
| 525 |
local.get $x |
| 526 |
local.get $y |
| 527 |
local.get $z |
| 528 |
struct.atomic.rmw.cmpxchg seq_cst $s $anyref) |
| 529 |
) |
| 530 |
"invalid type" |
| 531 |
) |
| 532 |
|
| 533 |
(assert_invalid |
| 534 |
(module |
| 535 |
(type $s (shared (struct (field $f f32)))) |
| 536 |
(func |
| 537 |
unreachable |
| 538 |
struct.atomic.get seq_cst $s $f |
| 539 |
drop |
| 540 |
)) |
| 541 |
"invalid type: `struct.atomic.get` only allows `i32`, `i64` and subtypes of `anyref`" |
| 542 |
) |
| 543 |
|
| 544 |
(assert_invalid |
| 545 |
(module |
| 546 |
(type $s (shared (struct (field $f (ref (shared func)))))) |
| 547 |
(func |
| 548 |
unreachable |
| 549 |
struct.atomic.get seq_cst $s $f |
| 550 |
drop |
| 551 |
)) |
| 552 |
"invalid type: `struct.atomic.get` only allows `i32`, `i64` and subtypes of `anyref`" |
| 553 |
) |
| 554 |
|
| 555 |
(assert_invalid |
| 556 |
(module |
| 557 |
(type $s (shared (struct (field $f i8)))) |
| 558 |
(func |
| 559 |
unreachable |
| 560 |
struct.atomic.get seq_cst $s $f |
| 561 |
drop |
| 562 |
)) |
| 563 |
"can only use struct `get` with non-packed storage types" |
| 564 |
) |
| 565 |
|
| 566 |
(assert_invalid |
| 567 |
(module |
| 568 |
(type $s (shared (struct (field $f (mut (ref (shared extern))))))) |
| 569 |
(func |
| 570 |
unreachable |
| 571 |
struct.atomic.set seq_cst $s $f |
| 572 |
)) |
| 573 |
"invalid type: `struct.atomic.set` only allows `i8`, `i16`, `i32`, `i64` and subtypes of `anyref`" |
| 574 |
) |