Skip to content

Commit 1e2ed1d

Browse files
committed
Ignore value of __proxy in WASM_WORKERS mode. NFC
Fixes: #20134
1 parent 0a6f54b commit 1e2ed1d

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
// This test checks whether attempting to call a proxied JS function (one with __proxy signature) will throw
2-
// an exception.
1+
// This test checks whether attempting to call a proxied JS function (one with
2+
// __proxy signature) will throw an exception.
33

44
#include <emscripten.h>
55
#include <emscripten/wasm_worker.h>
66

77
void proxied_js_function(void);
88

9-
void test_finished()
10-
{
9+
void test_finished() {
1110
REPORT_RESULT(0);
1211
}
1312

14-
void run_in_worker()
15-
{
13+
void run_in_worker() {
1614
int threw = EM_ASM_INT({
1715
try {
1816
_proxied_js_function();
@@ -28,8 +26,10 @@ void run_in_worker()
2826
}
2927
}
3028

31-
int main()
32-
{
29+
int main() {
30+
// Calling the proxied function from the main thread should always succeed.
31+
proxied_js_function();
32+
33+
// Calling it from a worker should fail
3334
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
3535
}

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-standard __proxy flag here.
3+
// This is used, for example, in library_html5_webgl.j which uses
4+
// sync_on_webgl_context_handle_thread. With WASM_WORKERS we want the build
5+
// to succeed rather than complain about the invalid proxy type.
6+
proxied_js_function__proxy: 'xx_non_standard',
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)