-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Remove special case JS function proxying from library_pthread.c #16405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove special case JS function proxying from library_pthread.c #16405
Conversation
bf4e1b0
to
0f1095f
Compare
system/lib/pthread/library_pthread.c
Outdated
case EM_PROXIED_CREATE_CONTEXT: | ||
q->returnValue.i = emscripten_webgl_create_context(q->args[0].cp, q->args[1].vp); | ||
break; | ||
#ifdef __EMSCRIPTEN_OFFSCREEN_CANVAS__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating another libc variant purely for this purpose seems rather unfortunate.
Can we leave this in unconditionally for now, and submit PR that just removes the EM_PROXIED_CREATE_CONTEXT
? Then we can figure out how to somehow
incject this handler only when OFFSCREEN_CANVAS is enabled as a followup?
Perhaps we can do it via some kind of dependency injections of extension mechanism
for _do_call
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted for now with commit 815f592. I'm not sure what the best way is to handle this.
src/library_pthread.js
Outdated
#if !MINIMAL_RUNTIME | ||
'$handleException', | ||
#endif | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unrelated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This NFC change (commit 0f1095f) was found while working on this, but is indeed unrelated. Let me know if you want to revert that too (for now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this code calls the _exit
C function so I don't understand how removing the dependency can be correct?
In any case please split this out into a separate change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These dependencies are also defined in $PThread__deps
, so it's just de-duplicating the deps here.
emscripten/src/library_pthread.js
Lines 9 to 18 in 0f1095f
$PThread__deps: ['_emscripten_thread_init', | |
'$killThread', | |
'$cancelThread', '$cleanupThread', '$zeroMemory', | |
'$ptrToString', '$spawnThread', | |
'_emscripten_thread_free_data', | |
'exit', | |
#if !MINIMAL_RUNTIME | |
'$handleException', | |
#endif | |
], |
I'll revert this change for now.
@@ -1 +1 @@ | |||
47521 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty nice size reduction!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to reduce it even more with commit b3beb21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give this PR the correct title and description and then I think we can land this.
82751c5
to
495f493
Compare
PR description and title were updated as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
The normal `__proxy` method for JS functions works fine in these cases and avoiding the special cases reduces the dependencies of `library_pthread.c` which is included in all threaded programs.
i.e. when building with `-sOFFSCREENCANVAS_SUPPORT=0` (default)
…pported" This reverts commit 670eecd.
495f493
to
67bac98
Compare
The dependency wrangling here was a workaround for a problem that was solved in #16405 (see the command that is being deleted). Pretty much all the functions in this depend either directly or indirectly on the global GL object, so it makes sense to use autoAddDeps rather than try to add individual deps.
This family of function was not used anywhere can not currently usable externally. The core function `emscripten_sync_run_in_main_thread` was not usable since the its first argument is `em_queued_call` which is not struct that is declared externally. The `emscripten_sync_run_in_main_thread_N` function all take a function index as arg0 which is a index in to the JS function table which is not known statically, and is an implementation of detail of JS library proxying. It looks like these function were once used by JS library code but the last remaining use of them was removed in #16405.
This family of function was not used anywhere and is not currently usable externally. The core function `emscripten_sync_run_in_main_thread` was not usable since the its first argument is `em_queued_call` which is not struct that is declared externally. The `emscripten_sync_run_in_main_thread_N` function takes a function enum as arg0 which is not designed to be user facing. It looks like these function were once used by JS library code but the last remaining use of them was removed in #16405. See: #15756
…18580) This family of functions was not used anywhere within the codebase and is not currently usable externally. The core function `emscripten_sync_run_in_main_thread` was not usable since the its first argument is `em_queued_call` which is not struct that is declared externally. The `emscripten_sync_run_in_main_thread_N` functions takes a function enum as arg0 which is not designed to be user facing. It looks like these function were once used by JS library code but the last remaining use of them was removed in #16405. See: #15756
The dependency wrangling here was a workaround for a problem that was solved in #16405 (see the command that is being deleted). Pretty much all the functions in this depend either directly or indirectly on the global GL object, so it makes sense to use autoAddDeps rather than try to add individual deps.
The dependency wrangling here was a workaround for a problem that was solved in #16405 (see the command that is being deleted). Pretty much all the functions in this depend either directly or indirectly on the global GL object, so it makes sense to use autoAddDeps rather than try to add individual deps.
The normal
__proxy
method for JS functions works fine in these casesand avoiding the special cases reduces the dependencies of
library_pthread.c
which is included in all threaded programs.