Skip to content

Commit 6791b1c

Browse files
authored
Remove getNativeFieldSize build-time helper. NFC (#19258)
This function had exactly one callsite, where its wasn't serving any useful purpose: ``` if (!WASM_BIGINT && getNativeFieldSize(type) > 4 && type == 'i64') { ``` Here the second clause in the condition would always return true when `type` in `i64` making the redundant in the face the third clause. This is because `getNativeFieldSize('i64')` always returns 8.
1 parent 6f02383 commit 6791b1c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/parseTools.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ function indentify(text, indent) {
258258
// Correction tools
259259

260260
function getHeapOffset(offset, type) {
261-
if (!WASM_BIGINT && getNativeFieldSize(type) > 4 && type == 'i64') {
262-
// we emulate 64-bit integer values as 32 in asmjs-unknown-emscripten, but not double
261+
if (type == 'i64' && !WASM_BIGINT) {
262+
// We are foreced to use the 32-bit heap for 64-bit values when we don't
263+
// have WASM_BIGINT.
263264
type = 'i32';
264265
}
265266

src/parseTools_legacy.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ function makeMalloc(source, param) {
8989
return `_malloc(${param})`;
9090
}
9191

92+
function getNativeFieldSize(type) {
93+
return Math.max(getNativeTypeSize(type), POINTER_SIZE);
94+
}
95+
9296
global.Runtime = {
9397
getNativeTypeSize: getNativeTypeSize,
9498
getNativeFieldSize: getNativeFieldSize,

src/runtime.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,3 @@ function getNativeTypeSize(type) {
3333
}
3434
}
3535
}
36-
37-
function getNativeFieldSize(type) {
38-
return Math.max(getNativeTypeSize(type), POINTER_SIZE);
39-
}

0 commit comments

Comments
 (0)