summaryrefslogtreecommitdiff
path: root/src/tools/wasm-split
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2021-09-08 13:13:33 -0700
committerGitHub <noreply@github.com>2021-09-08 13:13:33 -0700
commitd3e70f90d5b6ca975af8f19f171e4190d3652913 (patch)
tree3a619c28ede041d06197eda2081f486f81c455c5 /src/tools/wasm-split
parente7de93e58f2c5cfdfc136285b29d84b1f8a559cb (diff)
downloadbinaryen-d3e70f90d5b6ca975af8f19f171e4190d3652913.tar.gz
binaryen-d3e70f90d5b6ca975af8f19f171e4190d3652913.tar.bz2
binaryen-d3e70f90d5b6ca975af8f19f171e4190d3652913.zip
[wasm-split] Do not add exports of imported memories (#4133)
We can assume that imported memories (and the profiling data they contain) are already accessible from the module's environment, so there's no need to export them. This also avoids needing to add knowledge of "profile-memory" to Emscripten's library_dylink.js.
Diffstat (limited to 'src/tools/wasm-split')
-rw-r--r--src/tools/wasm-split/instrumenter.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/tools/wasm-split/instrumenter.cpp b/src/tools/wasm-split/instrumenter.cpp
index 36875bfc0..c23a70f06 100644
--- a/src/tools/wasm-split/instrumenter.cpp
+++ b/src/tools/wasm-split/instrumenter.cpp
@@ -266,19 +266,21 @@ void Instrumenter::addProfileExport() {
}
}
- // Export the memory if it is not already exported.
- bool memoryExported = false;
- for (auto& ex : wasm->exports) {
- if (ex->kind == ExternalKind::Memory) {
- memoryExported = true;
- break;
+ // Export the memory if it is not already exported or imported.
+ if (!wasm->memory.imported()) {
+ bool memoryExported = false;
+ for (auto& ex : wasm->exports) {
+ if (ex->kind == ExternalKind::Memory) {
+ memoryExported = true;
+ break;
+ }
+ }
+ if (!memoryExported) {
+ wasm->addExport(
+ Builder::makeExport("profile-memory",
+ Names::getValidExportName(*wasm, wasm->memory.name),
+ ExternalKind::Memory));
}
- }
- if (!memoryExported) {
- wasm->addExport(
- Builder::makeExport("profile-memory",
- Names::getValidExportName(*wasm, wasm->memory.name),
- ExternalKind::Memory));
}
}