Skip to content

Commit 13bcbe9

Browse files
committed
[wasm64] Remove temporary toIndexType workaround
Now the firefox and chrome both use BigInt for indexing 64-bit memories and tables this workaround is no longer needed.
1 parent 4af8790 commit 13bcbe9

File tree

6 files changed

+9
-20
lines changed

6 files changed

+9
-20
lines changed

src/library.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,10 +1903,12 @@ addToLibrary({
19031903
$setWasmTableEntry__internal: true,
19041904
$setWasmTableEntry__deps: ['$wasmTableMirror', '$wasmTable'],
19051905
$setWasmTableEntry: (idx, func) => {
1906+
/** @suppress {checkTypes} */
19061907
wasmTable.set({{{ toIndexType('idx') }}}, func);
19071908
// With ABORT_ON_WASM_EXCEPTIONS wasmTable.get is overridden to return wrapped
19081909
// functions so we need to call it here to retrieve the potential wrapper correctly
19091910
// instead of just storing 'func' directly into wasmTableMirror
1911+
/** @suppress {checkTypes} */
19101912
wasmTableMirror[idx] = wasmTable.get({{{ toIndexType('idx') }}});
19111913
},
19121914

@@ -1922,6 +1924,7 @@ addToLibrary({
19221924
var func = wasmTableMirror[funcPtr];
19231925
if (!func) {
19241926
if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
1927+
/** @suppress {checkTypes} */
19251928
wasmTableMirror[funcPtr] = func = wasmTable.get({{{ toIndexType('funcPtr') }}});
19261929
#if ASYNCIFY == 2
19271930
if (Asyncify.isAsyncExport(func)) {
@@ -1930,13 +1933,15 @@ addToLibrary({
19301933
#endif
19311934
}
19321935
#if ASSERTIONS && ASYNCIFY != 2 // With JSPI the function stored in the table will be a wrapper.
1936+
/** @suppress {checkTypes} */
19331937
assert(wasmTable.get({{{ toIndexType('funcPtr') }}}) == func, 'JavaScript-side Wasm function table mirror is out of date!');
19341938
#endif
19351939
return func;
19361940
},
19371941

19381942
#else
19391943

1944+
$setWasmTableEntry__docs: '/** @suppress{checkTypes} */',
19401945
$setWasmTableEntry__deps: ['$wasmTable'],
19411946
$setWasmTableEntry: (idx, func) => wasmTable.set({{{ toIndexType('idx') }}}, func),
19421947

src/library_addfunction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ addToLibrary({
151151
}
152152
// Grow the table
153153
try {
154+
/** @suppress {checkTypes} */
154155
wasmTable.grow({{{ toIndexType('1') }}});
155156
} catch (err) {
156157
if (!(err instanceof RangeError)) {

src/parseTools.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,7 @@ function from64Expr(x, assign = true) {
964964
}
965965

966966
function toIndexType(x) {
967-
if (MEMORY64 != 1) return x;
968-
return `toIndexType(${x})`;
967+
return to64(x);
969968
}
970969

971970
function to64(x) {

src/runtime_shared.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,6 @@ function updateMemoryViews() {
4747
#endif
4848
}
4949

50-
#if MEMORY64 == 1
51-
var toIndexType = (function() {
52-
// Probe for support of bigint bounds with memory64.
53-
// TODO(sbc): Remove this once all browsers start requiring bigint here.
54-
// See https://github.com/WebAssembly/memory64/issues/68
55-
var bigintMemoryBounds = 1;
56-
try {
57-
/** @suppress {checkTypes} */
58-
new WebAssembly.Memory({'initial': 1n, 'index': 'i64', 'address': 'i64'});
59-
} catch (e) {
60-
bigintMemoryBounds = 0;
61-
}
62-
return (i) => bigintMemoryBounds ? BigInt(i) : i;
63-
})();
64-
#endif
65-
6650
#if ENVIRONMENT_MAY_BE_NODE && MIN_NODE_VERSION < 160000
6751
// The performance global was added to node in v16.0.0:
6852
// https://nodejs.org/api/globals.html#performance
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1589
1+
1522
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3311
1+
3179

0 commit comments

Comments
 (0)