Skip to content

Commit 5fb5fe7

Browse files
authored
Move last remaining code in runtime.js into parseTools.js. NFC (#19338)
This file only had one remaining function and contained inaccurate information at the top.
1 parent a6087b3 commit 5fb5fe7

File tree

3 files changed

+24
-37
lines changed

3 files changed

+24
-37
lines changed

src/compiler.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ if (VERBOSE) {
9494
load('modules.js');
9595
load('parseTools.js');
9696
load('jsifier.js');
97-
load('runtime.js');
9897
if (!STRICT) {
9998
load('parseTools_legacy.js');
10099
}

src/parseTools.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ function needsQuoting(ident) {
170170
return true;
171171
}
172172

173-
const POINTER_SIZE = MEMORY64 ? 8 : 4;
173+
global.POINTER_SIZE = MEMORY64 ? 8 : 4;
174+
global.STACK_ALIGN = 16;
174175
const POINTER_BITS = POINTER_SIZE * 8;
175176
const POINTER_TYPE = 'u' + POINTER_BITS;
176177
const POINTER_JS_TYPE = MEMORY64 ? "'bigint'" : "'number'";
@@ -258,6 +259,28 @@ function indentify(text, indent) {
258259

259260
// Correction tools
260261

262+
function getNativeTypeSize(type) {
263+
switch (type) {
264+
case 'i1': case 'i8': case 'u8': return 1;
265+
case 'i16': case 'u16': return 2;
266+
case 'i32': case 'u32': return 4;
267+
case 'i64': case 'u64': return 8;
268+
case 'float': return 4;
269+
case 'double': return 8;
270+
default: {
271+
if (type[type.length - 1] === '*') {
272+
return POINTER_SIZE;
273+
}
274+
if (type[0] === 'i') {
275+
const bits = Number(type.substr(1));
276+
assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type);
277+
return bits / 8;
278+
}
279+
return 0;
280+
}
281+
}
282+
}
283+
261284
function getHeapOffset(offset, type) {
262285
if (type == 'i64' && !WASM_BIGINT) {
263286
// We are foreced to use the 32-bit heap for 64-bit values when we don't

src/runtime.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)