diff --git a/src/worker.js b/src/worker.js index 9580faa67c9a..643a225fa6ab 100644 --- a/src/worker.js +++ b/src/worker.js @@ -191,8 +191,14 @@ this.onmessage = function(e) { assert(selfThreadId); assert(parentThreadId); assert(STACK_BASE != 0); -#if !WASM_BACKEND - assert(STACK_MAX > STACK_BASE); +#if WASM_BACKEND + assert(max === e.data.stackBase); + assert(top > max); + assert(e.data.stackBase == max); +#else + assert(max > e.data.stackBase); + assert(max > top); + assert(e.data.stackBase === top); #endif #endif // Call inside asm.js/wasm module to set up the stack frame for this pthread in asm.js/wasm module scope diff --git a/tests/test_browser.py b/tests/test_browser.py index 4c128730e9fa..4c05fbb5d1fb 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -3538,13 +3538,11 @@ def prep_no_SAB(self): # Test that the emscripten_ atomics api functions work. @requires_threads - @no_wasm_backend('TODO - fix final pthreads tests (#8718)') def test_pthread_atomics(self): self.btest(path_from_root('tests', 'pthread', 'test_pthread_atomics.cpp'), expected='0', args=['-s', 'TOTAL_MEMORY=64MB', '-O3', '-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=8']) # Test 64-bit atomics. @requires_threads - @flaky # TODO - fix final pthreads tests (#8718) def test_pthread_64bit_atomics(self): self.btest(path_from_root('tests', 'pthread', 'test_pthread_64bit_atomics.cpp'), expected='0', args=['-s', 'TOTAL_MEMORY=64MB', '-O3', '-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=8']) @@ -3557,17 +3555,17 @@ def test_pthread_64bit_cxx11_atomics(self): # Test the old GCC atomic __sync_fetch_and_op builtin operations. @requires_threads - @no_wasm_backend('TODO - fix final pthreads tests (#8718)') def test_pthread_gcc_atomic_fetch_and_op(self): # We need to resort to using regexes to optimize out SharedArrayBuffer when pthreads are not supported, which is brittle! # Therefore perform very extensive testing of different codegen modes to catch any problems. - for opt in [[], ['-O1'], ['-O2'], ['-O3'], ['-O3', '-s', 'AGGRESSIVE_VARIABLE_ELIMINATION=1'], ['-Os'], ['-Oz']]: + for opt in [[], ['-O1'], ['-O2'], ['-O3'], ['-O3', '-s', 'AGGRESSIVE_VARIABLE_ELIMINATION=1'], ['-Os']]: for debug in [[], ['-g1'], ['-g2'], ['-g4']]: for f32 in [[], ['-s', 'PRECISE_F32=1', '--separate-asm', '-s', 'WASM=0']]: - print(opt, debug, f32) - if self.is_wasm_backend() and '--separate-asm' in f32: + args = opt + debug + f32 + print(args) + if self.is_wasm_backend() and '--separate-asm' in args or 'AGGRESSIVE_VARIABLE_ELIMINATION=1' in args: continue - self.btest(path_from_root('tests', 'pthread', 'test_pthread_gcc_atomic_fetch_and_op.cpp'), expected='0', args=opt + debug + f32 + ['-s', 'TOTAL_MEMORY=64MB', '-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=8']) + self.btest(path_from_root('tests', 'pthread', 'test_pthread_gcc_atomic_fetch_and_op.cpp'), expected='0', args=args + ['-s', 'TOTAL_MEMORY=64MB', '-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=8']) # 64 bit version of the above test. @requires_threads @@ -3590,7 +3588,6 @@ def test_pthread_gcc_atomics(self): self.btest(path_from_root('tests', 'pthread', 'test_pthread_gcc_atomics.cpp'), expected='0', args=['-s', 'TOTAL_MEMORY=64MB', '-O3', '-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=8']) # Test the __sync_lock_test_and_set and __sync_lock_release primitives. - @no_wasm_backend('TODO - fix final pthreads tests (#8718)') @requires_threads def test_pthread_gcc_spinlock(self): for arg in [[], ['-DUSE_EMSCRIPTEN_INTRINSICS']]: @@ -3598,7 +3595,6 @@ def test_pthread_gcc_spinlock(self): # Test that basic thread creation works. @requires_threads - @no_wasm_backend('TODO - fix final pthreads tests (#8718)') def test_pthread_create(self): def test(args): print(args) @@ -3615,7 +3611,6 @@ def test_pthread_proxy_to_pthread(self): # Test that a pthread can spawn another pthread of its own. @requires_threads - @no_wasm_backend('TODO - fix final pthreads tests (#8718)') def test_pthread_create_pthread(self): for modularize in [[], ['-s', 'MODULARIZE=1', '-s', 'EXPORT_NAME=MyModule', '--shell-file', path_from_root('tests', 'shell_that_launches_modularize.html')]]: self.btest(path_from_root('tests', 'pthread', 'test_pthread_create_pthread.cpp'), expected='1', args=['-O3', '-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=2'] + modularize) @@ -3632,7 +3627,6 @@ def test_pthread_join(self): # Test that threads can rejoin the pool once detached and finished @requires_threads - @no_wasm_backend('TODO - fix final pthreads tests (#8718)') def test_std_thread_detach(self): self.btest(path_from_root('tests', 'pthread', 'test_std_thread_detach.cpp'), expected='0', args=['-std=c++11', '-s', 'USE_PTHREADS=1']) @@ -3796,7 +3790,6 @@ def test_pthread_proxying_in_futex_wait(self): self.btest(path_from_root('tests', 'pthread', 'test_pthread_proxying_in_futex_wait.cpp'), expected='0', args=['-O3', '-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=1']) # Test that sbrk() operates properly in multithreaded conditions - @no_wasm_backend('TODO - fix final pthreads tests (#8718)') @requires_threads def test_pthread_sbrk(self): for aborting_malloc in [0, 1]: