|
32 | 32 | // |
33 | 33 | // Convert a module to be compatible with JavaScript promise integration (JSPI). |
34 | 34 | // 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" |
36 | 36 | // `WebAssembly.Function`. Suspending imports will also be wrapped, but they |
37 | 37 | // will take the stored suspender and pass it as the first param to the imported |
38 | 38 | // function that should be created from a "suspending" `WebAssembly.Function`. |
|
50 | 50 | // Wrap each export in the comma-separated list. Similar to jspi-imports, |
51 | 51 | // wildcards and separate files are supported. |
52 | 52 | // |
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 | | -// |
59 | 53 |
|
60 | 54 | namespace wasm { |
61 | 55 |
|
@@ -93,22 +87,6 @@ struct JSPI : public Pass { |
93 | 87 | read_possible_response_file(getArgumentOrDefault("jspi-exports", ""))); |
94 | 88 | String::Split listedExports(stateChangingExports, ","); |
95 | 89 |
|
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 | | - |
112 | 90 | // Create a global to store the suspender that is passed into exported |
113 | 91 | // functions and will then need to be passed out to the imported functions. |
114 | 92 | Name suspender = Names::getValidGlobalName(*module, "suspender"); |
@@ -168,7 +146,7 @@ struct JSPI : public Pass { |
168 | 146 | if (im->imported() && |
169 | 147 | canChangeState(getFullFunctionName(im->module, im->base), |
170 | 148 | listedImports)) { |
171 | | - makeWrapperForImport(im, module, suspender, wasmSplit); |
| 149 | + makeWrapperForImport(im, module, suspender); |
172 | 150 | } |
173 | 151 | } |
174 | 152 | } |
@@ -221,10 +199,7 @@ struct JSPI : public Pass { |
221 | 199 | return module->addFunction(std::move(wrapperFunc))->name; |
222 | 200 | } |
223 | 201 |
|
224 | | - void makeWrapperForImport(Function* im, |
225 | | - Module* module, |
226 | | - Name suspender, |
227 | | - bool wasmSplit) { |
| 202 | + void makeWrapperForImport(Function* im, Module* module, Name suspender) { |
228 | 203 | Builder builder(*module); |
229 | 204 | auto wrapperIm = std::make_unique<Function>(); |
230 | 205 | wrapperIm->name = Names::getValidFunctionName( |
@@ -278,15 +253,6 @@ struct JSPI : public Pass { |
278 | 253 | wrapperIm->type = |
279 | 254 | Type(Signature(Type(params), call->type), NonNullable, Inexact); |
280 | 255 |
|
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 | | - } |
290 | 256 | module->removeFunction(im->name); |
291 | 257 | module->addFunction(std::move(stub)); |
292 | 258 | module->addFunction(std::move(wrapperIm)); |
|
0 commit comments