diff options
Diffstat (limited to 'test/lit/passes/simplify-locals-gc.wast')
-rw-r--r-- | test/lit/passes/simplify-locals-gc.wast | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast index 33e4d1bd5..a930cae08 100644 --- a/test/lit/passes/simplify-locals-gc.wast +++ b/test/lit/passes/simplify-locals-gc.wast @@ -13,6 +13,17 @@ ;; NOMNL: (type $struct-immutable (struct_subtype (field i32) data)) (type $struct-immutable (struct (field i32))) + ;; CHECK: (type $B (struct (field dataref))) + + ;; CHECK: (type $A (struct (field (ref null data)))) + ;; NOMNL: (type $A (struct_subtype (field (ref null data)) data)) + (type $A (struct_subtype (field (ref null data)) data)) + + ;; $B is a subtype of $A, and its field has a more refined type (it is non- + ;; nullable). + ;; NOMNL: (type $B (struct_subtype (field dataref) $A)) + (type $B (struct_subtype (field (ref data)) $A)) + ;; Writes to heap objects cannot be reordered with reads. ;; CHECK: (func $no-reorder-past-write (param $x (ref $struct)) (result i32) ;; CHECK-NEXT: (local $temp i32) @@ -214,4 +225,31 @@ ) ) ) + + ;; CHECK: (func $needs-refinalize (param $b (ref $B)) (result anyref) + ;; CHECK-NEXT: (local $a (ref null $A)) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (struct.get $B 0 + ;; CHECK-NEXT: (local.get $b) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; NOMNL: (func $needs-refinalize (type $ref|$B|_=>_anyref) (param $b (ref $B)) (result anyref) + ;; NOMNL-NEXT: (local $a (ref null $A)) + ;; NOMNL-NEXT: (nop) + ;; NOMNL-NEXT: (struct.get $B 0 + ;; NOMNL-NEXT: (local.get $b) + ;; NOMNL-NEXT: ) + ;; NOMNL-NEXT: ) + (func $needs-refinalize (param $b (ref $B)) (result anyref) + (local $a (ref null $A)) + (local.set $a + (local.get $b) + ) + ;; This begins as a struct.get of $A, but after we move the set's value onto + ;; the get, we'll be reading from $B. $B's field has a more refined type, so + ;; we must update the type of the struct.get using refinalize. + (struct.get $A 0 + (local.get $a) + ) + ) ) |