summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-09-10 12:49:40 -0700
committerGitHub <noreply@github.com>2020-09-10 12:49:40 -0700
commit739144d96d162b430d5fd54e4fe11b8ce2d34d47 (patch)
tree841a3dd2cbf2ebdf350cc9225c9ad4065b37fdd8 /src
parent2aa0cf300998c62aea8cc6698f8325653a9f0895 (diff)
downloadbinaryen-739144d96d162b430d5fd54e4fe11b8ce2d34d47.tar.gz
binaryen-739144d96d162b430d5fd54e4fe11b8ce2d34d47.tar.bz2
binaryen-739144d96d162b430d5fd54e4fe11b8ce2d34d47.zip
Fix wasm2js memory import in case it is minified (#3113)
It was hardcoded as "env.memory", which is usually correct. But if we minify import names, as in -O3 in emscripten, we need to use the minified name. Note how in the test it now emits var memory = env.a; for the import. Fixes emscripten-core/emscripten#12123 This was not noticed earlier since that import is only used in memory growth. The tests that would catch it are wasm2js3.test*memory_growth* but we only run wasm2js1 on CI. I'll add testing after this lands.
Diffstat (limited to 'src')
-rw-r--r--src/wasm2js.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wasm2js.h b/src/wasm2js.h
index ab093dd03..ac0268e5b 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -382,7 +382,7 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) {
theVar,
"memory",
ValueBuilder::makeDot(ValueBuilder::makeName(ENV),
- ValueBuilder::makeName("memory")));
+ ValueBuilder::makeName(wasm->memory.base)));
}
// for emscripten, add a table import - otherwise we would have
// FUNCTION_TABLE be an upvar, and not as easy to be minified.