diff options
Diffstat (limited to 'src/ir')
-rw-r--r-- | src/ir/module-splitting.cpp | 12 | ||||
-rw-r--r-- | src/ir/module-splitting.h | 4 |
2 files changed, 14 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. |