diff options
-rw-r--r-- | src/wasm/wasm-type.cpp | 2 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.txt | 66 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.wast | 28 |
3 files changed, 28 insertions, 68 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index ffc18b9fd..d3c4c0fc4 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -415,7 +415,7 @@ bool Type::isDefaultable() const { // A variable can get a default value if its type is concrete (unreachable // and none have no values, hence no default), and if it's a reference, it // must be nullable. - return isConcrete() && (!isRef() || isNullable()); + return isConcrete() && (!isRef() || isNullable()) && !isRtt(); } bool Type::operator<(const Type& other) const { diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt index b43681cdf..867179092 100644 --- a/test/passes/Oz_fuzz-exec_all-features.txt +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -114,80 +114,46 @@ ) ) (func $2 (; has Stack IR ;) - (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 ${mut:i32}) - ) - ) - ) - (local.set $2 - (rtt.canon ${i32_f64}) - ) + (local $0 anyref) (call $log - (ref.is_null - (ref.cast ${mut:i32} - (ref.null ${mut:i32}) - (local.get $0) - ) - ) + (i32.const 1) ) (call $log - (ref.test ${mut:i32} - (ref.null ${mut:i32}) - (local.get $0) - ) + (i32.const 0) ) (call $log - (ref.test ${mut:i32} - (array.new_with_rtt $[mut:i8] - (rtt.canon $[mut:i8]) - (i32.const 10) - (i32.const 20) - ) - (local.get $0) - ) + (i32.const 0) ) (call $log - (ref.test ${mut:i32} - (struct.new_default_with_rtt ${mut:i32} - (local.get $0) - ) - (local.get $0) - ) + (i32.const 1) ) (call $log - (ref.test ${i32_f64} - (struct.new_default_with_rtt ${mut:i32} - (local.get $0) - ) - (local.get $2) - ) + (i32.const 0) ) (call $log (ref.test ${i32_f64} - (local.tee $3 + (local.tee $0 (struct.new_default_with_rtt ${i32_f64} - (local.get $1) + (rtt.sub ${i32_f64} + (rtt.canon ${mut:i32}) + ) ) ) - (local.get $1) + (rtt.sub ${i32_f64} + (rtt.canon ${mut:i32}) + ) ) ) (call $log (ref.test ${i32_f64} - (local.get $3) - (local.get $2) + (local.get $0) + (rtt.canon ${i32_f64}) ) ) (call $log (ref.test ${mut:i32} - (local.get $3) (local.get $0) + (rtt.canon ${mut:i32}) ) ) ) diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index 7d586cffc..d521ad377 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -69,20 +69,14 @@ ) ) (func "rtts" - (local $x (rtt $struct)) - (local $y (rtt $extendedstruct)) - (local $z (rtt $extendedstruct)) (local $any anyref) - (local.set $x (rtt.canon $struct)) - (local.set $y (rtt.sub $extendedstruct (local.get $x))) - (local.set $z (rtt.canon $extendedstruct)) ;; Casting null returns null. (call $log (ref.is_null - (ref.cast $struct (ref.null $struct) (local.get $x)) + (ref.cast $struct (ref.null $struct) (rtt.canon $struct)) )) ;; Testing null returns 0. (call $log - (ref.test $struct (ref.null $struct) (local.get $x)) + (ref.test $struct (ref.null $struct) (rtt.canon $struct)) ) ;; Testing something completely wrong (struct vs array) returns 0. (call $log @@ -92,52 +86,52 @@ (i32.const 10) (i32.const 20) ) - (local.get $x) + (rtt.canon $struct) ) ) ;; Testing a thing with the same RTT returns 1. (call $log (ref.test $struct (struct.new_default_with_rtt $struct - (local.get $x) + (rtt.canon $struct) ) - (local.get $x) + (rtt.canon $struct) ) ) ;; A bad downcast returns 0: we create a struct, which is not a extendedstruct. (call $log (ref.test $extendedstruct (struct.new_default_with_rtt $struct - (local.get $x) + (rtt.canon $struct) ) - (local.get $z) + (rtt.canon $extendedstruct) ) ) ;; Create a extendedstruct with RTT y, and upcast statically to anyref. (local.set $any (struct.new_default_with_rtt $extendedstruct - (local.get $y) + (rtt.sub $extendedstruct (rtt.canon $struct)) ) ) ;; Casting to y, the exact same RTT, works. (call $log (ref.test $extendedstruct (local.get $any) - (local.get $y) + (rtt.sub $extendedstruct (rtt.canon $struct)) ) ) ;; Casting to z, another RTT of the same data type, fails. (call $log (ref.test $extendedstruct (local.get $any) - (local.get $z) + (rtt.canon $extendedstruct) ) ) ;; Casting to x, the parent of y, works. (call $log (ref.test $struct (local.get $any) - (local.get $x) + (rtt.canon $struct) ) ) ) |