diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-09 20:17:50 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-09 20:17:50 -0700 |
commit | 064206f86c62c546b1860cb14e4f303b6056b5bc (patch) | |
tree | 1dd472cc0b4d9e2f7de78a8a9b393c5508fe3c52 | |
parent | 6d67e17176321f4c9c9bcf9aa9cd9d4db5c33aa5 (diff) |
remove ATMAIN hack, use a designated runPostSets function for postSets
-rw-r--r-- | src/jsifier.js | 9 | ||||
-rw-r--r-- | src/preamble.js | 5 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index eab4a88d..23fbb4c5 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1529,11 +1529,10 @@ function JSify(data, functionsOnly, givenFunctions) { } // Run postsets right before main, and after the memory initializer has been set up - if (itemsDict.GlobalVariablePostSet.length > 0) { - print('__ATMAIN__.push(function() {\n'); - print(itemsDict.GlobalVariablePostSet.map(function(item) { return item.JS }).join('\n')); - print('});\n'); - } + print('function runPostSets() {\n'); + print(itemsDict.GlobalVariablePostSet.map(function(item) { return item.JS }).join('\n')); + print('}\n'); + print('if (!awaitingMemoryInitializer) runPostSets();\n'); // if we load the memory initializer, this is done later } return; diff --git a/src/preamble.js b/src/preamble.js index 6961a0e9..592363f9 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -891,6 +891,8 @@ __ATEXIT__.push({ func: function() { PGOMonitor.dump() } }); addPreRun(function() { addRunDependency('pgo') }); #endif +var awaitingMemoryInitializer = false; + function loadMemoryInitializer(filename) { function applyData(data) { #if USE_TYPED_ARRAYS == 2 @@ -898,6 +900,7 @@ function loadMemoryInitializer(filename) { #else allocate(data, 'i8', ALLOC_NONE, TOTAL_STACK); #endif + runPostSets(); } // always do this asynchronously, to keep shell and web as similar as possible @@ -912,6 +915,8 @@ function loadMemoryInitializer(filename) { }); } }); + + awaitingMemoryInitializer = false; } // === Body === |