-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[esm-integration] Add pthread support #24555
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
I found a way to make it work! Not pretty, but it works! |
I think I was confused at some point and thought that only ASYNCIFY=1 was not supported. Split out from emscripten-core#24555
1233179
to
967f7fa
Compare
I think I was confused at some point and thought that only ASYNCIFY=1 was not supported. Split out from emscripten-core#24555
967f7fa
to
cf8e793
Compare
I think I was confused at some point and thought that only ASYNCIFY=1 was not supported. Split out from #24555
This function doesn't need to take an argument or be declared in closure externs anymore. Split out from emscripten-core#24555
This function doesn't need to take an argument or be declared in closure externs anymore. Split out from #24555
cf8e793
to
18d5a3a
Compare
9da3bec
to
b10d786
Compare
This change has now been simplified a lot. I think its good to go now. PTAL |
src/postamble.js
Outdated
// When run as a worker thread run `init` immediately. | ||
if ({{{ ENVIRONMENT_IS_WORKER_THREAD() }}}) await init() | ||
if ({{{ ENVIRONMENT_IS_WORKER_THREAD() }}}) init() |
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.
if ({{{ ENVIRONMENT_IS_WORKER_THREAD() }}}) init() | |
if ({{{ ENVIRONMENT_IS_WORKER_THREAD() }}}) init(); |
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.
(pre-existing, but still)
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 this line.
b10d786
to
79d4b0b
Compare
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.
Now I see, thanks. Tricky but nice how you got it to work.
Under ESM integration all dependencies must be satisfied at import time, but pthreads requires that we have supply the memory via postMessage, so the memory is, by definition, not available at import time. On order to work around this issue we create a smaller pthread stub/loader file that delays the import of the main program until the initial `postMessage` has been received. Once the memory is received we load main program using a dynamic `import` statement.
79d4b0b
to
968bbbc
Compare
Under ESM integration all dependencies must be satisfied at import time, but pthreads requires that we have supply the memory via postMessage, so the memory is, by definition, not available at import time.
On order to work around this issue we create a smaller pthread stub/loader file that delays the import of the main program until the initial
postMessage
has been received. Once the memory is received we load main program using a dynamicimport
statement.