Skip to content

Commit d567de3

Browse files
committed
Fix wasm2s (SAFE_HEAP) test suite
This change fixes all the failing tests in the wasm2s suite. Depends on WebAssembly/binaryen#4439.
1 parent 2885620 commit d567de3

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

src/preamble_minimal.js

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

77
#include "runtime_safe_heap.js"
88

9-
#if ASSERTIONS
9+
#if ASSERTIONS || SAFE_HEAP
1010
/** @type {function(*, string=)} */
1111
function assert(condition, text) {
1212
if (!condition) throw text;

src/runtime_safe_heap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function SAFE_HEAP_STORE(dest, value, bytes, isFloat) {
110110
#else
111111
if (dest % bytes !== 0) warnOnce('alignment error in a memory store operation, alignment was a multiple of ' + (((dest ^ (dest-1)) >> 1) + 1) + ', but was was expected to be aligned to a multiple of ' + bytes);
112112
#endif
113-
if (runtimeInitialized) {
113+
if (runtimeInitialized && !runtimeExited) {
114114
var brk = _sbrk() >>> 0;
115115
if (dest + bytes > brk) abort('segmentation fault, exceeded the top of the available dynamic heap when storing ' + bytes + ' bytes to address ' + dest + '. DYNAMICTOP=' + brk);
116116
assert(brk >= _emscripten_stack_get_base()); // sbrk-managed memory must be above the stack
@@ -134,7 +134,7 @@ function SAFE_HEAP_LOAD(dest, bytes, unsigned, isFloat) {
134134
#else
135135
if (dest % bytes !== 0) warnOnce('alignment error in a memory load operation, alignment was a multiple of ' + (((dest ^ (dest-1)) >> 1) + 1) + ', but was was expected to be aligned to a multiple of ' + bytes);
136136
#endif
137-
if (runtimeInitialized) {
137+
if (runtimeInitialized && !runtimeExited) {
138138
var brk = _sbrk() >>> 0;
139139
if (dest + bytes > brk) abort('segmentation fault, exceeded the top of the available dynamic heap when loading ' + bytes + ' bytes from address ' + dest + '. DYNAMICTOP=' + brk);
140140
assert(brk >= _emscripten_stack_get_base()); // sbrk-managed memory must be above the stack

src/shell.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ assert(typeof Module['TOTAL_MEMORY'] === 'undefined', 'Module.TOTAL_MEMORY has b
450450
{{{ makeRemovedFSAssert('IDBFS') }}}
451451
{{{ makeRemovedFSAssert('PROXYFS') }}}
452452
{{{ makeRemovedFSAssert('WORKERFS') }}}
453+
#if !NODERAWFS
453454
{{{ makeRemovedFSAssert('NODEFS') }}}
455+
#endif
454456
{{{ makeRemovedRuntimeFunction('alignMemory') }}}
455457

456458
#if USE_PTHREADS

tests/core/test_functionpointer_libfunc_varargs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ typedef int (*fp_t)(int, int, ...);
1111
int main(int argc, char **argv) {
1212
fp_t fp = &fcntl;
1313
if (argc == 1337) fp = (fp_t) & main;
14-
(*fp)(0, 10);
15-
(*fp)(0, 10, 5);
14+
(*fp)(0, F_GETFL);
15+
(*fp)(0, F_SETSIG, 5);
1616
printf("waka\n");
1717
return 0;
1818
}

tests/test_core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7881,13 +7881,11 @@ def test_memprof_requirements(self):
78817881
# This test checks for the global variables required to run the memory
78827882
# profiler. It would fail if these variables were made no longer global
78837883
# or if their identifiers were changed.
7884-
create_file('main.cpp', '''
7885-
extern "C" {
7886-
void check_memprof_requirements();
7887-
}
7884+
create_file('main.c', '''
7885+
int check_memprof_requirements();
7886+
78887887
int main() {
7889-
check_memprof_requirements();
7890-
return 0;
7888+
return check_memprof_requirements();
78917889
}
78927890
''')
78937891
create_file('lib.js', '''
@@ -7898,14 +7896,16 @@ def test_memprof_requirements(self):
78987896
typeof _emscripten_stack_get_current === 'function' &&
78997897
typeof Module['___heap_base'] === 'number') {
79007898
out('able to run memprof');
7899+
return 0;
79017900
} else {
79027901
out('missing the required variables to run memprof');
7902+
return 1;
79037903
}
79047904
}
79057905
});
79067906
''')
79077907
self.emcc_args += ['--memoryprofiler', '--js-library', 'lib.js']
7908-
self.do_runf('main.cpp', 'able to run memprof')
7908+
self.do_runf('main.c', 'able to run memprof')
79097909

79107910
def test_fs_dict(self):
79117911
self.set_setting('FORCE_FILESYSTEM')

0 commit comments

Comments
 (0)