diff options
-rw-r--r-- | src/wasm/wasm-validator.cpp | 5 | ||||
-rw-r--r-- | test/heap-types.wast | 6 | ||||
-rw-r--r-- | test/heap-types.wast.from-wast | 8 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary | 8 | ||||
-rw-r--r-- | test/heap-types.wast.fromBinary.noDebugInfo | 8 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.txt | 42 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.wast | 2 |
7 files changed, 41 insertions, 38 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 06f77b093..bf6e121bf 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2336,10 +2336,13 @@ void FunctionValidator::visitStructSet(StructSet* curr) { if (curr->ref->type != Type::unreachable) { const auto& fields = curr->ref->type.getHeapType().getStruct().fields; shouldBeTrue(curr->index < fields.size(), curr, "bad struct.get field"); + auto& field = fields[curr->index]; shouldBeEqual(curr->value->type, - fields[curr->index].type, + field.type, curr, "struct.set must have the proper type"); + shouldBeEqual( + field.mutable_, Mutable, curr, "struct.set field must be mutable"); } } diff --git a/test/heap-types.wast b/test/heap-types.wast index 5f47b6d2e..da8baf1e0 100644 --- a/test/heap-types.wast +++ b/test/heap-types.wast @@ -84,9 +84,9 @@ (i32.const 1) ) ) - (struct.set $struct.A 0 - (local.get $x) - (i32.const 100) + (struct.set $struct.C 0 + (ref.null $struct.C) + (f32.const 100) ) (drop (struct.new_default_with_rtt $struct.A diff --git a/test/heap-types.wast.from-wast b/test/heap-types.wast.from-wast index 1b70252b0..33c86b903 100644 --- a/test/heap-types.wast.from-wast +++ b/test/heap-types.wast.from-wast @@ -2,10 +2,10 @@ (type ${i32_f32_f64} (struct (field i32) (field f32) (field f64))) (type $[mut:f64] (array (mut f64))) (type ${} (struct )) + (type ${mut:f32} (struct (field (mut f32)))) (type $none_=>_none (func)) (type ${i32} (struct (field i32))) (type ${i32_i64} (struct (field i32) (field i64))) - (type ${mut:f32} (struct (field (mut f32)))) (type $[mut:i32] (array (mut i32))) (type $[mut:i8] (array (mut i8))) (type ${i8_mut:i16_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}))))) @@ -87,9 +87,9 @@ (i32.const 1) ) ) - (struct.set ${i32_f32_f64} 0 - (local.get $x) - (i32.const 100) + (struct.set ${mut:f32} 0 + (ref.null ${mut:f32}) + (f32.const 100) ) (drop (struct.new_default_with_rtt ${i32_f32_f64} diff --git a/test/heap-types.wast.fromBinary b/test/heap-types.wast.fromBinary index 85d452727..cb6b0fcf8 100644 --- a/test/heap-types.wast.fromBinary +++ b/test/heap-types.wast.fromBinary @@ -2,10 +2,10 @@ (type ${i32_f32_f64} (struct (field i32) (field f32) (field f64))) (type $[mut:f64] (array (mut f64))) (type ${} (struct )) + (type ${mut:f32} (struct (field (mut f32)))) (type $none_=>_none (func)) (type ${i32} (struct (field i32))) (type ${i32_i64} (struct (field i32) (field i64))) - (type ${mut:f32} (struct (field (mut f32)))) (type $[mut:i32] (array (mut i32))) (type $[mut:i8] (array (mut i8))) (type ${i8_mut:i16_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}))))) @@ -87,9 +87,9 @@ (i32.const 1) ) ) - (struct.set ${i32_f32_f64} 0 - (local.get $x) - (i32.const 100) + (struct.set ${mut:f32} 0 + (ref.null ${mut:f32}) + (f32.const 100) ) (drop (struct.new_default_with_rtt ${i32_f32_f64} diff --git a/test/heap-types.wast.fromBinary.noDebugInfo b/test/heap-types.wast.fromBinary.noDebugInfo index cf9067b21..d725f5319 100644 --- a/test/heap-types.wast.fromBinary.noDebugInfo +++ b/test/heap-types.wast.fromBinary.noDebugInfo @@ -2,10 +2,10 @@ (type ${i32_f32_f64} (struct (field i32) (field f32) (field f64))) (type $[mut:f64] (array (mut f64))) (type ${} (struct )) + (type ${mut:f32} (struct (field (mut f32)))) (type $none_=>_none (func)) (type ${i32} (struct (field i32))) (type ${i32_i64} (struct (field i32) (field i64))) - (type ${mut:f32} (struct (field (mut f32)))) (type $[mut:i32] (array (mut i32))) (type $[mut:i8] (array (mut i8))) (type ${i8_mut:i16_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}))))) @@ -87,9 +87,9 @@ (i32.const 1) ) ) - (struct.set ${i32_f32_f64} 0 - (local.get $0) - (i32.const 100) + (struct.set ${mut:f32} 0 + (ref.null ${mut:f32}) + (f32.const 100) ) (drop (struct.new_default_with_rtt ${i32_f32_f64} diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index d035309e2..8fa184345 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -22,7 +22,7 @@ [LoggingExternalInterface logging 3] [trap unreachable] (module - (type ${i32} (struct (field i32))) + (type ${mut:i32} (struct (field (mut i32)))) (type $none_=>_none (func)) (type ${i32_f64} (struct (field i32) (field f64))) (type $[mut:i8] (array (mut i8))) @@ -33,36 +33,36 @@ (export "rtts" (func $2)) (export "br_on_cast" (func $3)) (func $0 (; has Stack IR ;) - (local $0 (ref null ${i32})) + (local $0 (ref null ${mut:i32})) (call $log - (struct.get ${i32} 0 + (struct.get ${mut:i32} 0 (local.tee $0 - (struct.new_default_with_rtt ${i32} - (rtt.canon ${i32}) + (struct.new_default_with_rtt ${mut:i32} + (rtt.canon ${mut:i32}) ) ) ) ) - (struct.set ${i32} 0 + (struct.set ${mut:i32} 0 (local.get $0) (i32.const 42) ) (call $log - (struct.get ${i32} 0 + (struct.get ${mut:i32} 0 (local.get $0) ) ) - (struct.set ${i32} 0 + (struct.set ${mut:i32} 0 (local.get $0) (i32.const 100) ) (call $log - (struct.get ${i32} 0 + (struct.get ${mut:i32} 0 (local.get $0) ) ) (call $log - (struct.get ${i32} 0 + (struct.get ${mut:i32} 0 (local.get $0) ) ) @@ -111,14 +111,14 @@ ) ) (func $2 (; has Stack IR ;) - (local $0 (rtt ${i32})) + (local $0 (rtt ${mut:i32})) (local $1 (rtt ${i32_f64})) (local $2 (rtt ${i32_f64})) (local $3 anyref) (local.set $1 (rtt.sub ${i32_f64} (local.tee $0 - (rtt.canon ${i32}) + (rtt.canon ${mut:i32}) ) ) ) @@ -127,20 +127,20 @@ ) (call $log (ref.is_null - (ref.cast ${i32} - (ref.null ${i32}) + (ref.cast ${mut:i32} + (ref.null ${mut:i32}) (local.get $0) ) ) ) (call $log - (ref.test ${i32} - (ref.null ${i32}) + (ref.test ${mut:i32} + (ref.null ${mut:i32}) (local.get $0) ) ) (call $log - (ref.test ${i32} + (ref.test ${mut:i32} (array.new_with_rtt $[mut:i8] (rtt.canon $[mut:i8]) (i32.const 10) @@ -150,8 +150,8 @@ ) ) (call $log - (ref.test ${i32} - (struct.new_default_with_rtt ${i32} + (ref.test ${mut:i32} + (struct.new_default_with_rtt ${mut:i32} (local.get $0) ) (local.get $0) @@ -159,7 +159,7 @@ ) (call $log (ref.test ${i32_f64} - (struct.new_default_with_rtt ${i32} + (struct.new_default_with_rtt ${mut:i32} (local.get $0) ) (local.get $2) @@ -182,7 +182,7 @@ ) ) (call $log - (ref.test ${i32} + (ref.test ${mut:i32} (local.get $3) (local.get $0) ) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index cf2e182e4..78313267c 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -1,5 +1,5 @@ (module - (type $struct (struct i32)) + (type $struct (struct (mut i32))) (type $extendedstruct (struct i32 f64)) (type $bytes (array (mut i8))) (import "fuzzing-support" "log-i32" (func $log (param i32))) |