summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-emscripten.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-emscripten.cpp')
-rw-r--r--src/wasm/wasm-emscripten.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp
index ae7e7f871..f069e558d 100644
--- a/src/wasm/wasm-emscripten.cpp
+++ b/src/wasm/wasm-emscripten.cpp
@@ -996,9 +996,8 @@ struct FixInvokeFunctionNamesWalker
std::vector<Name> toRemove;
std::set<Name> newImports;
std::set<Signature> invokeSigs;
- ImportInfo imports;
- FixInvokeFunctionNamesWalker(Module& _wasm) : wasm(_wasm), imports(wasm) {}
+ FixInvokeFunctionNamesWalker(Module& _wasm) : wasm(_wasm) {}
// Converts invoke wrapper names generated by LLVM backend to real invoke
// wrapper names that are expected by JavaScript glue code.
@@ -1053,18 +1052,15 @@ struct FixInvokeFunctionNamesWalker
return;
}
- BYN_TRACE("renaming import: " << curr->module << "." << curr->base << " ("
- << curr->name << ") -> " << newname << "\n");
- assert(importRenames.count(curr->base) == 0);
- importRenames[curr->base] = newname;
+ assert(importRenames.count(curr->name) == 0);
+ BYN_TRACE("renaming: " << curr->name << " -> " << newname << "\n");
+ importRenames[curr->name] = newname;
// Either rename or remove the existing import
- if (imports.getImportedFunction(curr->module, newname) ||
- !newImports.insert(newname).second) {
- BYN_TRACE("using existing import\n");
+ if (wasm.getFunctionOrNull(newname) || !newImports.insert(newname).second) {
toRemove.push_back(curr->name);
} else {
- BYN_TRACE("renaming import\n");
curr->base = newname;
+ curr->name = newname;
}
}
@@ -1073,11 +1069,10 @@ struct FixInvokeFunctionNamesWalker
wasm.removeFunction(importName);
}
ModuleUtils::renameFunctions(wasm, importRenames);
- // Update any associated GOT.func imports.
+ ImportInfo imports(wasm);
for (auto& pair : importRenames) {
+ // Update any associated GOT.func import.
if (auto g = imports.getImportedGlobal("GOT.func", pair.first)) {
- BYN_TRACE("renaming corresponding GOT entry: " << g->base << " -> "
- << pair.second << "\n");
g->base = pair.second;
}
}