diff options
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 2b96e839c..b12cb50c7 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -35,6 +35,11 @@ void WasmBinaryWriter::prepare() { // Collect function types and their frequencies. Collect information in each // function in parallel, then merge. indexedTypes = ModuleUtils::getOptimizedIndexedHeapTypes(*wasm); + for (Index i = 0, size = indexedTypes.types.size(); i < size; ++i) { + if (indexedTypes.types[i].isSignature()) { + signatureIndexes.insert({indexedTypes.types[i].getSignature(), i}); + } + } importInfo = std::make_unique<ImportInfo>(*wasm); } @@ -686,6 +691,17 @@ uint32_t WasmBinaryWriter::getTypeIndex(HeapType type) const { return it->second; } +uint32_t WasmBinaryWriter::getSignatureIndex(Signature sig) const { + auto it = signatureIndexes.find(sig); +#ifndef NDEBUG + if (it == signatureIndexes.end()) { + std::cout << "Missing signature: " << sig << '\n'; + assert(0); + } +#endif + return it->second; +} + uint32_t WasmBinaryWriter::getStringIndex(Name string) const { auto it = stringIndexes.find(string); assert(it != stringIndexes.end()); |