summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/binaryen.js/kitchen-sink.js1
-rw-r--r--test/binaryen.js/kitchen-sink.js.txt7
-rw-r--r--test/heap-types.wast17
-rw-r--r--test/heap-types.wast.from-wast23
-rw-r--r--test/heap-types.wast.fromBinary23
-rw-r--r--test/heap-types.wast.fromBinary.noDebugInfo23
-rw-r--r--test/passes/Oz_fuzz-exec_all-features.txt35
-rw-r--r--test/passes/Oz_fuzz-exec_all-features.wast22
8 files changed, 142 insertions, 9 deletions
diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js
index 04aca99f7..7a3007cfe 100644
--- a/test/binaryen.js/kitchen-sink.js
+++ b/test/binaryen.js/kitchen-sink.js
@@ -180,6 +180,7 @@ function test_ids() {
console.log("StructGetId: " + binaryen.StructGetId);
console.log("StructSetId: " + binaryen.StructSetId);
console.log("ArrayNewId: " + binaryen.ArrayNewId);
+ console.log("ArrayInitId: " + binaryen.ArrayInitId);
console.log("ArrayGetId: " + binaryen.ArrayGetId);
console.log("ArraySetId: " + binaryen.ArraySetId);
console.log("ArrayLenId: " + binaryen.ArrayLenId);
diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt
index b9462e68c..95236a4be 100644
--- a/test/binaryen.js/kitchen-sink.js.txt
+++ b/test/binaryen.js/kitchen-sink.js.txt
@@ -104,9 +104,10 @@ StructNewId: 58
StructGetId: 59
StructSetId: 60
ArrayNewId: 61
-ArrayGetId: 62
-ArraySetId: 63
-ArrayLenId: 64
+ArrayInitId: 62
+ArrayGetId: 63
+ArraySetId: 64
+ArrayLenId: 65
getExpressionInfo={"id":15,"type":4,"op":6}
(f32.neg
(f32.const -33.61199951171875)
diff --git a/test/heap-types.wast b/test/heap-types.wast
index f62003da5..750467946 100644
--- a/test/heap-types.wast
+++ b/test/heap-types.wast
@@ -379,4 +379,21 @@
(i32.const 1337)
)
)
+ (func $array-init (result (ref $vector))
+ (array.init $vector
+ (f64.const 1)
+ (f64.const 2)
+ (f64.const 4)
+ (f64.const 8)
+ (rtt.canon $vector)
+ )
+ )
+ (func $array-init-packed (result (ref $bytes))
+ (array.init $bytes
+ (i32.const 4)
+ (i32.const 2)
+ (i32.const 1)
+ (rtt.canon $bytes)
+ )
+ )
)
diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast
index ddc590ce7..32e29bfba 100644
--- a/test/heap-types.wast.from-wast
+++ b/test/heap-types.wast.from-wast
@@ -1,23 +1,25 @@
(module
(type $struct.A (struct (field i32) (field f32) (field $named f64)))
+ (type $vector (array (mut f64)))
(type $none_=>_none (func))
(type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A)))))
- (type $vector (array (mut f64)))
(type $grandchild (struct (field i32) (field i64)))
(type $struct.C (struct (field $named-mut (mut f32))))
(type $matrix (array (mut (ref null $vector))))
(type $parent (struct ))
(type $child (struct (field i32)))
+ (type $bytes (array (mut i8)))
(type $anyref_=>_none (func (param anyref)))
(type $nested-child-struct (struct (field (mut (ref $child)))))
(type $ref|$struct.A|_=>_ref|$struct.B| (func (param (ref $struct.A)) (result (ref $struct.B))))
(type $ref|$vector|_=>_ref|$matrix| (func (param (ref $vector)) (result (ref $matrix))))
- (type $bytes (array (mut i8)))
(type $words (array (mut i32)))
(type $nested-child-array (array (mut (ref $child))))
(type $rtt_1_$parent_=>_none (func (param (rtt 1 $parent))))
(type $rtt_$parent_=>_none (func (param (rtt $parent))))
(type $ref|$vector|_ref?|$vector|_=>_none (func (param (ref $vector) (ref null $vector))))
+ (type $none_=>_ref|$vector| (func (result (ref $vector))))
+ (type $none_=>_ref|$bytes| (func (result (ref $bytes))))
(global $rttparent (rtt 0 $parent) (rtt.canon $parent))
(global $rttchild (rtt 1 $child) (rtt.sub $child
(global.get $rttparent)
@@ -468,4 +470,21 @@
(i32.const 1337)
)
)
+ (func $array-init (result (ref $vector))
+ (array.init $vector
+ (f64.const 1)
+ (f64.const 2)
+ (f64.const 4)
+ (f64.const 8)
+ (rtt.canon $vector)
+ )
+ )
+ (func $array-init-packed (result (ref $bytes))
+ (array.init $bytes
+ (i32.const 4)
+ (i32.const 2)
+ (i32.const 1)
+ (rtt.canon $bytes)
+ )
+ )
)
diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary
index 74c47eddf..a9bff28f3 100644
--- a/test/heap-types.wast.fromBinary
+++ b/test/heap-types.wast.fromBinary
@@ -1,23 +1,25 @@
(module
(type $struct.A (struct (field i32) (field f32) (field $named f64)))
+ (type $vector (array (mut f64)))
(type $none_=>_none (func))
(type $struct.B (struct (field i8) (field (mut i16)) (field (ref $struct.A)) (field (mut (ref $struct.A)))))
- (type $vector (array (mut f64)))
(type $grandchild (struct (field i32) (field i64)))
(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)))
(type $anyref_=>_none (func (param anyref)))
(type $nested-child-struct (struct (field (mut (ref $child)))))
(type $ref|$struct.A|_=>_ref|$struct.B| (func (param (ref $struct.A)) (result (ref $struct.B))))
(type $ref|$vector|_=>_ref|$matrix| (func (param (ref $vector)) (result (ref $matrix))))
- (type $bytes (array (mut i8)))
(type $words (array (mut i32)))
(type $nested-child-array (array (mut (ref $child))))
(type $rtt_1_$parent_=>_none (func (param (rtt 1 $parent))))
(type $rtt_$parent_=>_none (func (param (rtt $parent))))
(type $ref|$vector|_ref?|$vector|_=>_none (func (param (ref $vector) (ref null $vector))))
+ (type $none_=>_ref|$vector| (func (result (ref $vector))))
+ (type $none_=>_ref|$bytes| (func (result (ref $bytes))))
(global $rttparent (rtt 0 $parent) (rtt.canon $parent))
(global $rttchild (rtt 1 $child) (rtt.sub $child
(global.get $rttparent)
@@ -423,5 +425,22 @@
(i32.const 1337)
)
)
+ (func $array-init (result (ref $vector))
+ (array.init $vector
+ (f64.const 1)
+ (f64.const 2)
+ (f64.const 4)
+ (f64.const 8)
+ (rtt.canon $vector)
+ )
+ )
+ (func $array-init-packed (result (ref $bytes))
+ (array.init $bytes
+ (i32.const 4)
+ (i32.const 2)
+ (i32.const 1)
+ (rtt.canon $bytes)
+ )
+ )
)
diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo
index 66caa798a..5857e6689 100644
--- a/test/heap-types.wast.fromBinary.noDebugInfo
+++ b/test/heap-types.wast.fromBinary.noDebugInfo
@@ -1,23 +1,25 @@
(module
(type ${i32_f32_f64} (struct (field i32) (field f32) (field f64)))
+ (type $[mut:f64] (array (mut f64)))
(type $none_=>_none (func))
(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 $[mut:f64] (array (mut f64)))
(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))))
(type ${} (struct ))
(type ${i32} (struct (field i32)))
+ (type $[mut:i8] (array (mut i8)))
(type $anyref_=>_none (func (param anyref)))
(type ${mut:ref|{i32}|} (struct (field (mut (ref ${i32})))))
(type $ref|{i32_f32_f64}|_=>_ref|{i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|}| (func (param (ref ${i32_f32_f64})) (result (ref ${i8_mut:i16_ref|{i32_f32_f64}|_mut:ref|{i32_f32_f64}|}))))
(type $ref|[mut:f64]|_=>_ref|[mut:ref?|[mut:f64]|]| (func (param (ref $[mut:f64])) (result (ref $[mut:ref?|[mut:f64]|]))))
- (type $[mut:i8] (array (mut i8)))
(type $[mut:i32] (array (mut i32)))
(type $[mut:ref|{i32}|] (array (mut (ref ${i32}))))
(type $rtt_1_{}_=>_none (func (param (rtt 1 ${}))))
(type $rtt_{}_=>_none (func (param (rtt ${}))))
(type $ref|[mut:f64]|_ref?|[mut:f64]|_=>_none (func (param (ref $[mut:f64]) (ref null $[mut:f64]))))
+ (type $none_=>_ref|[mut:f64]| (func (result (ref $[mut:f64]))))
+ (type $none_=>_ref|[mut:i8]| (func (result (ref $[mut:i8]))))
(global $global$0 (rtt 0 ${}) (rtt.canon ${}))
(global $global$1 (rtt 1 ${i32}) (rtt.sub ${i32}
(global.get $global$0)
@@ -423,5 +425,22 @@
(i32.const 1337)
)
)
+ (func $20 (result (ref $[mut:f64]))
+ (array.init $[mut:f64]
+ (f64.const 1)
+ (f64.const 2)
+ (f64.const 4)
+ (f64.const 8)
+ (rtt.canon $[mut:f64])
+ )
+ )
+ (func $21 (result (ref $[mut:i8]))
+ (array.init $[mut:i8]
+ (i32.const 4)
+ (i32.const 2)
+ (i32.const 1)
+ (rtt.canon $[mut:i8])
+ )
+ )
)
diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt
index 329853ae2..4ac373f75 100644
--- a/test/passes/Oz_fuzz-exec_all-features.txt
+++ b/test/passes/Oz_fuzz-exec_all-features.txt
@@ -61,6 +61,10 @@
[LoggingExternalInterface logging 1]
[LoggingExternalInterface logging 0]
[LoggingExternalInterface logging 1]
+[fuzz-exec] calling array.init
+[LoggingExternalInterface logging 2]
+[LoggingExternalInterface logging 42]
+[LoggingExternalInterface logging 50]
(module
(type $extendedstruct (struct (field (mut i32)) (field f64)))
(type $struct (struct (field (mut i32))))
@@ -90,6 +94,7 @@
(export "cast-func-to-struct" (func $19))
(export "array-copy" (func $20))
(export "rtt_Fresh" (func $21))
+ (export "array.init" (func $22))
(func $0 (; has Stack IR ;)
(local $0 i32)
(call $log
@@ -456,6 +461,32 @@
)
)
)
+ (func $22 (; has Stack IR ;)
+ (local $0 (ref null $bytes))
+ (call $log
+ (array.len $bytes
+ (local.tee $0
+ (array.init $bytes
+ (i32.const 42)
+ (i32.const 50)
+ (rtt.canon $bytes)
+ )
+ )
+ )
+ )
+ (call $log
+ (array.get_u $bytes
+ (local.get $0)
+ (i32.const 0)
+ )
+ )
+ (call $log
+ (array.get_u $bytes
+ (local.get $0)
+ (i32.const 1)
+ )
+ )
+ )
)
[fuzz-exec] calling structs
[LoggingExternalInterface logging 0]
@@ -519,6 +550,10 @@
[LoggingExternalInterface logging 1]
[LoggingExternalInterface logging 0]
[LoggingExternalInterface logging 1]
+[fuzz-exec] calling array.init
+[LoggingExternalInterface logging 2]
+[LoggingExternalInterface logging 42]
+[LoggingExternalInterface logging 50]
ignoring comparison of ExecutionResults!
[fuzz-exec] calling foo
[host limit allocation failure]
diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast
index 520747075..a41e2bf70 100644
--- a/test/passes/Oz_fuzz-exec_all-features.wast
+++ b/test/passes/Oz_fuzz-exec_all-features.wast
@@ -475,6 +475,28 @@
)
)
)
+ (func "array.init"
+ (local $x (ref null $bytes))
+ (local.set $x
+ (array.init $bytes
+ (i32.const 42) ;; first value
+ (i32.const 50) ;; second value
+ (rtt.canon $bytes)
+ )
+ )
+ ;; The length should be 2
+ (call $log
+ (array.len $bytes (local.get $x))
+ )
+ ;; The first value should be 42
+ (call $log
+ (array.get_u $bytes (local.get $x) (i32.const 0))
+ )
+ ;; The second value should be 50
+ (call $log
+ (array.get_u $bytes (local.get $x) (i32.const 1))
+ )
+ )
)
(module
(type $[mut:i8] (array (mut i8)))