diff options
Diffstat (limited to 'test/passes/Oz_fuzz-exec_all-features.wast')
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.wast | 210 |
1 files changed, 29 insertions, 181 deletions
diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast index 7ab9116dd..c8ad3700a 100644 --- a/test/passes/Oz_fuzz-exec_all-features.wast +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -8,15 +8,11 @@ (import "fuzzing-support" "log-i32" (func $log (param i32))) - (global $rtt (mut (rtt $extendedstruct)) (rtt.canon $extendedstruct)) - (func "structs" (local $x (ref null $struct)) (local $y (ref null $struct)) (local.set $x - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ;; The value is initialized to 0 ;; Note: We cannot optimize these to constants without either immutability or @@ -49,10 +45,9 @@ (func "arrays" (local $x (ref null $bytes)) (local.set $x - (array.new_with_rtt $bytes + (array.new $bytes (i32.const 42) ;; value to splat into the array (i32.const 50) ;; size - (rtt.canon $bytes) ) ) ;; The length should be 50 @@ -77,78 +72,11 @@ (array.get_s $bytes (local.get $x) (i32.const 20)) ) ) - (func "rtts" - (local $any anyref) - ;; Casting null returns null. - (call $log (ref.is_null - (ref.cast (ref.null $struct) (rtt.canon $struct)) - )) - ;; Testing null returns 0. - (call $log - (ref.test (ref.null $struct) (rtt.canon $struct)) - ) - ;; Testing something completely wrong (struct vs array) returns 0. - (call $log - (ref.test - (array.new_with_rtt $bytes - (i32.const 20) - (i32.const 10) - (rtt.canon $bytes) - ) - (rtt.canon $struct) - ) - ) - ;; Testing a thing with the same RTT returns 1. - (call $log - (ref.test - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) - (rtt.canon $struct) - ) - ) - ;; A bad downcast returns 0: we create a struct, which is not a extendedstruct. - (call $log - (ref.test - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) - (rtt.canon $extendedstruct) - ) - ) - ;; Create a extendedstruct with RTT y, and upcast statically to anyref. - (local.set $any - (struct.new_default_with_rtt $extendedstruct - (rtt.sub $extendedstruct (rtt.canon $struct)) - ) - ) - ;; Casting to y, the exact same RTT, works. - (call $log - (ref.test - (local.get $any) - (rtt.sub $extendedstruct (rtt.canon $struct)) - ) - ) - ;; Casting to z, another RTT of the same data type, fails. - (call $log - (ref.test - (local.get $any) - (rtt.canon $extendedstruct) - ) - ) - ;; Casting to x, the parent of y, works. - (call $log - (ref.test - (local.get $any) - (rtt.canon $struct) - ) - ) - ) (func "br_on_cast" (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any - (struct.new_default_with_rtt $struct (rtt.canon $struct)) + (struct.new_default $struct) ) (drop (block $block (result ($ref $struct)) @@ -156,12 +84,11 @@ (block $extendedblock (result (ref $extendedstruct)) (drop ;; second, try to cast our simple $struct to what it is, which will work - (br_on_cast $block + (br_on_cast_static $block $struct ;; first, try to cast our simple $struct to an extended, which will fail - (br_on_cast $extendedblock - (local.get $any) (rtt.canon $extendedstruct) + (br_on_cast_static $extendedblock $extendedstruct + (local.get $any) ) - (rtt.canon $struct) ) ) (call $log (i32.const -1)) ;; we should never get here @@ -173,20 +100,12 @@ ) ) (call $log (i32.const 3)) ;; we should get here - (drop - (block $never (result (ref $extendedstruct)) - ;; an untaken br_on_cast, with unreachable rtt - so we cannot use the - ;; RTT in binaryen IR to find the cast type. - (br_on_cast $never (ref.null $struct) (unreachable)) - (unreachable) - ) - ) ) (func "br_on_failed_cast-1" (local $any anyref) ;; create a simple $struct, store it in an anyref (local.set $any - (struct.new_default_with_rtt $struct (rtt.canon $struct)) + (struct.new_default $struct) ) (drop (block $any (result (ref null any)) @@ -194,9 +113,8 @@ (drop ;; try to cast our simple $struct to an extended, which will fail, and ;; so we will branch, skipping the next logging. - (br_on_cast_fail $any + (br_on_cast_static_fail $any $extendedstruct (local.get $any) - (rtt.canon $extendedstruct) ) ) (call $log (i32.const 999)) ;; we should skip this @@ -208,7 +126,7 @@ (local $any anyref) ;; create an $extendedstruct, store it in an anyref (local.set $any - (struct.new_default_with_rtt $extendedstruct (rtt.canon $extendedstruct)) + (struct.new_default $extendedstruct) ) (drop (block $any (result (ref null any)) @@ -216,9 +134,8 @@ (drop ;; try to cast our simple $struct to an extended, which will succeed, and ;; so we will continue to the next logging. - (br_on_cast_fail $any + (br_on_cast_static_fail $any $extendedstruct (local.get $any) - (rtt.canon $extendedstruct) ) ) (call $log (i32.const 999)) @@ -231,16 +148,13 @@ ;; array or a struct, so our casting code should not assume it is. it is ok ;; to try to cast it, and the result should be 0. (call $log - (ref.test + (ref.test_static $struct (ref.null any) - (rtt.canon $struct) ) ) ) (func $get_data (result dataref) - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) (func "br_on_data" (param $x anyref) (local $y anyref) @@ -272,9 +186,7 @@ (local $x anyref) ;; set x to valid data (local.set $x - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) (drop (block $any (result anyref) @@ -336,9 +248,7 @@ (func "ref-as-data-of-data" (drop (ref.as_data - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) ) @@ -346,9 +256,7 @@ (drop ;; This should trap. (ref.as_func - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) + (struct.new_default $struct) ) ) ) @@ -362,43 +270,33 @@ (func $a-void-func (call $log (i32.const 1337)) ) - (func "rtt-and-cast-on-func" + (func "cast-on-func" (call $log (i32.const 0)) - (drop - (rtt.canon $void_func) - ) - (call $log (i32.const 1)) - (drop - (rtt.canon $int_func) - ) - (call $log (i32.const 2)) ;; a valid cast (call_ref - (ref.cast (ref.func $a-void-func) (rtt.canon $void_func)) + (ref.cast_static $void_func (ref.func $a-void-func)) ) - (call $log (i32.const 3)) + (call $log (i32.const 1)) ;; an invalid cast (drop (call_ref - (ref.cast (ref.func $a-void-func) (rtt.canon $int_func)) + (ref.cast_static $int_func (ref.func $a-void-func)) )) ;; will never be reached - (call $log (i32.const 4)) + (call $log (i32.const 2)) ) (func "array-alloc-failure" (drop - (array.new_default_with_rtt $bytes + (array.new_default $bytes (i32.const -1) ;; un-allocatable size (4GB * sizeof(Literal)) - (rtt.canon $bytes) ) ) ) (func "init-array-packed" (result i32) (local $x (ref null $bytes)) (local.set $x - (array.new_with_rtt $bytes + (array.new $bytes (i32.const -43) ;; initialize the i8 values with a negative i32 (i32.const 50) - (rtt.canon $bytes) ) ) ;; read the value, which should be -43 & 255 ==> 213 @@ -413,9 +311,8 @@ (func "cast-func-to-struct" (drop ;; An impossible cast of a function to a struct, which should fail. - (ref.cast + (ref.cast_static $struct (ref.func $call-target) - (rtt.canon $struct) ) ) ) @@ -424,17 +321,15 @@ (local $y (ref null $bytes)) ;; Create an array of 10's, of size 100. (local.set $x - (array.new_with_rtt $bytes + (array.new $bytes (i32.const 10) (i32.const 100) - (rtt.canon $bytes) ) ) ;; Create an array of zeros of size 200, and also set one index there. (local.set $y - (array.new_default_with_rtt $bytes + (array.new_default $bytes (i32.const 200) - (rtt.canon $bytes) ) ) (array.set $bytes @@ -467,55 +362,12 @@ (array.get_u $bytes (local.get $x) (i32.const 12)) ) ) - (func "rtt_Fresh" - ;; Casting to the same sequence of rtt.subs works. - (call $log - (ref.test - (struct.new_default_with_rtt $extendedstruct - (rtt.sub $extendedstruct - (rtt.canon $struct) - ) - ) - (rtt.sub $extendedstruct - (rtt.canon $struct) - ) - ) - ) - ;; But not with fresh! - (call $log - (ref.test - (struct.new_default_with_rtt $extendedstruct - (rtt.sub $extendedstruct - (rtt.canon $struct) - ) - ) - (rtt.fresh_sub $extendedstruct - (rtt.canon $struct) - ) - ) - ) - ;; Casts with fresh succeed, if we use the same fresh rtt. - (global.set $rtt - (rtt.fresh_sub $extendedstruct - (rtt.canon $struct) - ) - ) - (call $log - (ref.test - (struct.new_default_with_rtt $extendedstruct - (global.get $rtt) - ) - (global.get $rtt) - ) - ) - ) (func "array.init" (local $x (ref null $bytes)) (local.set $x - (array.init $bytes + (array.init_static $bytes (i32.const 42) ;; first value (i32.const 50) ;; second value - (rtt.canon $bytes) ) ) ;; The length should be 2 @@ -534,9 +386,8 @@ (func "array.init-packed" (local $x (ref null $bytes)) (local.set $x - (array.init $bytes + (array.init_static $bytes (i32.const -11512) - (rtt.canon $bytes) ) ) ;; The value should be be -11512 & 255 => 8 @@ -574,9 +425,7 @@ (struct.new_default $struct) ) ) - ;; Casting to a supertype does not work because the canonical RTT for the - ;; subtype is not a sub-rtt of the canonical RTT of the supertype in - ;; structural mode. + ;; Casting to a supertype works. (call $log (ref.test_static $struct (struct.new_default $extendedstruct) @@ -641,9 +490,8 @@ ;; opts the unused value is removed so there is no trap, and a value is ;; returned, which should not confuse the fuzzer. (drop - (array.new_default_with_rtt $[mut:i8] + (array.new_default $[mut:i8] (i32.const -1) - (rtt.canon $[mut:i8]) ) ) (i32.const 0) |