Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/passes/Unsubtyping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,10 @@ struct Unsubtyping : Pass, Noter<Unsubtyping> {
noteSubtype(elem.type, super.getArray().element.type);
break;
}
case HeapTypeKind::Cont:
WASM_UNREACHABLE("TODO: cont");
case HeapTypeKind::Cont: {
noteSubtype(sub.getContinuation().type, super.getContinuation().type);
break;
}
case HeapTypeKind::Basic:
WASM_UNREACHABLE("unexpected kind");
}
Expand Down
47 changes: 47 additions & 0 deletions test/lit/passes/unsubtyping-stack-switching.wast
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,50 @@
)
)

(module
;; CHECK: (rec
;; CHECK-NEXT: (type $super (sub (func)))
(type $super (sub (func)))
;; CHECK: (type $sub (sub $super (func)))
(type $sub (sub $super (func)))
;; CHECK: (type $cont-super (sub (cont $super)))
(type $cont-super (sub (cont $super)))
;; CHECK: (type $cont-sub (sub $cont-super (cont $sub)))
(type $cont-sub (sub $cont-super (cont $sub)))

;; CHECK: (type $4 (func (param (ref $cont-sub)) (result (ref $cont-super))))

;; CHECK: (func $cont-new (type $4) (param $sub (ref $cont-sub)) (result (ref $cont-super))
;; CHECK-NEXT: (local.get $sub)
;; CHECK-NEXT: )
(func $cont-new (param $sub (ref $cont-sub)) (result (ref $cont-super))
;; This requires $cont-sub <: $cont-super and $sub <: $super.
(local.get $sub)
)
)

(module
;; CHECK: (rec
;; CHECK-NEXT: (type $super (sub (func)))
(type $super (sub (func)))
;; CHECK: (type $sub (sub (func)))
(type $sub (sub $super (func)))
;; CHECK: (type $cont-super (sub (cont $super)))
(type $cont-super (sub (cont $super)))
;; CHECK: (type $cont-sub (sub (cont $sub)))
(type $cont-sub (sub $cont-super (cont $sub)))

;; CHECK: (type $4 (func (param (ref $cont-sub)) (result (ref $cont-sub))))

;; CHECK: (func $cont-new (type $4) (param $sub (ref $cont-sub)) (result (ref $cont-sub))
;; CHECK-NEXT: (local $keepalive (ref $cont-super))
;; CHECK-NEXT: (local.get $sub)
;; CHECK-NEXT: )
(func $cont-new (param $sub (ref $cont-sub)) (result (ref $cont-sub))
(local $keepalive (ref $cont-super))
;; As above, but now we return the subtype, so there is no constraint. We
;; can unsubtype both the continuations and the funcs.
(local.get $sub)
)
)

Loading