Skip to content

Move sharedModules object to runtime_pthread.js #23998

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 8 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ function stackCheckInit() {
}
#endif

#if MAIN_MODULE && PTHREADS
// Map of modules to be shared with new threads. This gets populated by the
// main thread and shared with all new workers via the initial `load` message.
var sharedModules = {};
#endif

#if MAIN_READS_PARAMS
function run(args = arguments_) {
#else
Expand Down
6 changes: 6 additions & 0 deletions src/runtime_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
var workerID = 0;
#endif

#if MAIN_MODULE
// Map of modules to be shared with new threads. This gets populated by the
// main thread and shared with all new workers via the initial `load` message.
var sharedModules = {};
#endif

if (ENVIRONMENT_IS_PTHREAD) {
#if !MINIMAL_RUNTIME
var wasmModuleReceived;
Expand Down
3 changes: 2 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,7 @@ def test(link_flags, lib_suffix):
test(['libdir/libfile.so.3.1.4.1.5.9'], '.3.1.4.1.5.9') # handle libX.so.1.2.3 as well

@node_pthreads
@also_with_modularize
def test_dylink_pthread_static_data(self):
# Test that a side module uses the same static data region for global objects across all threads

Expand Down Expand Up @@ -15272,7 +15273,7 @@ def test_preload_module(self, args):

// Check that it was preloaded.
// The preloading actually only happens on the main thread where the filesystem
// lives. On worker threads the module object is shared via preloadedModules.
// lives. On worker threads the module object is shared via sharedModules.
if (emscripten_is_main_runtime_thread()) {
int found = EM_ASM_INT(
return preloadedWasm['/library.so'] !== undefined;
Expand Down