diff options
author | jgravelle-google <jgravelle@google.com> | 2016-09-09 10:41:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-09 10:41:00 -0700 |
commit | ac078dcb1c677f83527693536cb1c06157095447 (patch) | |
tree | 0e007d41a98322bbbf28b3a270558d98692a7e1a /src/asm2wasm.h | |
parent | 87f65f1623983bfc516ff4b222a3bb2537971837 (diff) | |
download | binaryen-ac078dcb1c677f83527693536cb1c06157095447.tar.gz binaryen-ac078dcb1c677f83527693536cb1c06157095447.tar.bz2 binaryen-ac078dcb1c677f83527693536cb1c06157095447.zip |
Add flag to s2wasm to export __growWasmMemory function (#696)
* Add a flag to s2wasm to export grow_memory
Binaryen's wasm.js-post.js calls back in to wasm in order to grow the
linear memory, via a function that asm2wasm exports called
__growWasmMemory.
This changes exposes that method through s2wasm when invoked with a
flag.
* Move AsmConstWalker from wasm-linker to wasm-emscripten
* Add test for memory growth in s2wasm
* Move makeDynCallThunks into wasm-emscripten module
* Move mutation in getTableSegment into a separate method
* Move emscripten metadata generation into wasm-emscripten
Also make AsmConstWalker internal to the wasm-emscripten module, as it's only used for the metadata pass.
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 53fa78db4..b19451a7b 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -32,6 +32,7 @@ #include "pass.h" #include "ast_utils.h" #include "wasm-builder.h" +#include "wasm-emscripten.h" #include "wasm-validator.h" #include "wasm-module-building.h" @@ -814,23 +815,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // apply memory growth, if relevant if (memoryGrowth) { - // create and export a function that just calls memory growth - Builder builder(wasm); - wasm.addFunction(builder.makeFunction( - GROW_WASM_MEMORY, - { { NEW_SIZE, i32 } }, - i32, - {}, - builder.makeHost( - GrowMemory, - Name(), - { builder.makeGetLocal(0, i32) } - ) - )); - auto export_ = new Export; - export_->name = export_->value = GROW_WASM_MEMORY; - export_->kind = Export::Function; - wasm.addExport(export_); + emscripten::generateMemoryGrowthFunction(wasm); } #if 0 |