summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-04 10:40:10 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-03-04 10:40:10 -0800
commit5d54bd1c2713ac802d919351f668e2316ab27d70 (patch)
tree14a61fb5a205fb2bd1a67f86040876890c8a6e93
parent23d0b0a717cd139c27e9127b2a0bdcaf19abf6ec (diff)
downloadbinaryen-5d54bd1c2713ac802d919351f668e2316ab27d70.tar.gz
binaryen-5d54bd1c2713ac802d919351f668e2316ab27d70.tar.bz2
binaryen-5d54bd1c2713ac802d919351f668e2316ab27d70.zip
remove optimization for interpreter memory generation, make it always return a memory like in the native code path
-rw-r--r--src/wasm-js.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index 9c9096ad8..7b9afab30 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -148,19 +148,16 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() {
struct JSExternalInterface : ModuleInstance::ExternalInterface {
void init(Module& wasm) override {
- // if we have memory segments, create a new buffer here, just like native wasm support would.
- // otherwise, no need to.
- if (wasm.memory.segments.size() > 0) {
+ // create a new buffer here, just like native wasm support would.
+ EM_ASM_({
+ Module['outside']['newBuffer'] = new ArrayBuffer($0);
+ }, wasm.memory.initial);
+ for (auto segment : wasm.memory.segments) {
EM_ASM_({
- Module['outside']['newBuffer'] = new ArrayBuffer($0);
- }, wasm.memory.initial);
- for (auto segment : wasm.memory.segments) {
- EM_ASM_({
- var source = Module['HEAP8'].subarray($1, $1 + $2);
- var target = new Int8Array(Module['outside']['newBuffer']);
- target.set(source, $0);
- }, segment.offset, segment.data, segment.size);
- }
+ var source = Module['HEAP8'].subarray($1, $1 + $2);
+ var target = new Int8Array(Module['outside']['newBuffer']);
+ target.set(source, $0);
+ }, segment.offset, segment.data, segment.size);
}
}