Skip to content

Commit 750e193

Browse files
committed
Ignore value of __proxy in WASM_WORKERS mode. NFC
Fixes: #20134
1 parent e69b6cf commit 750e193

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/jsifier.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ function(${args}) {
228228
if (SHARED_MEMORY) {
229229
const proxyingMode = LibraryManager.library[symbol + '__proxy'];
230230
if (proxyingMode) {
231-
if (proxyingMode !== 'sync' && proxyingMode !== 'async') {
232-
throw new Error(`Invalid proxyingMode ${symbol}__proxy: '${proxyingMode}' specified!`);
233-
}
234-
const sync = proxyingMode === 'sync';
235231
if (PTHREADS) {
232+
if (proxyingMode !== 'sync' && proxyingMode !== 'async') {
233+
error(`Invalid proxyingMode ${symbol}__proxy: '${proxyingMode}' specified!`);
234+
}
235+
const sync = proxyingMode === 'sync';
236236
snippet = modifyJSFunction(snippet, (args, body, async_, oneliner) => {
237237
if (oneliner) {
238238
body = `return ${body}`;

test/wasm_worker/proxied_function.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ void run_in_worker()
2828
}
2929
}
3030

31-
int main()
32-
{
31+
int main() {
32+
// Calling the proxied function form the main thread should succeed.
33+
proxied_js_function();
34+
35+
// Calling it from a worker should fail
3336
emscripten_wasm_worker_post_function_v(emscripten_malloc_wasm_worker(1024), run_in_worker);
34-
proxied_js_function(); // Pin a dependency from C code to the JS function to avoid needing to mess with cmdline export directives
3537
}

test/wasm_worker/proxied_function.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
addToLibrary({
2-
proxied_js_function__proxy: 'sync',
2+
// Use a non-standaed __proxy flag here.
3+
// This is used, for example, in library_html5_webgl.js. With WASM_WORKERS
4+
// we want the build to succeed rather than complain about the invalid
5+
// proxy type.
6+
proxied_js_function__proxy: 'sync_on_webgl_context_handle_thread',
37
proxied_js_function__sig: 'v',
4-
proxied_js_function: function() {
5-
console.log('In proxied_js_function');
6-
}
8+
proxied_js_function: () => console.log('In proxied_js_function'),
79
});

0 commit comments

Comments
 (0)