aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc2
-rw-r--r--src/postamble.js21
-rw-r--r--src/preamble.js23
3 files changed, 23 insertions, 23 deletions
diff --git a/emcc b/emcc
index 641e1d6a..9a687bd8 100755
--- a/emcc
+++ b/emcc
@@ -1620,7 +1620,7 @@ try:
temp_memfile = os.path.join(shared.EMSCRIPTEN_TEMP_DIR, os.path.basename(memfile))
if os.path.abspath(memfile) != os.path.abspath(memfile):
shutil.copyfile(memfile, temp_memfile)
- return 'loadMemoryInitializer("%s");' % os.path.basename(memfile)
+ return 'var memoryInitializer = "%s";' % os.path.basename(memfile)
src = re.sub(shared.JS.memory_initializer_pattern, repl, open(final).read(), count=1)
open(final + '.mem.js', 'w').write(src)
final += '.mem.js'
diff --git a/src/postamble.js b/src/postamble.js
index 88986dea..8f585b86 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -1,6 +1,27 @@
// === Auto-generated postamble setup entry stuff ===
+if (memoryInitializer) {
+ function applyData(data) {
+#if USE_TYPED_ARRAYS == 2
+ HEAPU8.set(data, STATIC_BASE);
+#else
+ allocate(data, 'i8', ALLOC_NONE, STATIC_BASE);
+#endif
+ }
+ if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
+ applyData(Module['readBinary'](memoryInitializer));
+ } else {
+ addRunDependency('memory initializer');
+ Browser.asyncLoad(memoryInitializer, function(data) {
+ applyData(data);
+ removeRunDependency('memory initializer');
+ }, function(data) {
+ throw 'could not load memory initializer ' + memoryInitializer;
+ });
+ }
+}
+
function ExitStatus(status) {
this.name = "ExitStatus";
this.message = "Program terminated with exit(" + status + ")";
diff --git a/src/preamble.js b/src/preamble.js
index 579e3065..02935f8f 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -1020,28 +1020,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 ===