summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-10-11 16:15:15 -0700
committerGitHub <noreply@github.com>2016-10-11 16:15:15 -0700
commit85900965a12a3f07c9cca8ef620d4bee039f16fc (patch)
tree184203f372600d547705ce3d11b616d52ad522aa /src/js
parent1dbdfff8e997f74154dfebce124756e415aa431a (diff)
parent943fd287247f9d23d463a24e8eb4b0f666900c43 (diff)
downloadbinaryen-85900965a12a3f07c9cca8ef620d4bee039f16fc.tar.gz
binaryen-85900965a12a3f07c9cca8ef620d4bee039f16fc.tar.bz2
binaryen-85900965a12a3f07c9cca8ef620d4bee039f16fc.zip
Merge pull request #757 from WebAssembly/js-api
Tiny fixes for native wasm support
Diffstat (limited to 'src/js')
-rw-r--r--src/js/wasm.js-post.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js
index e7d461642..f093ff64d 100644
--- a/src/js/wasm.js-post.js
+++ b/src/js/wasm.js-post.js
@@ -223,13 +223,6 @@ function integrateWasmJS(Module) {
env['memory'] = providedBuffer;
assert(env['memory'] instanceof ArrayBuffer);
- if (!('memoryBase' in env)) {
- env['memoryBase'] = STATIC_BASE; // tell the memory segments where to place themselves
- }
- if (!('tableBase' in env)) {
- env['tableBase'] = 0; // tell the memory segments where to place themselves
- }
-
wasmJS['providedTotalMemory'] = Module['buffer'].byteLength;
// Prepare to generate wasm, using either asm2wasm or s-exprs
@@ -290,13 +283,21 @@ function integrateWasmJS(Module) {
// import table
if (!env['table']) {
- var TABLE_SIZE = 1024; // TODO
+ var TABLE_SIZE = Module['wasmTableSize'];
+ if (TABLE_SIZE === undefined) TABLE_SIZE = 1024; // works in binaryen interpreter at least
if (typeof WebAssembly === 'object' && typeof WebAssembly.Table === 'function') {
env['table'] = new WebAssembly.Table({ initial: TABLE_SIZE, maximum: TABLE_SIZE, element: 'anyfunc' });
} else {
env['table'] = new Array(TABLE_SIZE); // works in binaryen interpreter at least
}
}
+
+ if (!env['memoryBase']) {
+ env['memoryBase'] = STATIC_BASE; // tell the memory segments where to place themselves
+ }
+ if (!env['tableBase']) {
+ env['tableBase'] = 0; // table starts at 0 by default, in dynamic linking this will change
+ }
// try the methods. each should return the exports if it succeeded