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
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
+20-5Lines changed: 20 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -81,11 +81,26 @@ 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 pthread-main.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.
Copy file name to clipboardExpand all lines: src/worker.js
+71-37Lines changed: 71 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,10 @@ var __performance_now_clock_drift = 0;
38
38
// Therefore implement custom logging facility for threads running in a worker, which queue the messages to main thread to print.
39
39
varModule={};
40
40
41
+
functionassert(condition,text){
42
+
if(!condition)abort('Assertion failed: '+text);
43
+
}
44
+
41
45
// When error objects propagate from Web Worker to main thread, they lose helpful call stack and thread ID information, so print out errors early here,
}elseif(e.data.cmd==='run'){// This worker was idle, and now should start executing its pthread entry point.
120
151
__performance_now_clock_drift=performance.now()-e.data.time;// Sync up to the clock of the main thread.
121
152
threadInfoStruct=e.data.threadInfoStruct;
122
-
__register_pthread_ptr(threadInfoStruct,/*isMainBrowserThread=*/0,/*isMainRuntimeThread=*/0);// Pass the thread address inside the asm.js scope to store it for fast access that avoids the need for a FFI out.
153
+
Module.__register_pthread_ptr(threadInfoStruct,/*isMainBrowserThread=*/0,/*isMainRuntimeThread=*/0);// Pass the thread address inside the asm.js scope to store it for fast access that avoids the need for a FFI out.
123
154
assert(threadInfoStruct);
124
155
selfThreadId=e.data.selfThreadId;
125
156
parentThreadId=e.data.parentThreadId;
126
157
assert(selfThreadId);
127
158
assert(parentThreadId);
128
159
// TODO: Emscripten runtime has these variables twice(!), once outside the asm.js module, and a second time inside the asm.js module.
Atomics.store(HEAPU32,(threadInfoStruct+4/*{{{ C_STRUCTS.pthread.threadExitCode }}}*/)>>2,(einstanceofExitStatus) ? e.status : -2/*A custom entry specific to Emscripten denoting that the thread crashed.*/);
165
-
Atomics.store(HEAPU32,(threadInfoStruct+0/*{{{ C_STRUCTS.pthread.threadStatus }}}*/)>>2,1);// Mark the thread as no longer running.
166
-
_emscripten_futex_wake(threadInfoStruct+0/*{{{ C_STRUCTS.pthread.threadStatus }}}*/,0x7FFFFFFF/*INT_MAX*/);// Wake all threads waiting on this thread to finish.
167
-
if(!(einstanceofExitStatus))throwe;
198
+
Atomics.store(HEAPU32,(threadInfoStruct+4/*C_STRUCTS.pthread.threadExitCode*/)>>2,(einstanceofModule.ExitStatus) ? e.status : -2/*A custom entry specific to Emscripten denoting that the thread crashed.*/);
199
+
Atomics.store(HEAPU32,(threadInfoStruct+0/*C_STRUCTS.pthread.threadStatus*/)>>2,1);// Mark the thread as no longer running.
200
+
Module._emscripten_futex_wake(threadInfoStruct+0/*C_STRUCTS.pthread.threadStatus*/,0x7FFFFFFF/*INT_MAX*/);// Wake all threads waiting on this thread to finish.
201
+
if(!(einstanceofModule.ExitStatus))throwe;
168
202
}
169
203
}
170
204
// The thread might have finished without calling pthread_exit(). If so, then perform the exit operation ourselves.
0 commit comments