summaryrefslogtreecommitdiff
path: root/src/ir/module-splitting.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-06-01 12:15:24 -0400
committerGitHub <noreply@github.com>2021-06-01 09:15:24 -0700
commit028f47368fe844130f52ad7811c8028ebd18a38e (patch)
tree7c6b2a68a55f922d70f534abd594d900079139b3 /src/ir/module-splitting.cpp
parent88606f75b97ef3014edb74484125534c2040095b (diff)
downloadbinaryen-028f47368fe844130f52ad7811c8028ebd18a38e.tar.gz
binaryen-028f47368fe844130f52ad7811c8028ebd18a38e.tar.bz2
binaryen-028f47368fe844130f52ad7811c8028ebd18a38e.zip
[wasm-split] Minimize names of newly created exports (#3905)
wasm-split would previously use internal function names to create the external names of the functions that are newly exported from the primary module to be imported into the secondary module. When the input module contains full function names (as is commonly the case when emitting symbol maps), this caused the function names to be preserved as the export names, even when names are otherwise being stripped. To save on code size and properly anonymize functions, generate minimal export names when debuginfo is disabled instead.
Diffstat (limited to 'src/ir/module-splitting.cpp')
-rw-r--r--src/ir/module-splitting.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp
index 5f9ba0aad..d6dca8994 100644
--- a/src/ir/module-splitting.cpp
+++ b/src/ir/module-splitting.cpp
@@ -266,6 +266,8 @@ struct ModuleSplitter {
TableSlotManager tableManager;
+ Names::MinifiedNameGenerator minified;
+
// Map from internal function names to (one of) their corresponding export
// names.
std::map<Name, Name> exportedPrimaryFuncs;
@@ -344,8 +346,14 @@ void ModuleSplitter::exportImportFunction(Name funcName) {
if (exportIt != exportedPrimaryFuncs.end()) {
exportName = exportIt->second;
} else {
- exportName = Names::getValidExportName(
- primary, config.newExportPrefix + funcName.c_str());
+ if (config.minimizeNewExportNames) {
+ do {
+ exportName = config.newExportPrefix + minified.getName();
+ } while (primary.getExportOrNull(exportName) != nullptr);
+ } else {
+ exportName = Names::getValidExportName(
+ primary, config.newExportPrefix + funcName.c_str());
+ }
primary.addExport(
Builder::makeExport(exportName, funcName, ExternalKind::Function));
exportedPrimaryFuncs[funcName] = exportName;