summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@users.noreply.github.com>2016-08-26 11:29:18 -0700
committerGitHub <noreply@github.com>2016-08-26 11:29:18 -0700
commit4a04fc609133313ab18ef49599f365d3587af55b (patch)
treeca259b046d5a6ec39c3c78370aad784024a87066 /src
parent801baed1ca81d87380d56298289fe8cc0b4f1e1a (diff)
downloadbinaryen-4a04fc609133313ab18ef49599f365d3587af55b.tar.gz
binaryen-4a04fc609133313ab18ef49599f365d3587af55b.tar.bz2
binaryen-4a04fc609133313ab18ef49599f365d3587af55b.zip
Asm.js-style setjmp/longjmp support for wasm (#681)
This needs to export realloc as well, in addition to malloc and free handled in #4469. To support asm.js style setjmp/longjmp, wasm needs to export realloc as well, in addition to malloc and free handled in #4469. saveSetjmp() uses realloc within it, and realloc is not implemented in JS glue code.
Diffstat (limited to 'src')
-rw-r--r--src/wasm-linker.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp
index 2c9a4cd4d..b1160e94a 100644
--- a/src/wasm-linker.cpp
+++ b/src/wasm-linker.cpp
@@ -213,18 +213,21 @@ void Linker::layout() {
}
}
- // Export malloc and free whenever availble. JavsScript version of malloc has
- // some issues and it cannot be called once _sbrk() is called.
- // TODO This should get the list of exported functions from emcc.py - it has
- // EXPORTED_FUNCTION metadata to keep track of this. Get the list of exported
- // functions using a command-line argument from emcc.py and export all of
- // them.
+ // Export malloc, realloc, and free whenever availble. JavsScript version of
+ // malloc has some issues and it cannot be called once _sbrk() is called, and
+ // JS glue code does not have realloc(). TODO This should get the list of
+ // exported functions from emcc.py - it has EXPORTED_FUNCTION metadata to keep
+ // track of this. Get the list of exported functions using a command-line
+ // argument from emcc.py and export all of them.
if (out.symbolInfo.implementedFunctions.count("malloc")) {
exportFunction("malloc", true);
}
if (out.symbolInfo.implementedFunctions.count("free")) {
exportFunction("free", true);
}
+ if (out.symbolInfo.implementedFunctions.count("realloc")) {
+ exportFunction("realloc", true);
+ }
// finalize function table
if (out.wasm.table.segments.size() > 0) {