-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Export runtime keepalive API to native code. NFC #17160
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
Conversation
Sometimes it is useful to be able to make the runtime as alive without also unwinding. See test_pthread_proxying_cpp.cpp for an example of this. I also have use case for emscripten_runtime_keepalive_check() in #17153
3dcf8a2
to
cd1adeb
Compare
const mangledName = mangleCSymbolName(target); | ||
lib[x] = new Function(args, `${ret}${mangledName}(${args});`); |
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 related?
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.
Yes, without this you can't have the target of the alias be an internal JS function (i.e. one that starts with $
).
I could rename the internal $runtimeKeepalivePush
so that we don't need aliases at all but that would make the patch way bigger and should probable be a followup.
emscripten_runtime_keepalive_push: '$runtimeKeepalivePush', | ||
emscripten_runtime_keepalive_pop: '$runtimeKeepalivePop', | ||
emscripten_runtime_keepalive_check: function() { | ||
// keepRuntimeAlive is a runtime function rather than a library function, |
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.
What is the difference between a runtime function and a library function?
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.
A runtime function is just a few function in the JS preamble/postamble/etc. There is no way to include or exclude runtime functions.
Library functions are the ones defined in these specifically-formed library files (mostly src/library.js
and src/library_*.js
. Library functions are included on demand and never included unless somebody depends on them. We tend to prefer library functions these day because they have no impact on users codesize unless they are actually needed.
@@ -26,6 +26,10 @@ void emscripten_set_immediate_loop(EM_BOOL (*cb)(void *userData), void *userData | |||
long emscripten_set_interval(void (*cb)(void *userData), double intervalMsecs, void *userData); | |||
void emscripten_clear_interval(long setIntervalId); | |||
|
|||
void emscripten_runtime_keepalive_push(); | |||
void emscripten_runtime_keepalive_pop(); | |||
EM_BOOL emscripten_runtime_keepalive_check(); |
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.
Why does EM_BOOL exist? Why not just use int or bool here?
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.
It exists yes. It pre-dates my involvement with the project.
I guess we could use <stdbool.h>
these days but I'm not sure I'd want to force all emscripten users to include <stdbool.h>
.. since it does pollute the global namespace.
Sometimes it is useful to be able to make the runtime as alive without
also unwinding. See test_pthread_proxying_cpp.cpp for an example of
this.
I also have use case for emscripten_runtime_keepalive_check() in #17153