diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/heap-types.wast | 31 | ||||
-rw-r--r-- | test/heap-types.wast.from-wast | 35 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary | 33 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary.noDebugInfo | 33 | ||||
-rw-r--r-- | test/lit/binary/heap-types.wast | 150 | ||||
-rw-r--r-- | test/lit/passes/heap2local.wast | 25 | ||||
-rw-r--r-- | test/lit/passes/precompute-gc.wast | 20 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.txt | 23 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.wast | 19 |
9 files changed, 334 insertions, 35 deletions
diff --git a/test/heap-types.wast b/test/heap-types.wast index be6da5330..3c0a5a0ef 100644 --- a/test/heap-types.wast +++ b/test/heap-types.wast @@ -422,4 +422,35 @@ ) ) ) + (func $static-constructions + (drop + (struct.new_default $struct.A) + ) + (drop + (struct.new $struct.A + (i32.const 1) + (f32.const 2.345) + (f64.const 3.14159) + ) + ) + (drop + (array.new $vector + (f64.const 3.14159) + (i32.const 3) + ) + ) + (drop + (array.new_default $matrix + (i32.const 10) + ) + ) + (drop + (array.init_static $vector + (f64.const 1) + (f64.const 2) + (f64.const 4) + (f64.const 8) + ) + ) + ) ) diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast index 9ca3b580b..f4e7245bb 100644 --- a/test/heap-types.wast.from-wast +++ b/test/heap-types.wast.from-wast @@ -1,11 +1,11 @@ (module (type $struct.A (struct (field i32) (field f32) (field $named f64))) (type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A))))) - (type $none_=>_none (func)) (type $vector (array (mut f64))) + (type $none_=>_none (func)) (type $grandchild (struct (field i32) (field i64))) - (type $struct.C (struct (field $named-mut (mut f32)))) (type $matrix (array (mut (ref null $vector)))) + (type $struct.C (struct (field $named-mut (mut f32)))) (type $parent (struct )) (type $child (struct (field i32))) (type $bytes (array (mut i8))) @@ -521,4 +521,35 @@ ) ) ) + (func $static-constructions + (drop + (struct.new_default $struct.A) + ) + (drop + (struct.new $struct.A + (i32.const 1) + (f32.const 2.3450000286102295) + (f64.const 3.14159) + ) + ) + (drop + (array.new $vector + (f64.const 3.14159) + (i32.const 3) + ) + ) + (drop + (array.new_default $matrix + (i32.const 10) + ) + ) + (drop + (array.init_static $vector + (f64.const 1) + (f64.const 2) + (f64.const 4) + (f64.const 8) + ) + ) + ) ) diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary index 7ac581848..f6b364b14 100644 --- a/test/heap-types.wast.fromBinary +++ b/test/heap-types.wast.fromBinary @@ -1,8 +1,8 @@ (module (type $struct.A (struct (field i32) (field f32) (field $named f64))) (type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A))))) - (type $none_=>_none (func)) (type $vector (array (mut f64))) + (type $none_=>_none (func)) (type $grandchild (struct (field i32) (field i64))) (type $matrix (array (mut (ref null $vector)))) (type $struct.C (struct (field $named-mut (mut f32)))) @@ -476,5 +476,36 @@ ) ) ) + (func $static-constructions + (drop + (struct.new_default $struct.A) + ) + (drop + (struct.new $struct.A + (i32.const 1) + (f32.const 2.3450000286102295) + (f64.const 3.14159) + ) + ) + (drop + (array.new $vector + (f64.const 3.14159) + (i32.const 3) + ) + ) + (drop + (array.new_default $matrix + (i32.const 10) + ) + ) + (drop + (array.init_static $vector + (f64.const 1) + (f64.const 2) + (f64.const 4) + (f64.const 8) + ) + ) + ) ) diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo index 6a8991150..c33ba0cc8 100644 --- a/test/heap-types.wast.fromBinary.noDebugInfo +++ b/test/heap-types.wast.fromBinary.noDebugInfo @@ -1,8 +1,8 @@ (module (type ${i32_f32_f64} (struct (field i32) (field f32) (field f64))) (type ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|} (struct (field i8) (field (mut i16)) (field (ref ${i32_f32_f64})) (field (mut (ref ${i32_f32_f64}))))) - (type $none_=>_none (func)) (type $[mut:f64] (array (mut f64))) + (type $none_=>_none (func)) (type ${i32_i64} (struct (field i32) (field i64))) (type $[mut:ref?|[mut:f64]|] (array (mut (ref null $[mut:f64])))) (type ${mut:f32} (struct (field (mut f32)))) @@ -476,5 +476,36 @@ ) ) ) + (func $23 + (drop + (struct.new_default ${i32_f32_f64}) + ) + (drop + (struct.new ${i32_f32_f64} + (i32.const 1) + (f32.const 2.3450000286102295) + (f64.const 3.14159) + ) + ) + (drop + (array.new $[mut:f64] + (f64.const 3.14159) + (i32.const 3) + ) + ) + (drop + (array.new_default $[mut:ref?|[mut:f64]|] + (i32.const 10) + ) + ) + (drop + (array.init_static $[mut:f64] + (f64.const 1) + (f64.const 2) + (f64.const 4) + (f64.const 8) + ) + ) + ) ) diff --git a/test/lit/binary/heap-types.wast b/test/lit/binary/heap-types.wast new file mode 100644 index 000000000..f455d7376 --- /dev/null +++ b/test/lit/binary/heap-types.wast @@ -0,0 +1,150 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. + +;; Check that heap types are emitted properly in the binary format. This file +;; contains small modules that each use a single instruction with a heap type. +;; If we forgot to update collectHeapTypes then we would not write out their +;; type, and hit an error during --roundtrip. + +;; RUN: foreach %s %t wasm-opt -all --roundtrip -S -o - | filecheck %s +;; RUN: foreach %s %t wasm-opt -all --roundtrip -S --nominal -o - | filecheck %s --check-prefix NOMNL + +(module + ;; CHECK: (type $struct.A (struct (field i32))) + ;; NOMNL: (type $struct.A (struct (field i32))) + (type $struct.A (struct i32)) + ;; NOMNL: (type $struct.B (struct (field i32))) + (type $struct.B (struct i32)) + ;; CHECK: (func $test + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.test_static $struct.A + ;; CHECK-NEXT: (ref.null $struct.A) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; NOMNL: (func $test + ;; NOMNL-NEXT: (drop + ;; NOMNL-NEXT: (ref.test_static $struct.B + ;; NOMNL-NEXT: (ref.null $struct.A) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + (func $test + (drop + (ref.test_static $struct.B (ref.null $struct.A)) + ) + ) +) + +(module + ;; CHECK: (type $struct.A (struct (field i32))) + ;; NOMNL: (type $struct.A (struct (field i32))) + (type $struct.A (struct i32)) + ;; NOMNL: (type $struct.B (struct (field i32))) + (type $struct.B (struct i32)) + ;; CHECK: (func $test + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.cast_static $struct.A + ;; CHECK-NEXT: (ref.null $struct.A) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; NOMNL: (func $test + ;; NOMNL-NEXT: (drop + ;; NOMNL-NEXT: (ref.cast_static $struct.B + ;; NOMNL-NEXT: (ref.null $struct.A) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + (func $test + (drop + (ref.cast_static $struct.B (ref.null $struct.A)) + ) + ) +) + +(module + ;; CHECK: (type $struct.A (struct (field i32))) + ;; NOMNL: (type $struct.A (struct (field i32))) + (type $struct.A (struct i32)) + ;; CHECK: (func $test + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (struct.new_default $struct.A) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; NOMNL: (func $test + ;; NOMNL-NEXT: (drop + ;; NOMNL-NEXT: (struct.new_default $struct.A) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + (func $test + (drop + (struct.new_default $struct.A) + ) + ) +) + +(module + ;; CHECK: (type $vector (array (mut f64))) + ;; NOMNL: (type $vector (array (mut f64))) + (type $vector (array (mut f64))) + ;; CHECK: (func $test + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (array.new $vector + ;; CHECK-NEXT: (f64.const 3.14159) + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; NOMNL: (func $test + ;; NOMNL-NEXT: (drop + ;; NOMNL-NEXT: (array.new $vector + ;; NOMNL-NEXT: (f64.const 3.14159) + ;; NOMNL-NEXT: (i32.const 3) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + (func $test + (drop + (array.new $vector + (f64.const 3.14159) + (i32.const 3) + ) + ) + ) +) + +(module + ;; CHECK: (type $vector (array (mut f64))) + ;; NOMNL: (type $vector (array (mut f64))) + (type $vector (array (mut f64))) + ;; CHECK: (func $test + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (array.init_static $vector + ;; CHECK-NEXT: (f64.const 1) + ;; CHECK-NEXT: (f64.const 2) + ;; CHECK-NEXT: (f64.const 4) + ;; CHECK-NEXT: (f64.const 8) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; NOMNL: (func $test + ;; NOMNL-NEXT: (drop + ;; NOMNL-NEXT: (array.init_static $vector + ;; NOMNL-NEXT: (f64.const 1) + ;; NOMNL-NEXT: (f64.const 2) + ;; NOMNL-NEXT: (f64.const 4) + ;; NOMNL-NEXT: (f64.const 8) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + (func $test + (drop + (array.init_static $vector + (f64.const 1) + (f64.const 2) + (f64.const 4) + (f64.const 8) + ) + ) + ) +) diff --git a/test/lit/passes/heap2local.wast b/test/lit/passes/heap2local.wast index d49836b99..90ac8a418 100644 --- a/test/lit/passes/heap2local.wast +++ b/test/lit/passes/heap2local.wast @@ -254,7 +254,7 @@ ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit) ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (struct.new_with_rtt $struct.A + ;; CHECK-NEXT: (block ;; CHECK-NEXT: (i32.const 2) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: (rtt.canon $struct.A) @@ -1937,4 +1937,27 @@ ) ) ) + + ;; CHECK: (func $simple-no-rtt + ;; CHECK-NEXT: (local $0 i32) + ;; CHECK-NEXT: (local $1 f64) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block (result (ref null $struct.A)) + ;; CHECK-NEXT: (local.set $0 + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $1 + ;; CHECK-NEXT: (f64.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (ref.null $struct.A) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $simple-no-rtt + (drop + ;; This allocation has no rtt, so we have nothing to drop from it when + ;; we optimize. + (struct.new_default $struct.A) + ) + ) ) diff --git a/test/lit/passes/precompute-gc.wast b/test/lit/passes/precompute-gc.wast index 0a08c02c0..44eff1c5f 100644 --- a/test/lit/passes/precompute-gc.wast +++ b/test/lit/passes/precompute-gc.wast @@ -510,4 +510,24 @@ ) ) ) + + ;; CHECK: (func $new_block_unreachable (result anyref) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (rtt.canon $struct) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $new_block_unreachable (result anyref) + (struct.new_with_rtt $struct + ;; The value is a block with an unreachable. precompute will get rid of the + ;; block, after which fuzz-exec should not crash - this is a regression test + ;; for us being careful in how we execute an unreachable struct.new + (block $label$1 (result i32) + (unreachable) + ) + (rtt.canon $struct) + ) + ) ) diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index 4cb8f4142..179a75082 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -534,32 +534,25 @@ ) (call $log (ref.test_static $struct - (array.new_with_rtt $bytes + (array.new $bytes (i32.const 20) (i32.const 10) - (rtt.canon $bytes) ) ) ) (call $log (ref.test_static $struct - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) (call $log (ref.test_static $extendedstruct - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) (call $log (ref.test_static $struct - (struct.new_default_with_rtt $extendedstruct - (rtt.canon $extendedstruct) - ) + (struct.new_default $extendedstruct) ) ) ) @@ -571,9 +564,7 @@ (drop (br_on_cast_static $block $struct (br_on_cast_static $extendedblock $extendedstruct - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) ) @@ -598,9 +589,7 @@ (block $failblock (result (ref $struct)) (drop (br_on_cast_static_fail $failblock $extendedstruct - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) (call $log diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index 54bff9e5d..ea29f259a 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -556,35 +556,28 @@ ;; Testing something completely wrong (struct vs array) returns 0. (call $log (ref.test_static $struct - (array.new_with_rtt $bytes + (array.new $bytes (i32.const 20) (i32.const 10) - (rtt.canon $bytes) ) ) ) ;; Testing a thing with the same type returns 1. (call $log (ref.test_static $struct - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) ;; A bad downcast returns 0: we create a struct, which is not a extendedstruct. (call $log (ref.test_static $extendedstruct - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) ;; Casting to a supertype works. (call $log (ref.test_static $struct - (struct.new_default_with_rtt $extendedstruct - (rtt.canon $extendedstruct) - ) + (struct.new_default $extendedstruct) ) ) ) @@ -592,7 +585,7 @@ (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any - (struct.new_default_with_rtt $struct (rtt.canon $struct)) + (struct.new_default $struct) ) (drop (block $block (result ($ref $struct)) @@ -621,7 +614,7 @@ (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any - (struct.new_default_with_rtt $struct (rtt.canon $struct)) + (struct.new_default $struct) ) (drop (block $failblock (result anyref) |