diff options
author | Brendan Dahl <brendan.dahl@gmail.com> | 2023-03-01 11:13:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-01 11:13:19 -0800 |
commit | 76fcc26e5ca62b6aa0f2d07859ff5dd95e8f57e0 (patch) | |
tree | 4a16e28615c0777250d3d9d03654679b394643b4 /src | |
parent | 5b98e1896f16fc41d6a7b0d0c4ef0b7e1d72f420 (diff) | |
download | binaryen-76fcc26e5ca62b6aa0f2d07859ff5dd95e8f57e0.tar.gz binaryen-76fcc26e5ca62b6aa0f2d07859ff5dd95e8f57e0.tar.bz2 binaryen-76fcc26e5ca62b6aa0f2d07859ff5dd95e8f57e0.zip |
JSPI - Replace function table references with JSPI'ed wrapper. (#5519)
This makes it possible to get the JSPI'ed version of the function from the
function table.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/JSPI.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/passes/JSPI.cpp b/src/passes/JSPI.cpp index 01532bb38..a3b544bca 100644 --- a/src/passes/JSPI.cpp +++ b/src/passes/JSPI.cpp @@ -140,6 +140,24 @@ struct JSPI : public Pass { } } + // Replace any references to the original exports that are in the elements. + for (auto& segment : module->elementSegments) { + if (!segment->type.isFunction()) { + continue; + } + for (Index i = 0; i < segment->data.size(); i++) { + if (auto* get = segment->data[i]->dynCast<RefFunc>()) { + auto iter = wrappedExports.find(get->func); + if (iter == wrappedExports.end()) { + continue; + } + auto* replacementRef = builder.makeRefFunc( + iter->second, module->getFunction(iter->second)->type); + segment->data[i] = replacementRef; + } + } + } + // Avoid iterator invalidation later. std::vector<Function*> originalFunctions; for (auto& func : module->functions) { |