You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Generates access to module exports variable in pthreads worker.js
1480
+
// Generates access to module exports variable in pthreads worker.js. Depending on whether main code is built with MODULARIZE
1481
+
// or not, asm module exports need to either be accessed via a local exports object obtained from instantiating the module (in src/worker.js), or via
1482
+
// the global Module exports object.
1481
1483
functionmakeAsmExportAccessInPthread(variable){
1482
1484
if(MODULARIZE){
1483
1485
return"Module['"+variable+"']"// 'Module' is defined in worker.js local scope, so not EXPORT_NAME in this case.
@@ -1486,7 +1488,8 @@ function makeAsmExportAccessInPthread(variable) {
1486
1488
}
1487
1489
}
1488
1490
1489
-
// Generates access to a global scope variable in pthreads worker.js
1491
+
// Generates access to a JS global scope variable in pthreads worker.js. In MODULARIZE mode the JS scope is not directly accessible, so all the relevant variables
1492
+
// are exported via Module. In non-MODULARIZE mode, we can directly access the variables in global scope.
1490
1493
functionmakeAsmGlobalAccessInPthread(variable){
1491
1494
if(MODULARIZE){
1492
1495
return"Module['"+variable+"']"// 'Module' is defined in worker.js local scope, so not EXPORT_NAME in this case.
@@ -1496,8 +1499,8 @@ function makeAsmGlobalAccessInPthread(variable) {
1496
1499
}
1497
1500
1498
1501
// Generates access to both global scope variable and exported Module variable, e.g. "Module['foo'] = foo" or just plain "foo" depending on if we are MODULARIZEing.
1499
-
// Used the be able to initialize both variables at the same time.
Copy file name to clipboardExpand all lines: src/shell.js
+2-29Lines changed: 2 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -76,41 +76,14 @@ if (Module['ENVIRONMENT']) {
76
76
}
77
77
#endif
78
78
79
-
// Three configurations we can be running in:
80
-
// 1) We could be the application main() thread running in the main JS UI thread. (ENVIRONMENT_IS_WORKER == false and ENVIRONMENT_IS_PTHREAD == false)
81
-
// 2) We could be the application main() thread proxied to worker. (with Emscripten -s PROXY_TO_WORKER=1) (ENVIRONMENT_IS_WORKER == true, ENVIRONMENT_IS_PTHREAD == false)
82
-
// 3) We could be an application pthread running in a worker. (ENVIRONMENT_IS_WORKER == true and ENVIRONMENT_IS_PTHREAD == true)
83
-
#if USE_PTHREADS
84
-
85
-
if(typeofENVIRONMENT_IS_PTHREAD==='undefined'){
86
-
// ENVIRONMENT_IS_PTHREAD=true will have been preset in worker.js. Make it false in the main runtime thread.
87
-
// N.B. this line needs to appear without 'var' keyword to avoid 'var hoisting' from occurring. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var)
88
-
ENVIRONMENT_IS_PTHREAD=false;
89
-
varPthreadWorkerInit={};// Collects together variables that are needed at initialization time for the web workers that host pthreads.
// Note that not all runtime fields are imported above. Values for STACK_BASE, STACKTOP and STACK_MAX are not yet known at worker.js load time.
102
-
// These will be filled in at pthread startup time (the 'run' message for a pthread - pthread start establishes the stack frame)
103
-
}
104
-
#endif
79
+
#include "shell_pthreads.js"
105
80
106
-
#if !MODULARIZE
81
+
#if USE_PTHREADS&&!MODULARIZE
107
82
// In MODULARIZE mode _scriptDir needs to be captured already at the very top of the page immediately when the page is parsed, so it is generated there
108
83
// before the page load. In non-MODULARIZE modes generate it here.
// 1) We could be the application main() thread running in the main JS UI thread. (ENVIRONMENT_IS_WORKER == false and ENVIRONMENT_IS_PTHREAD == false)
3
+
// 2) We could be the application main() thread proxied to worker. (with Emscripten -s PROXY_TO_WORKER=1) (ENVIRONMENT_IS_WORKER == true, ENVIRONMENT_IS_PTHREAD == false)
4
+
// 3) We could be an application pthread running in a worker. (ENVIRONMENT_IS_WORKER == true and ENVIRONMENT_IS_PTHREAD == true)
5
+
#if USE_PTHREADS
6
+
7
+
if(typeofENVIRONMENT_IS_PTHREAD==='undefined'){
8
+
// ENVIRONMENT_IS_PTHREAD=true will have been preset in worker.js. Make it false in the main runtime thread.
9
+
// N.B. this line needs to appear without 'var' keyword to avoid 'var hoisting' from occurring. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var)
10
+
ENVIRONMENT_IS_PTHREAD=false;
11
+
varPthreadWorkerInit={};// Collects together variables that are needed at initialization time for the web workers that host pthreads.
0 commit comments