Skip to content

Commit 4ea0b0e

Browse files
authored
[module-splitting] Remove jspi-split-module (#8200)
This no longer used by emscripten, and the TODO suggests it should be removed.
1 parent 9044082 commit 4ea0b0e

File tree

3 files changed

+12
-91
lines changed

3 files changed

+12
-91
lines changed

src/ir/module-splitting.cpp

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@ struct ModuleSplitter {
320320
// replace.
321321
std::unordered_map<Name, std::map<size_t, Name>> placeholderMap;
322322

323-
// Internal name of the LOAD_SECONDARY_MODULE function.
324-
Name internalLoadSecondaryModule;
325-
326323
// Map from original secondary function name to its trampoline
327324
std::unordered_map<Name, Name> trampolineMap;
328325

@@ -367,26 +364,14 @@ struct ModuleSplitter {
367364
};
368365

369366
void ModuleSplitter::setupJSPI() {
370-
// Support the first version of JSPI, where the JSPI pass added the load
371-
// secondary module export.
372-
// TODO: remove this when the new JSPI API is only supported.
373-
if (auto* loadSecondary = primary.getExportOrNull(LOAD_SECONDARY_MODULE);
374-
loadSecondary && loadSecondary->kind == ExternalKind::Function) {
375-
internalLoadSecondaryModule = *loadSecondary->getInternalName();
376-
// Remove the exported LOAD_SECONDARY_MODULE function since it's only needed
377-
// internally.
378-
primary.removeExport(LOAD_SECONDARY_MODULE);
379-
} else {
380-
// Add an imported function to load the secondary module.
381-
auto import = Builder::makeFunction(
382-
ModuleSplitting::LOAD_SECONDARY_MODULE,
383-
Type(Signature(Type::none, Type::none), NonNullable, Inexact),
384-
{});
385-
import->module = ENV;
386-
import->base = ModuleSplitting::LOAD_SECONDARY_MODULE;
387-
primary.addFunction(std::move(import));
388-
internalLoadSecondaryModule = ModuleSplitting::LOAD_SECONDARY_MODULE;
389-
}
367+
// Add an imported function to load the secondary module.
368+
auto import = Builder::makeFunction(
369+
ModuleSplitting::LOAD_SECONDARY_MODULE,
370+
Type(Signature(Type::none, Type::none), NonNullable, Inexact),
371+
{});
372+
import->module = ENV;
373+
import->base = ModuleSplitting::LOAD_SECONDARY_MODULE;
374+
primary.addFunction(std::move(import));
390375
Builder builder(primary);
391376
// Add a global to track whether the secondary module has been loaded yet.
392377
primary.addGlobal(builder.makeGlobal(LOAD_SECONDARY_STATUS,
@@ -600,7 +585,7 @@ Expression* ModuleSplitter::maybeLoadSecondary(Builder& builder,
600585
auto* loadSecondary = builder.makeIf(
601586
builder.makeUnary(EqZInt32,
602587
builder.makeGlobalGet(LOAD_SECONDARY_STATUS, Type::i32)),
603-
builder.makeCall(internalLoadSecondaryModule, {}, Type::none));
588+
builder.makeCall(ModuleSplitting::LOAD_SECONDARY_MODULE, {}, Type::none));
604589
return builder.makeSequence(loadSecondary, callIndirect);
605590
}
606591

src/passes/JSPI.cpp

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
//
3333
// Convert a module to be compatible with JavaScript promise integration (JSPI).
3434
// Promising exports will be wrapped with a function that will handle storing
35-
// the suspsender that is passed in as the first param from a "promising"
35+
// the suspender that is passed in as the first param from a "promising"
3636
// `WebAssembly.Function`. Suspending imports will also be wrapped, but they
3737
// will take the stored suspender and pass it as the first param to the imported
3838
// function that should be created from a "suspending" `WebAssembly.Function`.
@@ -50,12 +50,6 @@
5050
// Wrap each export in the comma-separated list. Similar to jspi-imports,
5151
// wildcards and separate files are supported.
5252
//
53-
// --pass-arg=jspi-split-module
54-
//
55-
// Enables integration with wasm-split. A JSPI'ed function named
56-
// `__load_secondary_module` will be injected that is used by wasm-split to
57-
// load a secondary module.
58-
//
5953

6054
namespace wasm {
6155

@@ -93,22 +87,6 @@ struct JSPI : public Pass {
9387
read_possible_response_file(getArgumentOrDefault("jspi-exports", "")));
9488
String::Split listedExports(stateChangingExports, ",");
9589

96-
bool wasmSplit = hasArgument("jspi-split-module");
97-
if (wasmSplit) {
98-
// Make an import for the load secondary module function so a JSPI wrapper
99-
// version will be created.
100-
auto import = Builder::makeFunction(
101-
ModuleSplitting::LOAD_SECONDARY_MODULE,
102-
Type(Signature(Type::none, Type::none), NonNullable, Inexact),
103-
{});
104-
import->module = ENV;
105-
import->base = ModuleSplitting::LOAD_SECONDARY_MODULE;
106-
module->addFunction(std::move(import));
107-
listedImports.push_back(
108-
ENV.toString() + "." +
109-
ModuleSplitting::LOAD_SECONDARY_MODULE.toString());
110-
}
111-
11290
// Create a global to store the suspender that is passed into exported
11391
// functions and will then need to be passed out to the imported functions.
11492
Name suspender = Names::getValidGlobalName(*module, "suspender");
@@ -168,7 +146,7 @@ struct JSPI : public Pass {
168146
if (im->imported() &&
169147
canChangeState(getFullFunctionName(im->module, im->base),
170148
listedImports)) {
171-
makeWrapperForImport(im, module, suspender, wasmSplit);
149+
makeWrapperForImport(im, module, suspender);
172150
}
173151
}
174152
}
@@ -221,10 +199,7 @@ struct JSPI : public Pass {
221199
return module->addFunction(std::move(wrapperFunc))->name;
222200
}
223201

224-
void makeWrapperForImport(Function* im,
225-
Module* module,
226-
Name suspender,
227-
bool wasmSplit) {
202+
void makeWrapperForImport(Function* im, Module* module, Name suspender) {
228203
Builder builder(*module);
229204
auto wrapperIm = std::make_unique<Function>();
230205
wrapperIm->name = Names::getValidFunctionName(
@@ -278,15 +253,6 @@ struct JSPI : public Pass {
278253
wrapperIm->type =
279254
Type(Signature(Type(params), call->type), NonNullable, Inexact);
280255

281-
if (wasmSplit && im->name == ModuleSplitting::LOAD_SECONDARY_MODULE) {
282-
// In non-debug builds the name of the JSPI wrapper function for loading
283-
// the secondary module will be removed. Create an export of it so that
284-
// wasm-split can find it.
285-
module->addExport(
286-
builder.makeExport(ModuleSplitting::LOAD_SECONDARY_MODULE,
287-
ModuleSplitting::LOAD_SECONDARY_MODULE,
288-
ExternalKind::Function));
289-
}
290256
module->removeFunction(im->name);
291257
module->addFunction(std::move(stub));
292258
module->addFunction(std::move(wrapperIm));

test/lit/passes/jspi-split-module.wast

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)