diff options
author | Thomas Lively <tlively@google.com> | 2024-06-25 12:39:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-25 12:39:05 -0700 |
commit | 654ee6e2504f11fb0e982a2cf276bafa750f694b (patch) | |
tree | e955f95d009f2df626e3d2ff07154ec56d5d6265 /test/spec | |
parent | 4cd8b61c5d4817f753a54ef9f501db66969e310f (diff) | |
download | binaryen-654ee6e2504f11fb0e982a2cf276bafa750f694b.tar.gz binaryen-654ee6e2504f11fb0e982a2cf276bafa750f694b.tar.bz2 binaryen-654ee6e2504f11fb0e982a2cf276bafa750f694b.zip |
[threads] Validate shared-polymorphic instructions (#6702)
Such as `ref.eq`, `i31.get_{s,u}`, and `array.len`. Also validate that
struct and array operations work on shared structs and arrays.
Diffstat (limited to 'test/spec')
-rw-r--r-- | test/spec/shared-array.wast | 46 | ||||
-rw-r--r-- | test/spec/shared-polymorphism.wast | 12 | ||||
-rw-r--r-- | test/spec/shared-struct.wast | 23 |
3 files changed, 81 insertions, 0 deletions
diff --git a/test/spec/shared-array.wast b/test/spec/shared-array.wast index a687c1d36..7aa387731 100644 --- a/test/spec/shared-array.wast +++ b/test/spec/shared-array.wast @@ -67,3 +67,49 @@ (module (type (array (ref null (shared any)))) ) + +;; Array instructions work on shared arrays. +(module + (type $i8 (shared (array (mut i8)))) + (type $i32 (shared (array (mut i32)))) + (type $unshared (array (mut i8))) + + (data) + (elem) + + (func (array.new $i8 (i32.const 0) (i32.const 0)) (drop)) + + (func (array.new_default $i8 (i32.const 0)) (drop)) + + (func (array.new_fixed $i8 0) (drop)) + + (func (param (ref null $i8)) + (array.get_s $i8 (local.get 0) (i32.const 0)) (drop)) + + (func (param (ref null $i8)) + (array.get_u $i8 (local.get 0) (i32.const 0)) (drop)) + + (func (param (ref null $i32)) + (array.get $i32 (local.get 0) (i32.const 0)) (drop)) + + (func (param (ref null $i8)) + (array.set $i8 (local.get 0) (i32.const 0) (i32.const 0))) + + (func (param (ref null $i8) (ref null $i8)) + (array.copy $i8 $i8 (local.get 0) (i32.const 0) (local.get 1) (i32.const 0) (i32.const 0))) + + (func (param (ref null $i8) (ref null $unshared)) + (array.copy $i8 $unshared (local.get 0) (i32.const 0) (local.get 1) (i32.const 0) (i32.const 0))) + + (func (param (ref null $unshared) (ref null $i8)) + (array.copy $unshared $i8 (local.get 0) (i32.const 0) (local.get 1) (i32.const 0) (i32.const 0))) + + (func (param (ref null $i8)) + (array.fill $i8 (local.get 0) (i32.const 0) (i32.const 0) (i32.const 0))) + + (func (param (ref null $i8)) + (array.init_data $i8 0 (local.get 0) (i32.const 0) (i32.const 0) (i32.const 0))) + + (func (param (ref null $i8)) + (array.init_data $i8 0 (local.get 0) (i32.const 0) (i32.const 0) (i32.const 0))) +) diff --git a/test/spec/shared-polymorphism.wast b/test/spec/shared-polymorphism.wast new file mode 100644 index 000000000..547829f11 --- /dev/null +++ b/test/spec/shared-polymorphism.wast @@ -0,0 +1,12 @@ +;; Some instructions are shared-polymorphic and work with shared or unshared +;; references. +(module + (func (drop (ref.eq (ref.null (shared none)) (ref.null (shared none))))) + (func (drop (ref.eq (ref.null (shared none)) (ref.null none)))) + (func (drop (ref.eq (ref.null none) (ref.null (shared none))))) + + (func (param (ref null (shared i31))) (drop (i31.get_s (local.get 0)))) + (func (param (ref null (shared i31))) (drop (i31.get_u (local.get 0)))) + + (func (param (ref null (shared array))) (drop (array.len (local.get 0)))) +) diff --git a/test/spec/shared-struct.wast b/test/spec/shared-struct.wast index b2c82caff..28139bb28 100644 --- a/test/spec/shared-struct.wast +++ b/test/spec/shared-struct.wast @@ -67,3 +67,26 @@ (module (type (struct (ref null (shared any)))) ) + +;; Struct instructions work on shared structs. +(module + (type $i8 (shared (struct (mut i8)))) + (type $i32 (shared (struct (mut i32)))) + (type $unshared (struct (mut i8))) + + (func (struct.new $i8 (i32.const 0)) (drop)) + + (func (struct.new_default $i8) (drop)) + + (func (param (ref null $i8)) + (struct.get_s $i8 0 (local.get 0)) (drop)) + + (func (param (ref null $i8)) + (struct.get_u $i8 0 (local.get 0)) (drop)) + + (func (param (ref null $i32)) + (struct.get $i32 0 (local.get 0)) (drop)) + + (func (param (ref null $i8)) + (struct.set $i8 0 (local.get 0) (i32.const 0))) +) |