summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm-interpreter.h3
-rw-r--r--test/passes/Oz_fuzz-exec_all-features.txt16
-rw-r--r--test/passes/Oz_fuzz-exec_all-features.wast13
3 files changed, 31 insertions, 1 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 9fc11de76..8dd7859ac 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -1712,13 +1712,14 @@ public:
if (num >= ArrayLimit) {
hostLimit("allocation failure");
}
+ auto field = curr->type.getHeapType().getArray().element;
Literals data(num);
for (Index i = 0; i < num; i++) {
auto value = this->visit(curr->values[i]);
if (value.breaking()) {
return value;
}
- data[i] = value.getSingleValue();
+ data[i] = truncateForPacking(value.getSingleValue(), field);
}
return Flow(Literal(std::make_shared<GCData>(rtt.getSingleValue(), data),
curr->type));
diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt
index 4ac373f75..1360d6b42 100644
--- a/test/passes/Oz_fuzz-exec_all-features.txt
+++ b/test/passes/Oz_fuzz-exec_all-features.txt
@@ -65,6 +65,8 @@
[LoggingExternalInterface logging 2]
[LoggingExternalInterface logging 42]
[LoggingExternalInterface logging 50]
+[fuzz-exec] calling array.init-packed
+[LoggingExternalInterface logging 8]
(module
(type $extendedstruct (struct (field (mut i32)) (field f64)))
(type $struct (struct (field (mut i32))))
@@ -95,6 +97,7 @@
(export "array-copy" (func $20))
(export "rtt_Fresh" (func $21))
(export "array.init" (func $22))
+ (export "array.init-packed" (func $23))
(func $0 (; has Stack IR ;)
(local $0 i32)
(call $log
@@ -487,6 +490,17 @@
)
)
)
+ (func $23 (; has Stack IR ;)
+ (call $log
+ (array.get_u $bytes
+ (array.init $bytes
+ (i32.const -11512)
+ (rtt.canon $bytes)
+ )
+ (i32.const 0)
+ )
+ )
+ )
)
[fuzz-exec] calling structs
[LoggingExternalInterface logging 0]
@@ -554,6 +568,8 @@
[LoggingExternalInterface logging 2]
[LoggingExternalInterface logging 42]
[LoggingExternalInterface logging 50]
+[fuzz-exec] calling array.init-packed
+[LoggingExternalInterface logging 8]
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 a41e2bf70..54d93c9d0 100644
--- a/test/passes/Oz_fuzz-exec_all-features.wast
+++ b/test/passes/Oz_fuzz-exec_all-features.wast
@@ -497,6 +497,19 @@
(array.get_u $bytes (local.get $x) (i32.const 1))
)
)
+ (func "array.init-packed"
+ (local $x (ref null $bytes))
+ (local.set $x
+ (array.init $bytes
+ (i32.const -11512)
+ (rtt.canon $bytes)
+ )
+ )
+ ;; The value should be be -11512 & 255 => 8
+ (call $log
+ (array.get_u $bytes (local.get $x) (i32.const 0))
+ )
+ )
)
(module
(type $[mut:i8] (array (mut i8)))