diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index 7438f8e695f..797314e9f34 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -320,9 +320,6 @@ struct ModuleSplitter { // replace. std::unordered_map> placeholderMap; - // Internal name of the LOAD_SECONDARY_MODULE function. - Name internalLoadSecondaryModule; - // Map from original secondary function name to its trampoline std::unordered_map trampolineMap; @@ -367,26 +364,14 @@ struct ModuleSplitter { }; void ModuleSplitter::setupJSPI() { - // Support the first version of JSPI, where the JSPI pass added the load - // secondary module export. - // TODO: remove this when the new JSPI API is only supported. - if (auto* loadSecondary = primary.getExportOrNull(LOAD_SECONDARY_MODULE); - loadSecondary && loadSecondary->kind == ExternalKind::Function) { - internalLoadSecondaryModule = *loadSecondary->getInternalName(); - // Remove the exported LOAD_SECONDARY_MODULE function since it's only needed - // internally. - primary.removeExport(LOAD_SECONDARY_MODULE); - } else { - // Add an imported function to load the secondary module. - auto import = Builder::makeFunction( - ModuleSplitting::LOAD_SECONDARY_MODULE, - Type(Signature(Type::none, Type::none), NonNullable, Inexact), - {}); - import->module = ENV; - import->base = ModuleSplitting::LOAD_SECONDARY_MODULE; - primary.addFunction(std::move(import)); - internalLoadSecondaryModule = ModuleSplitting::LOAD_SECONDARY_MODULE; - } + // Add an imported function to load the secondary module. + auto import = Builder::makeFunction( + ModuleSplitting::LOAD_SECONDARY_MODULE, + Type(Signature(Type::none, Type::none), NonNullable, Inexact), + {}); + import->module = ENV; + import->base = ModuleSplitting::LOAD_SECONDARY_MODULE; + primary.addFunction(std::move(import)); Builder builder(primary); // Add a global to track whether the secondary module has been loaded yet. primary.addGlobal(builder.makeGlobal(LOAD_SECONDARY_STATUS, @@ -600,7 +585,7 @@ Expression* ModuleSplitter::maybeLoadSecondary(Builder& builder, auto* loadSecondary = builder.makeIf( builder.makeUnary(EqZInt32, builder.makeGlobalGet(LOAD_SECONDARY_STATUS, Type::i32)), - builder.makeCall(internalLoadSecondaryModule, {}, Type::none)); + builder.makeCall(ModuleSplitting::LOAD_SECONDARY_MODULE, {}, Type::none)); return builder.makeSequence(loadSecondary, callIndirect); } diff --git a/src/passes/JSPI.cpp b/src/passes/JSPI.cpp index 7d42aad118c..192b5dfa9e6 100644 --- a/src/passes/JSPI.cpp +++ b/src/passes/JSPI.cpp @@ -32,7 +32,7 @@ // // Convert a module to be compatible with JavaScript promise integration (JSPI). // Promising exports will be wrapped with a function that will handle storing -// the suspsender that is passed in as the first param from a "promising" +// the suspender that is passed in as the first param from a "promising" // `WebAssembly.Function`. Suspending imports will also be wrapped, but they // will take the stored suspender and pass it as the first param to the imported // function that should be created from a "suspending" `WebAssembly.Function`. @@ -50,12 +50,6 @@ // Wrap each export in the comma-separated list. Similar to jspi-imports, // wildcards and separate files are supported. // -// --pass-arg=jspi-split-module -// -// Enables integration with wasm-split. A JSPI'ed function named -// `__load_secondary_module` will be injected that is used by wasm-split to -// load a secondary module. -// namespace wasm { @@ -93,22 +87,6 @@ struct JSPI : public Pass { read_possible_response_file(getArgumentOrDefault("jspi-exports", ""))); String::Split listedExports(stateChangingExports, ","); - bool wasmSplit = hasArgument("jspi-split-module"); - if (wasmSplit) { - // Make an import for the load secondary module function so a JSPI wrapper - // version will be created. - auto import = Builder::makeFunction( - ModuleSplitting::LOAD_SECONDARY_MODULE, - Type(Signature(Type::none, Type::none), NonNullable, Inexact), - {}); - import->module = ENV; - import->base = ModuleSplitting::LOAD_SECONDARY_MODULE; - module->addFunction(std::move(import)); - listedImports.push_back( - ENV.toString() + "." + - ModuleSplitting::LOAD_SECONDARY_MODULE.toString()); - } - // Create a global to store the suspender that is passed into exported // functions and will then need to be passed out to the imported functions. Name suspender = Names::getValidGlobalName(*module, "suspender"); @@ -168,7 +146,7 @@ struct JSPI : public Pass { if (im->imported() && canChangeState(getFullFunctionName(im->module, im->base), listedImports)) { - makeWrapperForImport(im, module, suspender, wasmSplit); + makeWrapperForImport(im, module, suspender); } } } @@ -221,10 +199,7 @@ struct JSPI : public Pass { return module->addFunction(std::move(wrapperFunc))->name; } - void makeWrapperForImport(Function* im, - Module* module, - Name suspender, - bool wasmSplit) { + void makeWrapperForImport(Function* im, Module* module, Name suspender) { Builder builder(*module); auto wrapperIm = std::make_unique(); wrapperIm->name = Names::getValidFunctionName( @@ -278,15 +253,6 @@ struct JSPI : public Pass { wrapperIm->type = Type(Signature(Type(params), call->type), NonNullable, Inexact); - if (wasmSplit && im->name == ModuleSplitting::LOAD_SECONDARY_MODULE) { - // In non-debug builds the name of the JSPI wrapper function for loading - // the secondary module will be removed. Create an export of it so that - // wasm-split can find it. - module->addExport( - builder.makeExport(ModuleSplitting::LOAD_SECONDARY_MODULE, - ModuleSplitting::LOAD_SECONDARY_MODULE, - ExternalKind::Function)); - } module->removeFunction(im->name); module->addFunction(std::move(stub)); module->addFunction(std::move(wrapperIm)); diff --git a/test/lit/passes/jspi-split-module.wast b/test/lit/passes/jspi-split-module.wast deleted file mode 100644 index e14e508bf70..00000000000 --- a/test/lit/passes/jspi-split-module.wast +++ /dev/null @@ -1,30 +0,0 @@ -;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. -;; RUN: wasm-opt %s --jspi --pass-arg=jspi-split-module -all -S -o - | filecheck %s - -;; The following should be generated besides the usual JSPI wasm: -;; - function import -;; - JSPI'ed version of the import -;; - export of the above -(module) -;; CHECK: (type $0 (func)) - -;; CHECK: (type $1 (func (param externref))) - -;; CHECK: (import "env" "__load_secondary_module" (func $import$__load_secondary_module (type $1) (param externref))) - -;; CHECK: (global $suspender (mut externref) (ref.null noextern)) - -;; CHECK: (export "__load_secondary_module" (func $__load_secondary_module)) - -;; CHECK: (func $__load_secondary_module (type $0) -;; CHECK-NEXT: (local $0 externref) -;; CHECK-NEXT: (local.set $0 -;; CHECK-NEXT: (global.get $suspender) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (call $import$__load_secondary_module -;; CHECK-NEXT: (global.get $suspender) -;; CHECK-NEXT: ) -;; CHECK-NEXT: (global.set $suspender -;; CHECK-NEXT: (local.get $0) -;; CHECK-NEXT: ) -;; CHECK-NEXT: )