Skip to content

Commit 32ca8dc

Browse files
committed
[wasm64] making JS bindings wasm64 aware
1 parent ea4c450 commit 32ca8dc

File tree

7 files changed

+106
-28
lines changed

7 files changed

+106
-28
lines changed

src/runtime.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ var Compiletime = {
2121
// code used both at compile time and runtime is defined here, then put on
2222
// the Runtime object for compile time and support.js for the generated code
2323

24+
function getPointerSize() {
25+
return MEMORY64 ? 8 : 4;
26+
}
27+
2428
function getNativeTypeSize(type) {
2529
switch (type) {
2630
case 'i1': case 'i8': return 1;
@@ -31,7 +35,7 @@ function getNativeTypeSize(type) {
3135
case 'double': return 8;
3236
default: {
3337
if (type[type.length-1] === '*') {
34-
return 4; // A pointer
38+
return getPointerSize();
3539
} else if (type[0] === 'i') {
3640
var bits = Number(type.substr(1));
3741
assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type);
@@ -53,6 +57,6 @@ var Runtime = {
5357
return Math.max(getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
5458
},
5559

56-
POINTER_SIZE: 4,
57-
QUANTUM_SIZE: 4,
60+
POINTER_SIZE: getPointerSize(),
61+
QUANTUM_SIZE: getPointerSize(),
5862
};

src/support.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
var STACK_ALIGN = {{{ STACK_ALIGN }}};
88

9+
function getPointerSize() {
10+
return {{{ MEMORY64 ? 8 : 4 }}};
11+
}
12+
913
{{{ getNativeTypeSize }}}
1014

1115
function warnOnce(text) {

tests/core/test_typeid.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
#include <stdio.h>
99
#include <string.h>
1010
#include <typeinfo>
11+
#include <stdint.h>
1112
int main() {
1213
printf("*\n");
1314
#define MAX 100
14-
int ptrs[MAX];
15+
long ptrs[MAX];
1516
int groups[MAX];
16-
memset(ptrs, 0, MAX * sizeof(int));
17+
memset(ptrs, 0, MAX * sizeof(long));
1718
memset(groups, 0, MAX * sizeof(int));
1819
int next_group = 1;
1920
#define TEST(X) \
2021
{ \
21-
int ptr = (int)&typeid(X); \
22+
intptr_t ptr = (intptr_t)&typeid(X); \
2223
int group = 0; \
2324
int i; \
2425
for (i = 0; i < MAX; i++) { \

tests/runner.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
'wasm2js3',
6161
'wasm2jss',
6262
'wasm2jsz',
63+
'wasm64'
6364
]
6465

6566
# The default core test mode, used when none is specified
@@ -312,6 +313,8 @@ def parse_args(args):
312313
parser.add_argument('tests', nargs='*')
313314
parser.add_argument('--failfast', dest='failfast', action='store_const',
314315
const=True, default=False)
316+
parser.add_argument('--force64', dest='force64', action='store_const',
317+
const=True, default=False)
315318
return parser.parse_args()
316319

317320

@@ -324,6 +327,8 @@ def configure():
324327
common.EMTEST_LACKS_NATIVE_CLANG = int(os.getenv('EMTEST_LACKS_NATIVE_CLANG', '0'))
325328
common.EMTEST_REBASELINE = int(os.getenv('EMTEST_REBASELINE', '0'))
326329
common.EMTEST_VERBOSE = int(os.getenv('EMTEST_VERBOSE', '0')) or shared.DEBUG
330+
global FORCE64
331+
FORCE64 = int(os.getenv('EMTEST_FORCE64', '0'))
327332
if common.EMTEST_VERBOSE:
328333
logging.root.setLevel(logging.DEBUG)
329334

@@ -361,6 +366,7 @@ def set_env(name, option_value):
361366
set_env('EMTEST_REBASELINE', options.rebaseline)
362367
set_env('EMTEST_VERBOSE', options.verbose)
363368
set_env('EMTEST_CORES', options.cores)
369+
set_env('EMTEST_FORCE64', options.force64)
364370

365371
configure()
366372

tests/test_benchmark.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151

5252
LLVM_FEATURE_FLAGS = ['-mnontrapping-fptoint']
5353

54+
FORCE64 = 0
55+
5456

5557
class Benchmarker():
5658
# called when we init the object, which is during startup, even if we are
@@ -205,12 +207,14 @@ def build(self, parent, filename, args, shared_args, emcc_args, native_args, nat
205207
OPTIMIZATIONS,
206208
'-s', 'INITIAL_MEMORY=256MB',
207209
'-s', 'FILESYSTEM=0',
208-
'--closure=1',
209-
'-s', 'MINIMAL_RUNTIME',
210210
'-s', 'ENVIRONMENT=node,shell',
211211
'-s', 'BENCHMARK=%d' % (1 if IGNORE_COMPILATION and not has_output_parser else 0),
212212
'-o', final
213213
] + shared_args + emcc_args + LLVM_FEATURE_FLAGS + self.extra_args
214+
if FORCE64:
215+
cmd += ['--profiling']
216+
else:
217+
cmd += ['--closure=1', '-sMINIMAL_RUNTIME']
214218
if 'FORCE_FILESYSTEM' in cmd:
215219
cmd = [arg if arg != 'FILESYSTEM=0' else 'FILESYSTEM=1' for arg in cmd]
216220
if PROFILING:
@@ -353,22 +357,30 @@ def cleanup(self):
353357

354358
# Benchmarkers
355359

356-
benchmarkers = [
357-
NativeBenchmarker('clang', [CLANG_CC], [CLANG_CXX]),
358-
# NativeBenchmarker('gcc', ['gcc', '-no-pie'], ['g++', '-no-pie'])
359-
]
360+
benchmarkers = []
361+
362+
if not FORCE64:
363+
benchmarkers += [
364+
NativeBenchmarker('clang', [CLANG_CC], [CLANG_CXX]),
365+
# NativeBenchmarker('gcc', ['gcc', '-no-pie'], ['g++', '-no-pie'])
366+
]
360367

361368
if config.V8_ENGINE and config.V8_ENGINE in config.JS_ENGINES:
362369
# avoid the baseline compiler running, because it adds a lot of noise
363370
# (the nondeterministic time it takes to get to the full compiler ends up
364371
# mattering as much as the actual benchmark)
365372
aot_v8 = config.V8_ENGINE + ['--no-liftoff']
366373
default_v8_name = os.environ.get('EMBENCH_NAME') or 'v8'
367-
benchmarkers += [
368-
EmscriptenBenchmarker(default_v8_name, aot_v8),
369-
EmscriptenBenchmarker(default_v8_name + '-lto', aot_v8, ['-flto']),
370-
# EmscriptenWasm2CBenchmarker('wasm2c')
371-
]
374+
if FORCE64:
375+
benchmarkers += [
376+
EmscriptenBenchmarker(default_v8_name, aot_v8, ['-sMEMORY64=2']),
377+
]
378+
else:
379+
benchmarkers += [
380+
EmscriptenBenchmarker(default_v8_name, aot_v8),
381+
EmscriptenBenchmarker(default_v8_name + '-lto', aot_v8, ['-flto']),
382+
# EmscriptenWasm2CBenchmarker('wasm2c')
383+
]
372384
if os.path.exists(CHEERP_BIN):
373385
benchmarkers += [
374386
# CheerpBenchmarker('cheerp-v8-wasm', aot_v8),
@@ -385,9 +397,14 @@ def cleanup(self):
385397
]
386398

387399
if config.NODE_JS and config.NODE_JS in config.JS_ENGINES:
388-
benchmarkers += [
389-
# EmscriptenBenchmarker('Node.js', config.NODE_JS),
390-
]
400+
if FORCE64:
401+
benchmarkers += [
402+
EmscriptenBenchmarker('Node.js', config.NODE_JS, ['-sMEMORY64=2']),
403+
]
404+
else:
405+
benchmarkers += [
406+
# EmscriptenBenchmarker('Node.js', config.NODE_JS),
407+
]
391408

392409

393410
class benchmark(common.RunnerCore):

0 commit comments

Comments
 (0)