diff --git a/src/library.js b/src/library.js index 248fcb117f262..99c0b6a8446a0 100644 --- a/src/library.js +++ b/src/library.js @@ -1903,10 +1903,12 @@ addToLibrary({ $setWasmTableEntry__internal: true, $setWasmTableEntry__deps: ['$wasmTableMirror', '$wasmTable'], $setWasmTableEntry: (idx, func) => { + /** @suppress {checkTypes} */ wasmTable.set({{{ toIndexType('idx') }}}, func); // With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overridden to return wrapped // functions so we need to call it here to retrieve the potential wrapper correctly // instead of just storing 'func' directly into wasmTableMirror + /** @suppress {checkTypes} */ wasmTableMirror[idx] = wasmTable.get({{{ toIndexType('idx') }}}); }, @@ -1922,6 +1924,7 @@ addToLibrary({ var func = wasmTableMirror[funcPtr]; if (!func) { if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1; + /** @suppress {checkTypes} */ wasmTableMirror[funcPtr] = func = wasmTable.get({{{ toIndexType('funcPtr') }}}); #if ASYNCIFY == 2 if (Asyncify.isAsyncExport(func)) { @@ -1930,6 +1933,7 @@ addToLibrary({ #endif } #if ASSERTIONS && ASYNCIFY != 2 // With JSPI the function stored in the table will be a wrapper. + /** @suppress {checkTypes} */ assert(wasmTable.get({{{ toIndexType('funcPtr') }}}) == func, 'JavaScript-side Wasm function table mirror is out of date!'); #endif return func; @@ -1937,16 +1941,13 @@ addToLibrary({ #else + $setWasmTableEntry__docs: '/** @suppress{checkTypes} */', $setWasmTableEntry__deps: ['$wasmTable'], $setWasmTableEntry: (idx, func) => wasmTable.set({{{ toIndexType('idx') }}}, func), + $getWasmTableEntry__docs: '/** @suppress{checkTypes} */', $getWasmTableEntry__deps: ['$wasmTable'], $getWasmTableEntry: (funcPtr) => { -#if MEMORY64 - // Function pointers are 64-bit, but wasmTable.get() requires a Number. - // https://github.com/emscripten-core/emscripten/issues/18200 - funcPtr = Number(funcPtr); -#endif // In -Os and -Oz builds, do not implement a JS side wasm table mirror for small // code size, but directly access wasmTable, which is a bit slower as uncached. return wasmTable.get({{{ toIndexType('funcPtr') }}}); diff --git a/src/library_addfunction.js b/src/library_addfunction.js index fc9f91f11d00c..373b8cfab3f3b 100644 --- a/src/library_addfunction.js +++ b/src/library_addfunction.js @@ -151,6 +151,7 @@ addToLibrary({ } // Grow the table try { + /** @suppress {checkTypes} */ wasmTable.grow({{{ toIndexType('1') }}}); } catch (err) { if (!(err instanceof RangeError)) { diff --git a/src/parseTools.mjs b/src/parseTools.mjs index 0a9fb43b14b2e..01dfafceb5711 100644 --- a/src/parseTools.mjs +++ b/src/parseTools.mjs @@ -964,8 +964,7 @@ function from64Expr(x, assign = true) { } function toIndexType(x) { - if (MEMORY64 != 1) return x; - return `toIndexType(${x})`; + return to64(x); } function to64(x) { diff --git a/src/runtime_init_memory.js b/src/runtime_init_memory.js index b3e71ac2154fe..8a5d93398163f 100644 --- a/src/runtime_init_memory.js +++ b/src/runtime_init_memory.js @@ -26,6 +26,7 @@ if (!ENVIRONMENT_IS_PTHREAD) { #if ASSERTIONS assert(INITIAL_MEMORY >= {{{STACK_SIZE}}}, 'INITIAL_MEMORY should be larger than STACK_SIZE, was ' + INITIAL_MEMORY + '! (STACK_SIZE=' + {{{STACK_SIZE}}} + ')'); #endif + /** @suppress {checkTypes} */ #if MINIMAL_RUNTIME && WASM_WORKERS wasmMemory = Module['mem'] || new WebAssembly.Memory({ #else diff --git a/src/runtime_shared.js b/src/runtime_shared.js index ea63e247a6a5d..9a9943c3ad13e 100644 --- a/src/runtime_shared.js +++ b/src/runtime_shared.js @@ -47,22 +47,6 @@ function updateMemoryViews() { #endif } -#if MEMORY64 == 1 -var toIndexType = (function() { - // Probe for support of bigint bounds with memory64. - // TODO(sbc): Remove this once all browsers start requiring bigint here. - // See https://github.com/WebAssembly/memory64/issues/68 - var bigintMemoryBounds = 1; - try { - /** @suppress {checkTypes} */ - new WebAssembly.Memory({'initial': 1n, 'index': 'i64', 'address': 'i64'}); - } catch (e) { - bigintMemoryBounds = 0; - } - return (i) => bigintMemoryBounds ? BigInt(i) : i; -})(); -#endif - #if ENVIRONMENT_MAY_BE_NODE && MIN_NODE_VERSION < 160000 // The performance global was added to node in v16.0.0: // https://nodejs.org/api/globals.html#performance diff --git a/test/other/codesize/test_codesize_minimal_64.gzsize b/test/other/codesize/test_codesize_minimal_64.gzsize index 8ba317efe6514..64a05134ac7e8 100644 --- a/test/other/codesize/test_codesize_minimal_64.gzsize +++ b/test/other/codesize/test_codesize_minimal_64.gzsize @@ -1 +1 @@ -1589 +1522 diff --git a/test/other/codesize/test_codesize_minimal_64.jssize b/test/other/codesize/test_codesize_minimal_64.jssize index 37023f76951aa..9af21432425ab 100644 --- a/test/other/codesize/test_codesize_minimal_64.jssize +++ b/test/other/codesize/test_codesize_minimal_64.jssize @@ -1 +1 @@ -3311 +3179