From f0d6b089960e089bcc5c1794003585ebbd91d33a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 11 Nov 2020 15:50:33 -0800 Subject: wasm2js: Declare data segments before calling asmFunc (#3337) This is because we maybe need to reference the segments during the start function. For example in the case of pthreads we conditionally load passive segments during start. Tested in emscripten with: tests/runner.py wasm2js1 --- test/wasm2js/unaligned.2asm.js.opt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/wasm2js/unaligned.2asm.js.opt') diff --git a/test/wasm2js/unaligned.2asm.js.opt b/test/wasm2js/unaligned.2asm.js.opt index 0eb08a4c7..e5005fef5 100644 --- a/test/wasm2js/unaligned.2asm.js.opt +++ b/test/wasm2js/unaligned.2asm.js.opt @@ -1,5 +1,6 @@ import { setTempRet0 } from 'env'; + var bufferView; var scratchBuffer = new ArrayBuffer(16); var i32ScratchView = new Int32Array(scratchBuffer); @@ -36,7 +37,6 @@ function asmFunc(env) { var HEAPU32 = new Uint32Array(buffer); var HEAPF32 = new Float32Array(buffer); var HEAPF64 = new Float64Array(buffer); - bufferView = HEAPU8; var Math_imul = Math.imul; var Math_fround = Math.fround; var Math_abs = Math.abs; @@ -113,6 +113,7 @@ function asmFunc(env) { return $0_1; } + bufferView = HEAPU8; function __wasm_memory_size() { return buffer.byteLength / 65536 | 0; } @@ -129,7 +130,6 @@ function asmFunc(env) { }; } -var bufferView; var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }, setTempRet0 }); -- cgit v1.2.3