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
1 change: 1 addition & 0 deletions scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ def is_git_repo():
'shared-absheaptype.wast',
'type-ssa-shared.wast',
'shared-ref_eq.wast',
'shared-null-no-gc.wast',
]


Expand Down
15 changes: 1 addition & 14 deletions src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,20 +1629,7 @@ void WasmBinaryWriter::writeHeapType(HeapType type) {
// only actually valid with GC. Otherwise, emit the corresponding valid top
// types instead.
if (!wasm->features.hasGC()) {
if (HeapType::isSubType(type, HeapType::func)) {
type = HeapType::func;
} else if (HeapType::isSubType(type, HeapType::ext)) {
type = HeapType::ext;
} else if (HeapType::isSubType(type, HeapType::exn)) {
type = HeapType::exn;
} else if (wasm->features.hasStrings()) {
// Strings are enabled, and this isn't a func or an ext, so it must be a
// string type (string or stringview), which we'll emit below, or a bottom
// type (which we must allow, because we wouldn't know whether to emit a
// string or stringview for it).
} else {
WASM_UNREACHABLE("invalid type without GC");
}
type = type.getTop();
}

if (!type.isBasic()) {
Expand Down
19 changes: 19 additions & 0 deletions test/lit/basic/shared-null-no-gc.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.

;; Test that we can write a binary without crashing when using a shared bottom
;; type without GC enabled.

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

(module
;; CHECK: (func $test
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.null (shared nofunc))
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $test
(drop
(ref.null (shared func))
)
)
)