aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js46
1 files changed, 20 insertions, 26 deletions
diff --git a/src/preamble.js b/src/preamble.js
index abcd1c67..acff665f 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -908,6 +908,17 @@ function writeArrayToMemory(array, buffer) {
}
Module['writeArrayToMemory'] = writeArrayToMemory;
+function writeAsciiToMemory(str, buffer, dontAddNull) {
+ for (var i = 0; i < str.length; i++) {
+#if ASSERTIONS
+ assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff);
+#endif
+ {{{ makeSetValue('buffer', 'i', 'str.charCodeAt(i)', 'i8') }}}
+ }
+ if (!dontAddNull) {{{ makeSetValue('buffer', 'str.length', 0, 'i8') }}}
+}
+Module['writeAsciiToMemory'] = writeAsciiToMemory;
+
{{{ unSign }}}
{{{ reSign }}}
@@ -942,8 +953,9 @@ Math.toFloat32 = Math['toFloat32'];
// the dependencies are met.
var runDependencies = 0;
var runDependencyTracking = {};
-var calledInit = false, calledRun = false;
var runDependencyWatcher = null;
+var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
+
function addRunDependency(id) {
runDependencies++;
if (Module['monitorRunDependencies']) {
@@ -990,9 +1002,12 @@ function removeRunDependency(id) {
if (runDependencyWatcher !== null) {
clearInterval(runDependencyWatcher);
runDependencyWatcher = null;
- }
- // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
- if (!calledRun && shouldRunNow) run();
+ }
+ if (dependenciesFulfilled) {
+ var callback = dependenciesFulfilled;
+ dependenciesFulfilled = null;
+ callback(); // can add another dependenciesFulfilled
+ }
}
}
Module['removeRunDependency'] = removeRunDependency;
@@ -1017,28 +1032,7 @@ __ATEXIT__.push({ func: function() { PGOMonitor.dump() } });
addOnPreRun(function() { addRunDependency('pgo') });
#endif
-function loadMemoryInitializer(filename) {
- function applyData(data) {
-#if USE_TYPED_ARRAYS == 2
- HEAPU8.set(data, STATIC_BASE);
-#else
- allocate(data, 'i8', ALLOC_NONE, STATIC_BASE);
-#endif
- }
-
- // always do this asynchronously, to keep shell and web as similar as possible
- addOnPreRun(function() {
- if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
- applyData(Module['readBinary'](filename));
- } else {
- Browser.asyncLoad(filename, function(data) {
- applyData(data);
- }, function(data) {
- throw 'could not load memory initializer ' + filename;
- });
- }
- });
-}
+var memoryInitializer = null;
// === Body ===