Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void WasmBinaryWriter::writeTypes() {
break;
case HeapTypeKind::Cont:
o << uint8_t(BinaryConsts::EncodedType::Cont);
writeHeapType(type.getContinuation().type, Inexact);
writeIndexedHeapType(type.getContinuation().type);
break;
case HeapTypeKind::Basic:
WASM_UNREACHABLE("unexpected kind");
Expand Down
4 changes: 3 additions & 1 deletion src/wasm/wasm-stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ void BinaryInstWriter::visitCallIndirect(CallIndirect* curr) {
Index tableIdx = parent.getTableIndex(curr->table);
int8_t op =
curr->isReturn ? BinaryConsts::RetCallIndirect : BinaryConsts::CallIndirect;
o << op << U32LEB(parent.getTypeIndex(curr->heapType)) << U32LEB(tableIdx);
o << op;
parent.writeIndexedHeapType(curr->heapType);
o << U32LEB(tableIdx);
}

void BinaryInstWriter::visitLocalGet(LocalGet* curr) {
Expand Down
29 changes: 29 additions & 0 deletions test/lit/basic/cont-no-gc.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.

;; Test that we can write a binary without erroring when using stack switching
;; without GC. This verifies we can emit continuation types properly even when
;; GC is disabled

;; RUN: wasm-opt %s --enable-stack-switching --enable-reference-types --roundtrip -S -o - | filecheck %s

(module
;; CHECK: (type $proc (func))
(type $proc (func))
;; CHECK: (type $cont (cont $proc))
(type $cont (cont $proc))

;; CHECK: (func $main
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (cont.new $cont
;; CHECK-NEXT: (ref.func $main)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $main
(drop
(cont.new $cont
(ref.func $main)
)
Comment on lines +24 to +26
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this doesn't make any sense without typed function references. If the ref.func is just a funcref, then there's no way to validate that the continuation type has the the same parameters as the type of the function reference it is initialized with.

And we don't differentiate between typed-function-references and gc as features, so continuations without GC simply don't make sense.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, wasn't there an effort to avoid continuations from depending on GC?

Anyhow, I'm fine with making stack switching depend on GC, is that the right thing then?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but they still depend on typed function references, and we don't differentiate between that and GC. So making stack switching depend on GC is the right thing for our purposes. We can revisit this in the future (probably by adding a separate typed-function-references feature again) if anyone really needs it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I opened #7830 and will close this.

)
)
)
Loading