Skip to content

Commit a3dc8bf

Browse files
committed
refactor memoryBase and tableBase init to a shared location, so it affects native builds too
1 parent 5e3f262 commit a3dc8bf

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/js/wasm.js-post.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,6 @@ function integrateWasmJS(Module) {
223223
env['memory'] = providedBuffer;
224224
assert(env['memory'] instanceof ArrayBuffer);
225225

226-
if (!('memoryBase' in env)) {
227-
env['memoryBase'] = STATIC_BASE; // tell the memory segments where to place themselves
228-
}
229-
if (!('tableBase' in env)) {
230-
env['tableBase'] = 0; // tell the memory segments where to place themselves
231-
}
232-
233226
wasmJS['providedTotalMemory'] = Module['buffer'].byteLength;
234227

235228
// Prepare to generate wasm, using either asm2wasm or s-exprs
@@ -297,6 +290,13 @@ function integrateWasmJS(Module) {
297290
env['table'] = new Array(TABLE_SIZE); // works in binaryen interpreter at least
298291
}
299292
}
293+
294+
if (!env['memoryBase']) {
295+
env['memoryBase'] = STATIC_BASE; // tell the memory segments where to place themselves
296+
}
297+
if (!env['tableBase']) {
298+
env['tableBase'] = 0; // table starts at 0 by default, in dynamic linking this will change
299+
}
300300

301301
// try the methods. each should return the exports if it succeeded
302302

0 commit comments

Comments
 (0)