Skip to content

Commit 11e8eee

Browse files
committed
[wasm64] Run wasm worker tests in browser64
Split out from emscripten-core#20516
1 parent df5b37d commit 11e8eee

File tree

7 files changed

+34
-8
lines changed

7 files changed

+34
-8
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ jobs:
823823
browser64.test_pthread_*
824824
browser64.test_wget_*
825825
browser64.test_emscripten_async_wget_*
826+
browser64.test_wasm_worker_*
826827
"
827828
test-browser-firefox:
828829
executor: bionic

src/library_wasm_worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ if (ENVIRONMENT_IS_WASM_WORKER) {
262262
emscripten_lock_async_acquire: (lock, asyncWaitFinished, userData, maxWaitMilliseconds) => {
263263
let dispatch = (val, ret) => {
264264
setTimeout(() => {
265-
{{{ makeDynCall('viiii', 'asyncWaitFinished') }}}(lock, val, /*waitResult=*/ret, userData);
265+
{{{ makeDynCall('vpiip', 'asyncWaitFinished') }}}(lock, val, /*waitResult=*/ret, userData);
266266
}, 0);
267267
};
268268
let tryAcquireLock = () => {

test/test_browser.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ def also_with_wasm2js(f):
119119
def metafunc(self, with_wasm2js):
120120
assert self.get_setting('WASM') is None
121121
if with_wasm2js:
122-
if self.is_wasm64():
123-
self.skipTest('wasm2js is not compatible with MEMORY64')
122+
self.require_wasm2js()
124123
self.set_setting('WASM', 0)
125124
f(self)
126125
else:
@@ -166,6 +165,7 @@ def is_jspi(args):
166165
def no_swiftshader(f):
167166
assert callable(f)
168167

168+
@wraps(f)
169169
def decorated(self, *args, **kwargs):
170170
if is_chrome() and '--use-gl=swiftshader' in EMTEST_BROWSER:
171171
self.skipTest('not compatible with swiftshader')
@@ -177,6 +177,7 @@ def decorated(self, *args, **kwargs):
177177
def requires_threads(f):
178178
assert callable(f)
179179

180+
@wraps(f)
180181
def decorated(self, *args, **kwargs):
181182
if os.environ.get('EMTEST_LACKS_THREAD_SUPPORT'):
182183
self.skipTest('EMTEST_LACKS_THREAD_SUPPORT is set')
@@ -185,14 +186,28 @@ def decorated(self, *args, **kwargs):
185186
return decorated
186187

187188

189+
def requires_wasm2js(f):
190+
assert callable(f)
191+
192+
@wraps(f)
193+
def decorated(self, *args, **kwargs):
194+
self.require_wasm2js()
195+
return f(self, *args, **kwargs)
196+
197+
return decorated
198+
199+
188200
def also_with_threads(f):
201+
assert callable(f)
202+
189203
@wraps(f)
190204
def decorated(self, *args, **kwargs):
191205
f(self, *args, **kwargs)
192206
if not os.environ.get('EMTEST_LACKS_THREAD_SUPPORT'):
193207
print('(threads)')
194208
self.emcc_args += ['-pthread']
195209
f(self, *args, **kwargs)
210+
196211
return decorated
197212

198213

@@ -223,6 +238,10 @@ def require_wasm64(self):
223238
# All the browsers we run on support wasm64 (Chrome and Firefox).
224239
return True
225240

241+
def require_wasm2js(self):
242+
if self.is_wasm64():
243+
self.skipTest('wasm2js is not compatible with MEMORY64')
244+
226245
def require_jspi(self):
227246
if not is_chrome():
228247
self.skipTest(f'Current browser ({EMTEST_BROWSER}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')
@@ -5218,12 +5237,14 @@ def test_wasm_worker_hello_minimal_runtime_2(self):
52185237
self.btest('wasm_worker/hello_wasm_worker.c', expected='0', args=['-sWASM_WORKERS', '-sMINIMAL_RUNTIME=2'])
52195238

52205239
# Tests Wasm Workers build in Wasm2JS mode.
5240+
@requires_wasm2js
52215241
@also_with_minimal_runtime
52225242
def test_wasm_worker_hello_wasm2js(self):
52235243
self.btest('wasm_worker/hello_wasm_worker.c', expected='0', args=['-sWASM_WORKERS', '-sWASM=0'])
52245244

52255245
# Tests the WASM_WORKERS=2 build mode, which embeds the Wasm Worker bootstrap JS script file to the main JS file.
52265246
@also_with_minimal_runtime
5247+
@no_wasm64()
52275248
def test_wasm_worker_embedded(self):
52285249
self.btest('wasm_worker/hello_wasm_worker.c', expected='0', args=['-sWASM_WORKERS=2'])
52295250

test/wasm_worker/lock_async_acquire.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@ void schedule_work(void *userData)
9090
}
9191
}
9292

93+
void start_worker(int arg) {
94+
schedule_work(0);
95+
}
96+
9397
int main()
9498
{
9599
#define NUM_THREADS 10
96100
for(int i = 0; i < NUM_THREADS; ++i)
97101
{
98102
emscripten_wasm_worker_t worker = emscripten_malloc_wasm_worker(1024);
99-
emscripten_wasm_worker_post_function_vi(worker, (void (*)(int))schedule_work, 0);
103+
emscripten_wasm_worker_post_function_vi(worker, start_worker, 0);
100104
}
101105

102106
schedule_work(0);

test/wasm_worker/no_proxied_js_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int should_throw(void(*func)())
2525
}
2626
console.error('Function was expected to throw, but did not!');
2727
return 0;
28-
}, (int)func);
28+
}, func);
2929
return threw;
3030
}
3131

test/wasm_worker/terminate_all_wasm_workers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int should_throw(void(*func)(emscripten_wasm_worker_t worker), emscripten_wasm_w
5252
}
5353
console.error('Function was expected to throw, but did not!');
5454
return 0;
55-
}, (int)func, worker);
55+
}, func, worker);
5656
return threw;
5757
}
5858

test/wasm_worker/terminate_wasm_worker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ int should_throw(void(*func)())
4444
{
4545
int threw = EM_ASM_INT({
4646
try {
47-
dynCall('v', $0);
47+
dynCall('v', Number($0));
4848
} catch(e) {
4949
console.error('Threw an exception like expected: ' + e);
5050
return 1;
5151
}
5252
console.error('Function was expected to throw, but did not!');
5353
return 0;
54-
}, (int)func);
54+
}, func);
5555
return threw;
5656
}
5757

0 commit comments

Comments
 (0)