Skip to content

Don't do memory operations in pthreads before the runtime is initialized. NFC #12052

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

Merged
merged 2 commits into from
Aug 28, 2020

Conversation

kripken
Copy link
Member

@kripken kripken commented Aug 26, 2020

Pthreads.initMainThreadBlock is called during "preRun" (before compiled code is ready) and
Pthreads.initRuntime is called during "atInit" (when compiled code is ready, just before
global ctors). This moves some code from the former into the latter. Specifically it moves
all allocation and memory operations.

This leaves initMainThreadBlock to only do pure JS operations for preloading the workers,
and everything else to initRuntime.

@sbc100
Copy link
Collaborator

sbc100 commented Aug 26, 2020

Looks reasonable but I don't know this code well. @juj?

@kripken kripken merged commit aa2731d into master Aug 28, 2020
@kripken kripken deleted the prestat branch August 28, 2020 14:23
@@ -41,7 +35,8 @@ var LibraryPThread = {
PThread.allocateUnusedWorker();
}
#endif

},
initRuntime: function() {
PThread.mainThreadBlock = {{{ makeStaticAlloc(C_STRUCTS.pthread.__size__) }}};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this change, the function initMainThreadBlock no longer initializes PThread.mainThreadBlock (but instead initRuntime does that). That naming mismatch is awkward, so maybe change name initMainThreadBlock to loadPThreadPool or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juj good point, thanks, I opened #12604 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants