aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-05 10:37:32 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-05 10:37:32 -0700
commite4d888ce84ea774e95e4b1122e908fb2a6a2f64c (patch)
tree0e79479db0d880fa1c7da51d17cccb33bee268ef /src
parentd79e23b630c76f628b9f183106912d1f47b14d22 (diff)
initialize runtime from run() (asynchronously, if run is asynchronous)
Diffstat (limited to 'src')
-rw-r--r--src/postamble.js7
-rw-r--r--src/preamble.js2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/postamble.js b/src/postamble.js
index dd4f4f37..388d0127 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -51,6 +51,11 @@ Module.callMain = function callMain(args) {
function run(args) {
args = args || Module['arguments'];
+ if (!calledInit) {
+ initRuntime();
+ calledInit = true;
+ }
+
if (runDependencies > 0) {
Module.printErr('run() called, but dependencies remain, so not running');
return 0;
@@ -112,8 +117,6 @@ if (Module['preInit']) {
}
}
-initRuntime();
-
#if INVOKE_RUN
var shouldRunNow = true;
#else
diff --git a/src/preamble.js b/src/preamble.js
index 2cff440c..e7778b30 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -805,7 +805,7 @@ Math.imul = function(a, b) {
// the dependencies are met.
var runDependencies = 0;
var runDependencyTracking = {};
-var calledRun = false;
+var calledInit = false, calledRun = false;
var runDependencyWatcher = null;
function addRunDependency(id) {
runDependencies++;