summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/module-splitting.cpp2
-rw-r--r--src/ir/module-splitting.h6
-rw-r--r--src/tools/wasm-split/wasm-split.cpp11
3 files changed, 7 insertions, 12 deletions
diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp
index 777818689..caa996b30 100644
--- a/src/ir/module-splitting.cpp
+++ b/src/ir/module-splitting.cpp
@@ -442,7 +442,7 @@ ModuleSplitter::classifyFunctions(Module& primary, const Config& config) {
// module since that would make them async when they may not have the JSPI
// wrapper. Exported JSPI functions can still benefit from splitting though
// since only the JSPI wrapper stub will remain in the primary module.
- if (func->imported() || config.primaryFuncs.count(func->name) ||
+ if (func->imported() || !config.secondaryFuncs.count(func->name) ||
(config.jspi && ExportUtils::isExported(primary, *func)) ||
segmentReferrers.count(func->name)) {
primaryFuncs.insert(func->name);
diff --git a/src/ir/module-splitting.h b/src/ir/module-splitting.h
index 620993d2d..89e4dd2bb 100644
--- a/src/ir/module-splitting.h
+++ b/src/ir/module-splitting.h
@@ -47,11 +47,11 @@ namespace wasm::ModuleSplitting {
static const Name LOAD_SECONDARY_MODULE("__load_secondary_module");
struct Config {
- // The set of functions to keep in the primary module. All others are split
- // out into the new secondary module. Must include the start function if it
+ // The set of functions to split into the secondary module. All others are
+ // kept in the primary module. Must not include the start function if it
// exists. May or may not include imported functions, which are always kept in
// the primary module regardless.
- std::set<Name> primaryFuncs;
+ std::set<Name> secondaryFuncs;
// Whether to import placeholder functions into the primary module that will
// be called when a secondary function is called before the secondary module
// has been loaded.
diff --git a/src/tools/wasm-split/wasm-split.cpp b/src/tools/wasm-split/wasm-split.cpp
index 1cfe5bad9..d26f6f1d6 100644
--- a/src/tools/wasm-split/wasm-split.cpp
+++ b/src/tools/wasm-split/wasm-split.cpp
@@ -221,7 +221,7 @@ void splitModule(const WasmSplitOptions& options) {
std::set<Name> splitFuncs;
if (options.profileFile.size()) {
- // Use the profile to set `keepFuncs`.
+ // Use the profile to set `keepFuncs` and `splitFuncs`.
uint64_t hash = hashFile(options.inputFiles[0]);
getFunctionsToKeepAndSplit(
wasm, hash, options.profileFile, keepFuncs, splitFuncs);
@@ -319,7 +319,7 @@ void splitModule(const WasmSplitOptions& options) {
// Actually perform the splitting
ModuleSplitting::Config config;
- config.primaryFuncs = std::move(keepFuncs);
+ config.secondaryFuncs = std::move(splitFuncs);
if (options.importNamespace.size()) {
config.importNamespace = options.importNamespace;
}
@@ -418,9 +418,6 @@ void multiSplitModule(const WasmSplitOptions& options) {
config.usePlaceholders = false;
config.importNamespace = "";
config.minimizeNewExportNames = true;
- for (auto& func : wasm.functions) {
- config.primaryFuncs.insert(func->name);
- }
for (auto& [mod, funcs] : moduleFuncs) {
if (options.verbose) {
std::cerr << "Splitting module " << mod << '\n';
@@ -428,9 +425,7 @@ void multiSplitModule(const WasmSplitOptions& options) {
if (!options.quiet && funcs.empty()) {
std::cerr << "warning: Module " << mod << " will be empty\n";
}
- for (auto& func : funcs) {
- config.primaryFuncs.erase(Name(func));
- }
+ config.secondaryFuncs = std::set<Name>(funcs.begin(), funcs.end());
auto splitResults = ModuleSplitting::splitFunctions(wasm, config);
// TODO: symbolMap, placeholderMap, emitModuleNames
// TODO: Support --emit-text and use .wast in that case.