Skip to content

Commit a58191f

Browse files
committed
Code review changes
1 parent 69b1495 commit a58191f

19 files changed

+41
-48
lines changed

src/library.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,16 +3772,13 @@ LibraryManager.library = {
37723772
// mode are created here and imported by the module.
37733773
// Mark with `__import` so these are usable from native code. This is needed
37743774
// because, by default, only functions can be be imported.
3775-
__stack_pointer:
3776-
"new WebAssembly.Global({'value': '{{{ SIZE_TYPE }}}', 'mutable': true}, {{{ to64(STACK_BASE) }}})",
3775+
__stack_pointer: "new WebAssembly.Global({'value': '{{{ SIZE_TYPE }}}', 'mutable': true}, {{{ to64(STACK_BASE) }}})",
37773776
__stack_pointer__import: true,
37783777
// tell the memory segments where to place themselves
3779-
__memory_base:
3780-
"new WebAssembly.Global({'value': '{{{ SIZE_TYPE}}}', 'mutable': false}, {{{ to64(GLOBAL_BASE) }}})",
3778+
__memory_base: "new WebAssembly.Global({'value': '{{{ SIZE_TYPE}}}', 'mutable': false}, {{{ to64(GLOBAL_BASE) }}})",
37813779
__memory_base__import: true,
37823780
// the wasm backend reserves slot 0 for the NULL function pointer
3783-
__table_base:
3784-
"new WebAssembly.Global({'value': '{{{ SIZE_TYPE }}}', 'mutable': false}, {{{ to64(1) }}})",
3781+
__table_base: "new WebAssembly.Global({'value': '{{{ SIZE_TYPE }}}', 'mutable': false}, {{{ to64(1) }}})",
37853782
__table_base__import: true,
37863783
#if MEMORY64
37873784
__table_base32: 1,

src/library_dylink.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ var LibraryDylink = {
4343
$GOTHandler: {
4444
'get': function(obj, symName) {
4545
if (!GOT[symName]) {
46-
GOT[symName] = new WebAssembly.Global({'value':
47-
#if MEMORY64
48-
'i64',
49-
#else
50-
'i32',
51-
#endif
52-
'mutable': true});
46+
GOT[symName] = new WebAssembly.Global({'value': '{{{ SIZE_TYPE }}}', 'mutable': true});
5347
#if DYLINK_DEBUG
5448
err("new GOT entry: " + symName);
5549
#endif

src/library_exceptions.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,15 @@ var LibraryExceptions = {
120120
};
121121

122122
this.set_adjusted_ptr = function(adjustedPtr) {
123-
var ptrSize = {{{ `${Runtime.POINTER_SIZE}` }}};
124-
{{{ makeSetValue('this.ptr', 'ptrSize', 'adjustedPtr', '*') }}};
123+
{{{ makeSetValue('this.ptr', Runtime.POINTER_SIZE, 'adjustedPtr', '*') }}};
125124
};
126125

127126
this.get_adjusted_ptr_addr = function() {
128127
return this.ptr + {{{ Runtime.POINTER_SIZE }}};
129128
}
130129

131130
this.get_adjusted_ptr = function() {
132-
var ptrSize = {{{ `${Runtime.POINTER_SIZE}` }}};
133-
return {{{ makeGetValue('this.ptr', 'ptrSize', '*') }}};
131+
return {{{ makeGetValue('this.ptr', Runtime.POINTER_SIZE, '*') }}};
134132
};
135133

136134
// Get pointer which is expected to be received by catch clause in C++ code. It may be adjusted
@@ -155,7 +153,7 @@ var LibraryExceptions = {
155153
};
156154

157155
if (ptr === undefined) {
158-
this.ptr = _malloc({{{ `${Runtime.POINTER_SIZE}` * 2 }}});
156+
this.ptr = _malloc({{{ Runtime.POINTER_SIZE * 2 }}});
159157
this.set_adjusted_ptr(0);
160158
} else {
161159
this.ptr = ptr;

src/library_pthread.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,7 @@ var LibraryPThread = {
667667
// Deduce which WebGL canvases (HTMLCanvasElements or OffscreenCanvases) should be passed over to the
668668
// Worker that hosts the spawned pthread.
669669
// Comma-delimited list of CSS selectors that must identify canvases by IDs: "#canvas1, #canvas2, ..."
670-
#if MEMORY64
671-
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', 40, 'i64') }}} : 0;
672-
#else
673-
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', 40, 'i32') }}} : 0;
674-
#endif
670+
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', 40, `${SIZE_TYPE}`) }}} : 0;
675671
#if OFFSCREENCANVASES_TO_PTHREAD
676672
// Proxied canvases string pointer -1 is used as a special token to fetch
677673
// whatever canvases were passed to build in -s

src/runtime_safe_heap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@param {number|boolean=} noSafe */
1515
function setValue(ptr, value, type, noSafe) {
1616
type = type || 'i8';
17-
if (type.charAt(type.length-1) === '*') type = {{{ `'${POINTER_TYPE}'` }}};
17+
if (type.charAt(type.length-1) === '*') type = '{{{ POINTER_TYPE }}}';
1818
#if SAFE_HEAP
1919
if (noSafe) {
2020
switch (type) {
@@ -49,7 +49,7 @@ function setValue(ptr, value, type, noSafe) {
4949
@param {number|boolean=} noSafe */
5050
function getValue(ptr, type, noSafe) {
5151
type = type || 'i8';
52-
if (type.charAt(type.length-1) === '*') type = {{{ `'${POINTER_TYPE}'` }}};
52+
if (type.charAt(type.length-1) === '*') type = '{{{ POINTER_TYPE }}}';
5353
#if SAFE_HEAP
5454
if (noSafe) {
5555
switch (type) {

src/settings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ var MEMORY_GROWTH_LINEAR_STEP = -1;
237237
// the full end-to-end wasm64 mode, and 2 is wasm64 for clang/lld but lowered to
238238
// wasm32 in Binaryen (such that it can run on wasm32 engines, while internally
239239
// using i64 pointers).
240+
// Assumes WASM_BIGINT.
240241
// [compile+link]
241242
var MEMORY64 = 0;
242243

system/lib/compiler-rt/lib/lsan/lsan_allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct ChunkMetadata {
5050
};
5151

5252
#if defined(__mips64) || defined(__aarch64__) || defined(__i386__) || \
53-
defined(__arm__) || defined(__wasm32__) || defined(__wasm64__)
53+
defined(__arm__) || defined(__wasm__)
5454
static const uptr kRegionSizeLog = 20;
5555
static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
5656
template <typename AddressSpaceView>

system/lib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ struct __sanitizer_file_handle {
427427
};
428428
#endif
429429

430-
#if SANITIZER_MAC
430+
#if SANITIZER_MAC || SANITIZER_EMSCRIPTEN
431431
struct __sanitizer_msghdr {
432432
void *msg_name;
433433
unsigned msg_namelen;
@@ -449,7 +449,7 @@ struct __sanitizer_msghdr {
449449
void *msg_name;
450450
unsigned msg_namelen;
451451
struct __sanitizer_iovec *msg_iov;
452-
unsigned msg_iovlen;
452+
uptr msg_iovlen;
453453
void *msg_control;
454454
unsigned msg_controllen;
455455
int msg_flags;

system/lib/compiler-rt/lib/ubsan/ubsan_flags.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ void InitializeFlags() {
7474
// Override from user-specified string.
7575
parser.ParseString(__ubsan_default_options());
7676
// Override from environment variable.
77-
#if SANITIZER_EMSCRIPTEN && !MEMORY64/*FIXME*/
78-
char *options = (char*)(long)EM_ASM_DOUBLE({
77+
#if SANITIZER_EMSCRIPTEN && !defined(__wasm64__)/*FIXME*/
78+
char *options = (char*) EM_ASM_INT({
7979
return withBuiltinMalloc(function () {
8080
return allocateUTF8(Module['UBSAN_OPTIONS'] || 0);
8181
});

system/lib/libc/musl/src/network/recvmmsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout)
77
{
8-
#if LONG_MAX > INT_MAX && 0 // XXX EMSCRIPTEN: __pad fields don't exist.
8+
#if LONG_MAX > INT_MAX && !defined(__EMSCRIPTEN__)
99
struct mmsghdr *mh = msgvec;
1010
unsigned int i;
1111
for (i = vlen; i; i--, mh++)

system/lib/libc/musl/src/network/recvmsg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
77
{
88
ssize_t r;
9-
#if LONG_MAX > INT_MAX && 0 // XXX EMSCRIPTEN: __pad fields don't exist.
9+
#if LONG_MAX > INT_MAX && !defined(__EMSCRIPTEN__)
1010
struct msghdr h, *orig = msg;
1111
if (msg) {
1212
h = *msg;
@@ -15,7 +15,7 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
1515
}
1616
#endif
1717
r = socketcall_cp(recvmsg, fd, msg, flags, 0, 0, 0);
18-
#if LONG_MAX > INT_MAX && 0 // XXX EMSCRIPTEN: __pad fields don't exist.
18+
#if LONG_MAX > INT_MAX && !defined(__EMSCRIPTEN__)
1919
if (orig) *orig = h;
2020
#endif
2121
return r;

system/lib/libc/musl/src/network/sendmsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
99
{
10-
#if LONG_MAX > INT_MAX && 0 // XXX EMSCRIPTEN: __pad fields don't exist.
10+
#if LONG_MAX > INT_MAX && !defined(__EMSCRIPTEN__)
1111
struct msghdr h;
1212
struct cmsghdr chbuf[1024/sizeof(struct cmsghdr)+1], *c;
1313
if (msg) {

system/lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct times
88
if (rw->_rw_wr_owner == (void *)pthread_self()) return EDEADLK;
99
#endif
1010
int r, t;
11-
11+
1212
r = pthread_rwlock_trywrlock(rw);
1313
if (r != EBUSY) return r;
14-
14+
1515
int spins = 100;
1616
while (spins-- && rw->_rw_lock && !rw->_rw_waiters) a_spin();
1717

system/lib/pthread/library_pthread.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ double emscripten_run_in_main_runtime_thread_js(int index, int num_args, int64_t
675675
}
676676
c->calleeDelete = 1-sync;
677677
c->functionEnum = EM_PROXIED_JS_FUNCTION;
678+
// Index not needed to ever be more than 32-bit.
678679
c->functionPtr = (void*)(size_t)index;
679680
assert(num_args+1 <= EM_QUEUED_JS_CALL_MAX_ARGS);
680681
// The types are only known at runtime in these calls, so we store values that

tests/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def needs_dylink(func):
109109

110110
@wraps(func)
111111
def decorated(self, *args, **kwargs):
112+
if self.get_setting('MEMORY64'):
113+
return self.skipTest('dylink not fully supported with wasm64 yet')
112114
self.check_dylink()
113115
return func(self, *args, **kwargs)
114116

tests/runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ def configure():
327327
common.EMTEST_LACKS_NATIVE_CLANG = int(os.getenv('EMTEST_LACKS_NATIVE_CLANG', '0'))
328328
common.EMTEST_REBASELINE = int(os.getenv('EMTEST_REBASELINE', '0'))
329329
common.EMTEST_VERBOSE = int(os.getenv('EMTEST_VERBOSE', '0')) or shared.DEBUG
330+
global FORCE64
331+
FORCE64 = int(os.getenv('EMTEST_FORCE64', '0'))
330332
if common.EMTEST_VERBOSE:
331333
logging.root.setLevel(logging.DEBUG)
332334

tests/test_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

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

54-
FORCE64 = int(os.getenv('EMTEST_FORCE64', '0'))
54+
FORCE64 = 0
5555

5656

5757
class Benchmarker():

tests/test_core.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,10 +3557,6 @@ def dylink_testf(self, main, side=None, expected=None, force_c=False, main_emcc_
35573557
main_module=2,
35583558
so_name='liblib.so',
35593559
need_reverse=True, **kwargs):
3560-
if self.get_setting('MEMORY64'):
3561-
# FIXME: this is actually mostly working, but disabled for now.
3562-
self.skipTest('dylink not fully supported with wasm64 yet')
3563-
35643560
self.maybe_closure()
35653561
# Same as dylink_test but takes source code as filenames on disc.
35663562
old_args = self.emcc_args.copy()
@@ -8706,7 +8702,7 @@ def test_em_async_js(self):
87068702

87078703

87088704
# Generate tests for everything
8709-
def make_run(name, emcc_args, settings=None, env=None, wasm64=False):
8705+
def make_run(name, emcc_args, settings=None, env=None, node_args=None):
87108706
if env is None:
87118707
env = {}
87128708
if settings is None:
@@ -8725,7 +8721,7 @@ def tearDown(self):
87258721
for k, v in self.env.items():
87268722
del os.environ[k]
87278723

8728-
if wasm64:
8724+
if node_args:
87298725
self.node_args = TT.original
87308726

87318727
TT.tearDown = tearDown
@@ -8743,9 +8739,9 @@ def setUp(self):
87438739

87448740
self.emcc_args += emcc_args
87458741

8746-
if wasm64:
8742+
if node_args:
87478743
TT.original = self.node_args
8748-
self.node_args.append('--experimental-wasm-bigint')
8744+
self.node_args.append(node_args)
87498745

87508746
TT.setUp = setUp
87518747

@@ -8761,8 +8757,8 @@ def setUp(self):
87618757
wasm3 = make_run('wasm3', emcc_args=['-O3'])
87628758
wasms = make_run('wasms', emcc_args=['-Os'])
87638759
wasmz = make_run('wasmz', emcc_args=['-Oz'])
8764-
# wasm64 = make_run('wasm64', emcc_args=['-O0', '-g3', '-s', 'MEMORY64=2'],
8765-
# settings=None, env=None, wasm64=True)
8760+
# wasm64 = make_run('wasm64', emcc_args=['-O0', '-g3'],
8761+
# settings={'MEMORY64':2}, env=None, node_args='--experimental-wasm-bigint')
87668762

87678763
wasmlto0 = make_run('wasmlto0', emcc_args=['-flto', '-O0'])
87688764
wasmlto1 = make_run('wasmlto1', emcc_args=['-flto', '-O1'])

tools/gen_struct_info.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,13 @@ def inspect_headers(headers, cflags):
266266
'-Wno-format',
267267
'-nostdlib',
268268
compiler_rt,
269-
'-s', 'MEMORY64=' + str(settings.MEMORY64),
269+
# FIXME: this setting here won't work, since this is only
270+
# ran once on first use. If there are differences here then
271+
# we would need a second set of json file and have them stored
272+
# separately in the cache.
273+
# Whereever generated_struct_info.json is generated, there now
274+
# needs to be a generated_struct_info64.json for MEMORY64 mode.
275+
#'-s', 'MEMORY64=' + str(settings.MEMORY64),
270276
'-s', 'BOOTSTRAPPING_STRUCT_INFO=1',
271277
'-s', 'LLD_REPORT_UNDEFINED=1',
272278
'-s', 'STRICT',

0 commit comments

Comments
 (0)