diff options
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 5ebc4d864..36cb0fd1a 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -34,7 +34,7 @@ namespace wasm { void WasmBinaryWriter::prepare() { // Collect function types and their frequencies. Collect information in each // function in parallel, then merge. - ModuleUtils::collectHeapTypes(*wasm, types, typeIndices); + indexedTypes = ModuleUtils::getOptimizedIndexedHeapTypes(*wasm); importInfo = wasm::make_unique<ImportInfo>(*wasm); } @@ -216,14 +216,14 @@ void WasmBinaryWriter::writeMemory() { } void WasmBinaryWriter::writeTypes() { - if (types.size() == 0) { + if (indexedTypes.types.size() == 0) { return; } BYN_TRACE("== writeTypes\n"); auto start = startSection(BinaryConsts::Section::Type); - o << U32LEB(types.size()); - for (Index i = 0; i < types.size(); ++i) { - auto type = types[i]; + o << U32LEB(indexedTypes.types.size()); + for (Index i = 0; i < indexedTypes.types.size(); ++i) { + auto type = indexedTypes.types[i]; bool nominal = type.isNominal() || getTypeSystem() == TypeSystem::Nominal; BYN_TRACE("write " << type << std::endl); if (type.isSignature()) { @@ -539,9 +539,9 @@ uint32_t WasmBinaryWriter::getTagIndex(Name name) const { } uint32_t WasmBinaryWriter::getTypeIndex(HeapType type) const { - auto it = typeIndices.find(type); + auto it = indexedTypes.indices.find(type); #ifndef NDEBUG - if (it == typeIndices.end()) { + if (it == indexedTypes.indices.end()) { std::cout << "Missing type: " << type << '\n'; assert(0); } @@ -774,7 +774,7 @@ void WasmBinaryWriter::writeNames() { // type names { std::vector<HeapType> namedTypes; - for (auto& [type, _] : typeIndices) { + for (auto& [type, _] : indexedTypes.indices) { if (wasm->typeNames.count(type) && wasm->typeNames[type].name.is()) { namedTypes.push_back(type); } @@ -784,7 +784,7 @@ void WasmBinaryWriter::writeNames() { startSubsection(BinaryConsts::UserSections::Subsection::NameType); o << U32LEB(namedTypes.size()); for (auto type : namedTypes) { - o << U32LEB(typeIndices[type]); + o << U32LEB(indexedTypes.indices[type]); writeEscapedName(wasm->typeNames[type].name.str); } finishSubsection(substart); @@ -909,7 +909,7 @@ void WasmBinaryWriter::writeNames() { // GC field names if (wasm->features.hasGC()) { std::vector<HeapType> relevantTypes; - for (auto& type : types) { + for (auto& type : indexedTypes.types) { if (type.isStruct() && wasm->typeNames.count(type) && !wasm->typeNames[type].fieldNames.empty()) { relevantTypes.push_back(type); @@ -921,7 +921,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(relevantTypes.size()); for (Index i = 0; i < relevantTypes.size(); i++) { auto type = relevantTypes[i]; - o << U32LEB(typeIndices[type]); + o << U32LEB(indexedTypes.indices[type]); std::unordered_map<Index, Name>& fieldNames = wasm->typeNames.at(type).fieldNames; o << U32LEB(fieldNames.size()); |