diff options
author | Alon Zakai <azakai@google.com> | 2020-12-08 18:55:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 18:55:20 -0800 |
commit | 63a042e3a94df7ba3a5c9dde03990a9813fdc366 (patch) | |
tree | 50c05727ce20615f4d0c0206e62dcd56c246766f /test | |
parent | 2a0059dec2fe01dcf1358e0120c32aadd2d765b6 (diff) | |
download | binaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.tar.gz binaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.tar.bz2 binaryen-63a042e3a94df7ba3a5c9dde03990a9813fdc366.zip |
[GC] Add basic RTT support (#3432)
This adds rtt.canon and rtt.sub together with RTT type support
that is necessary for them. Together this lets us test roundtripping the
instructions and types.
Also fixes a missing traversal over globals in collectHeapTypes,
which the example from the GC docs requires, as the RTTs are in
globals there.
This does not yet add full interpreter support and other things. It
disables initial contents on GC in the fuzzer, to avoid the fuzzer
breaking.
Renames the binary ID for exnref, which is being removed from
the spec, and which overlaps with the binary ID for rtt.
Diffstat (limited to 'test')
-rw-r--r-- | test/heap-types.wast | 13 | ||||
-rw-r--r-- | test/heap-types.wast.from-wast | 18 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary | 18 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary.noDebugInfo | 18 | ||||
-rw-r--r-- | test/try-body-multiple-insts.wasm | bin | 49 -> 0 bytes | |||
-rw-r--r-- | test/try-body-multiple-insts.wasm.fromBinary | 26 |
6 files changed, 67 insertions, 26 deletions
diff --git a/test/heap-types.wast b/test/heap-types.wast index 8e7655361..7e44e4fdb 100644 --- a/test/heap-types.wast +++ b/test/heap-types.wast @@ -1,5 +1,6 @@ ;; Test that we can roundtrip struct and array types (module + ;; Structs (type $struct.A (struct i32 (field f32) @@ -15,9 +16,18 @@ (field $named-mut (mut f32)) )) + ;; Arrays (type $vector (array (mut f64))) (type $matrix (array (ref $vector))) + ;; RTT + (type $parent (struct)) + (type $child (struct i32)) + (type $grandchild (struct i32 i64)) + (global $rttparent (rtt 0 $parent) (rtt.canon $parent)) + (global $rttchild (rtt 1 $child) (rtt.sub $child (global.get $rttparent))) + (global $rttgrandchild (rtt 2 $grandchild) (rtt.sub $grandchild (global.get $rttchild))) + (func "foo" (param $x (ref $struct.A)) (result (ref $struct.B)) (local $tA (ref null $struct.A)) (local $tB (ref null $struct.B)) @@ -78,4 +88,7 @@ ) (unreachable) ) + ;; RTT types as parameters + (func $rtt-param-with-depth (param $rtt (rtt 1 $parent))) + (func $rtt-param-without-depth (param $rtt (rtt $parent))) ) diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast index ced28e941..6f3c20589 100644 --- a/test/heap-types.wast.from-wast +++ b/test/heap-types.wast.from-wast @@ -1,10 +1,22 @@ (module (type ${i32_f32_f64} (struct (field i32) (field f32) (field f64))) + (type ${} (struct )) (type $[mut:f64] (array (mut f64))) + (type ${i32} (struct (field i32))) + (type ${i32_i64} (struct (field i32) (field i64))) (type ${mut:f32} (struct (field (mut f32)))) (type ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|} (struct (field i8) (field (mut i16)) (field (ref null ${i32_f32_f64})) (field (mut (ref null ${i32_f32_f64}))))) + (type $rtt_1_${}_=>_none (func (param (rtt 1 ${})))) + (type $rtt_${}_=>_none (func (param (rtt ${})))) (type $[ref?|[mut:f64]|] (array (ref null $[mut:f64]))) (type $ref?|{i32_f32_f64}|_=>_ref?|{i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|}| (func (param (ref null ${i32_f32_f64})) (result (ref null ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|})))) + (global $rttparent (rtt 0 ${}) (rtt.canon ${})) + (global $rttchild (rtt 1 ${i32}) (rtt.sub ${i32} + (global.get $rttparent) + )) + (global $rttgrandchild (rtt 2 ${i32_i64}) (rtt.sub ${i32_i64} + (global.get $rttchild) + )) (export "foo" (func $0)) (func $0 (param $x (ref null ${i32_f32_f64})) (result (ref null ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|})) (local $tA (ref null ${i32_f32_f64})) @@ -78,4 +90,10 @@ ) (unreachable) ) + (func $rtt-param-with-depth (param $rtt (rtt 1 ${})) + (nop) + ) + (func $rtt-param-without-depth (param $rtt (rtt ${})) + (nop) + ) ) diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary index 2d8e7ff38..537096fe0 100644 --- a/test/heap-types.wast.fromBinary +++ b/test/heap-types.wast.fromBinary @@ -1,10 +1,22 @@ (module (type ${i32_f32_f64} (struct (field i32) (field f32) (field f64))) + (type ${} (struct )) (type $[mut:f64] (array (mut f64))) + (type ${i32} (struct (field i32))) + (type ${i32_i64} (struct (field i32) (field i64))) (type ${mut:f32} (struct (field (mut f32)))) (type ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|} (struct (field i8) (field (mut i16)) (field (ref null ${i32_f32_f64})) (field (mut (ref null ${i32_f32_f64}))))) + (type $rtt_1_${}_=>_none (func (param (rtt 1 ${})))) + (type $rtt_${}_=>_none (func (param (rtt ${})))) (type $[ref?|[mut:f64]|] (array (ref null $[mut:f64]))) (type $ref?|{i32_f32_f64}|_=>_ref?|{i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|}| (func (param (ref null ${i32_f32_f64})) (result (ref null ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|})))) + (global $rttparent (rtt 0 ${}) (rtt.canon ${})) + (global $rttchild (rtt 1 ${i32}) (rtt.sub ${i32} + (global.get $rttparent) + )) + (global $rttgrandchild (rtt 2 ${i32_i64}) (rtt.sub ${i32_i64} + (global.get $rttchild) + )) (export "foo" (func $0)) (func $0 (param $x (ref null ${i32_f32_f64})) (result (ref null ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|})) (local $tA (ref null ${i32_f32_f64})) @@ -78,5 +90,11 @@ ) (unreachable) ) + (func $rtt-param-with-depth (param $rtt (rtt 1 ${})) + (nop) + ) + (func $rtt-param-without-depth (param $rtt (rtt ${})) + (nop) + ) ) diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo index 753402c05..19e5f701d 100644 --- a/test/heap-types.wast.fromBinary.noDebugInfo +++ b/test/heap-types.wast.fromBinary.noDebugInfo @@ -1,10 +1,22 @@ (module (type ${i32_f32_f64} (struct (field i32) (field f32) (field f64))) + (type ${} (struct )) (type $[mut:f64] (array (mut f64))) + (type ${i32} (struct (field i32))) + (type ${i32_i64} (struct (field i32) (field i64))) (type ${mut:f32} (struct (field (mut f32)))) (type ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|} (struct (field i8) (field (mut i16)) (field (ref null ${i32_f32_f64})) (field (mut (ref null ${i32_f32_f64}))))) + (type $rtt_1_${}_=>_none (func (param (rtt 1 ${})))) + (type $rtt_${}_=>_none (func (param (rtt ${})))) (type $[ref?|[mut:f64]|] (array (ref null $[mut:f64]))) (type $ref?|{i32_f32_f64}|_=>_ref?|{i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|}| (func (param (ref null ${i32_f32_f64})) (result (ref null ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|})))) + (global $global$0 (rtt 0 ${}) (rtt.canon ${})) + (global $global$1 (rtt 1 ${i32}) (rtt.sub ${i32} + (global.get $global$0) + )) + (global $global$2 (rtt 2 ${i32_i64}) (rtt.sub ${i32_i64} + (global.get $global$1) + )) (export "foo" (func $0)) (func $0 (param $0 (ref null ${i32_f32_f64})) (result (ref null ${i32_mut:i32_ref?|{i32_f32_f64}|_mut:ref?|{i32_f32_f64}|})) (local $1 (ref null ${i32_f32_f64})) @@ -78,5 +90,11 @@ ) (unreachable) ) + (func $1 (param $0 (rtt 1 ${})) + (nop) + ) + (func $2 (param $0 (rtt ${})) + (nop) + ) ) diff --git a/test/try-body-multiple-insts.wasm b/test/try-body-multiple-insts.wasm Binary files differdeleted file mode 100644 index dd67f3e52..000000000 --- a/test/try-body-multiple-insts.wasm +++ /dev/null diff --git a/test/try-body-multiple-insts.wasm.fromBinary b/test/try-body-multiple-insts.wasm.fromBinary deleted file mode 100644 index 179bb42ab..000000000 --- a/test/try-body-multiple-insts.wasm.fromBinary +++ /dev/null @@ -1,26 +0,0 @@ -(module - (type $none_=>_none (func)) - (func $0 - (nop) - ) - (func $1 - (nop) - ) - (func $2 - (local $0 exnref) - (try - (do - (call $0) - (call $1) - ) - (catch - (drop - (pop exnref) - ) - (call $0) - (call $1) - ) - ) - ) -) - |