summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 7a6d4d35d..54e417b8c 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -31,7 +31,7 @@ namespace wasm {
void WasmBinaryWriter::prepare() {
// Collect function types and their frequencies. Collect information in each
// function in parallel, then merge.
- ModuleUtils::collectSignatures(*wasm, types, typeIndices);
+ ModuleUtils::collectHeapTypes(*wasm, types, typeIndices);
importInfo = wasm::make_unique<ImportInfo>(*wasm);
}
@@ -215,14 +215,19 @@ void WasmBinaryWriter::writeTypes() {
auto start = startSection(BinaryConsts::Section::Type);
o << U32LEB(types.size());
for (Index i = 0; i < types.size(); ++i) {
- Signature& sig = types[i];
- BYN_TRACE("write " << sig.params << " -> " << sig.results << std::endl);
- o << S32LEB(BinaryConsts::EncodedType::Func);
- for (auto& sigType : {sig.params, sig.results}) {
- o << U32LEB(sigType.size());
- for (const auto& type : sigType) {
- writeType(type);
+ auto type = types[i];
+ BYN_TRACE("write " << type << std::endl);
+ if (type.isSignature()) {
+ o << S32LEB(BinaryConsts::EncodedType::Func);
+ auto sig = type.getSignature();
+ for (auto& sigType : {sig.params, sig.results}) {
+ o << U32LEB(sigType.size());
+ for (const auto& type : sigType) {
+ writeType(type);
+ }
}
+ } else {
+ WASM_UNREACHABLE("TODO GC type writing");
}
}
finishSection(start);