From 717bbe620aa36bc7b85040eade18b1a0300bcec4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 11:51:05 -0700 Subject: use wasmTableSize when provided --- src/js/wasm.js-post.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/js') diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index e7d461642..cc1f29c10 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -290,7 +290,7 @@ function integrateWasmJS(Module) { // import table if (!env['table']) { - var TABLE_SIZE = 1024; // TODO + var TABLE_SIZE = Module['wasmTableSize'] || 1024; if (typeof WebAssembly === 'object' && typeof WebAssembly.Table === 'function') { env['table'] = new WebAssembly.Table({ initial: TABLE_SIZE, maximum: TABLE_SIZE, element: 'anyfunc' }); } else { -- cgit v1.2.3 From a3dc8bf8cba7cd1b5ece8abf0489a9dcacfa3f2e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 13:51:34 -0700 Subject: refactor memoryBase and tableBase init to a shared location, so it affects native builds too --- src/js/wasm.js-post.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/js') diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index cc1f29c10..58e4c75cd 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 @@ -297,6 +290,13 @@ function integrateWasmJS(Module) { 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 -- cgit v1.2.3 From 943fd287247f9d23d463a24e8eb4b0f666900c43 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 14:50:34 -0700 Subject: wasmTableSize of 0 is allowed --- src/js/wasm.js-post.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/js') diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index 58e4c75cd..f093ff64d 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -283,7 +283,8 @@ function integrateWasmJS(Module) { // import table if (!env['table']) { - var TABLE_SIZE = Module['wasmTableSize'] || 1024; + 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 { -- cgit v1.2.3