blob: 2c236b4313b6139666f660b182df53118aacbdeb [file] [log] [blame] [edit]
// Three configurations we can be running in:
// 1) We could be the application main() thread running in the main JS UI thread. (ENVIRONMENT_IS_WORKER == false and ENVIRONMENT_IS_PTHREAD == false)
// 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)
// 3) We could be an application pthread running in a worker. (ENVIRONMENT_IS_WORKER == true and ENVIRONMENT_IS_PTHREAD == true)
// ENVIRONMENT_IS_PTHREAD=true will have been preset in worker.js. Make it false in the main runtime thread.
var ENVIRONMENT_IS_PTHREAD = Module['ENVIRONMENT_IS_PTHREAD'] || false;
if (ENVIRONMENT_IS_PTHREAD) {
// Grab imports from the pthread to local scope.
buffer = Module['buffer'];
DYNAMIC_BASE = Module['DYNAMIC_BASE'];
DYNAMICTOP_PTR = Module['DYNAMICTOP_PTR'];
// 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.
// These will be filled in at pthread startup time (the 'run' message for a pthread - pthread start establishes the stack frame)
}