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
Copy file name to clipboardExpand all lines: emcc.py
+38-9Lines changed: 38 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1081,6 +1081,15 @@ def check(input_file):
1081
1081
ifshared.Settings.MODULARIZE_INSTANCE:
1082
1082
shared.Settings.MODULARIZE=1
1083
1083
1084
+
ifshared.Settings.MODULARIZE:
1085
+
assertnotoptions.proxy_to_worker, '-s MODULARIZE=1 and -s MODULARIZE_INSTANCE=1 are not compatible with --proxy-to-worker (if you want to run in a worker with -s MODULARIZE=1, you likely want to do the worker side setup manually)'
1086
+
1087
+
ifnotshared.Settings.EXPORT_NAME:
1088
+
# If we are building directly to .html with -s MODULARIZE=1 (but not -s MODULARIZE_INSTANCE=1), default to exporting
1089
+
# Emscripten code under function EmscriptenCode() so that it does not collide with the Module object. (When not modularizing,
1090
+
# or if building with MODULARIZE_INSTANCE, or if building to .js manually, there is no conflict, so default to 'Module' in those cases)
// Generates access to module exports variable in pthreads worker.js
1481
+
functionmakeAsmExportAccessInPthread(variable){
1482
+
if(MODULARIZE){
1483
+
return"Module['"+variable+"']"// 'Module' is defined in worker.js local scope, so not EXPORT_NAME in this case.
1484
+
}else{
1485
+
returnEXPORT_NAME+"['"+variable+"']"
1486
+
}
1487
+
}
1488
+
1489
+
// Generates access to a global scope variable in pthreads worker.js
1490
+
functionmakeAsmGlobalAccessInPthread(variable){
1491
+
if(MODULARIZE){
1492
+
return"Module['"+variable+"']"// 'Module' is defined in worker.js local scope, so not EXPORT_NAME in this case.
1493
+
}else{
1494
+
returnvariable
1495
+
}
1496
+
}
1497
+
1498
+
// 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.
importScripts('{{{ SEPARATE_ASM }}}');// load the separated-out asm.js
411
-
#endif
412
-
}
413
-
#endif
414
-
415
407
#if EMTERPRETIFY
416
408
functionabortStackOverflowEmterpreter(){
417
409
abort("Emterpreter stack overflow! Decrease the recursion level or increase EMT_STACK_MAX in tools/emterpretify.py (current value "+EMT_STACK_MAX+").");
Copy file name to clipboardExpand all lines: src/shell.js
+28-5Lines changed: 28 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -81,11 +81,34 @@ if (Module['ENVIRONMENT']) {
81
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
82
// 3) We could be an application pthread running in a worker. (ENVIRONMENT_IS_WORKER == true and ENVIRONMENT_IS_PTHREAD == true)
83
83
#if USE_PTHREADS
84
-
varENVIRONMENT_IS_PTHREAD;
85
-
if(!ENVIRONMENT_IS_PTHREAD)ENVIRONMENT_IS_PTHREAD=false;// ENVIRONMENT_IS_PTHREAD=true will have been preset in worker.js. Make it false in the main runtime thread.
86
-
varPthreadWorkerInit;// Collects together variables that are needed at initialization time for the web workers that host pthreads.
// 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
105
+
106
+
#if !MODULARIZE
107
+
// 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
+
// before the page load. In non-MODULARIZE modes generate it here.
0 commit comments