diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/module-splitting.cpp | 12 | ||||
-rw-r--r-- | src/ir/module-splitting.h | 4 | ||||
-rw-r--r-- | src/tools/wasm-split.cpp | 1 |
3 files changed, 15 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; diff --git a/src/ir/module-splitting.h b/src/ir/module-splitting.h index 9a2597067..479fba148 100644 --- a/src/ir/module-splitting.h +++ b/src/ir/module-splitting.h @@ -62,6 +62,10 @@ struct Config { // used to differentiate between "real" exports of the module and exports that // should only be consumed by the secondary module. std::string newExportPrefix = ""; + // Whether the export names of newly created exports should be minimized. If + // false, the original function names will be used (after `newExportPrefix`) + // as the new export names. + bool minimizeNewExportNames = false; }; // Returns the new secondary module and modifies the `primary` module in place. diff --git a/src/tools/wasm-split.cpp b/src/tools/wasm-split.cpp index 3ac8b2c45..7f3fe65c4 100644 --- a/src/tools/wasm-split.cpp +++ b/src/tools/wasm-split.cpp @@ -676,6 +676,7 @@ void splitModule(Module& wasm, const WasmSplitOptions& options) { if (options.exportPrefix.size()) { config.newExportPrefix = options.exportPrefix; } + config.minimizeNewExportNames = !options.passOptions.debugInfo; std::unique_ptr<Module> secondary = ModuleSplitting::splitFunctions(wasm, config); |