Skip to content

Commit 3e8ab8c

Browse files
authored
Added minor docs for 64-bit conversions NFC (#25067)
Minor clarification of the difference between `toIndexType()` and `to64()`.
1 parent c70edc6 commit 3e8ab8c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/parseTools.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,11 +997,17 @@ function from64Expr(x) {
997997
return `Number(${x})`;
998998
}
999999

1000+
// Converts a value to BigInt if building for wasm64, with both 64-bit pointers
1001+
// and 64-bit memory. Used for indices into the memory tables, for example.
10001002
function toIndexType(x) {
10011003
if (MEMORY64 == 1) return `BigInt(${x})`;
10021004
return x;
10031005
}
10041006

1007+
// Converts a value to BigInt if building for wasm64, regardless of whether the
1008+
// memory is 32- or 64-bit. Used for passing pointer-width values to native
1009+
// code (since pointers are presented as Number in JS and BigInt in wasm we need
1010+
// this conversion before passing them).
10051011
function to64(x) {
10061012
if (!MEMORY64) return x;
10071013
return `BigInt(${x})`;

0 commit comments

Comments
 (0)