aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc2
-rw-r--r--src/library_sdl.js5
-rw-r--r--src/postamble.js21
-rw-r--r--src/preamble.js23
-rw-r--r--src/relooper/emscripten/glue.js12
-rw-r--r--src/settings.js2
-rw-r--r--tools/shared.py2
7 files changed, 36 insertions, 31 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/library_sdl.js b/src/library_sdl.js
index 9383834f..116bf547 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -1009,7 +1009,10 @@ var LibrarySDL = {
},
SDL_Delay: function(delay) {
- abort('SDL_Delay called! Potential infinite loop, quitting.');
+ if (!ENVIRONMENT_IS_WORKER) abort('SDL_Delay called on the main thread! Potential infinite loop, quitting.');
+ // horrible busy-wait, but in a worker it at least does not block rendering
+ var now = Date.now();
+ while (Date.now() - now < delay) {}
},
SDL_WM_SetCaption: function(title, icon) {
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 ===
diff --git a/src/relooper/emscripten/glue.js b/src/relooper/emscripten/glue.js
index 40ddabec..92c50500 100644
--- a/src/relooper/emscripten/glue.js
+++ b/src/relooper/emscripten/glue.js
@@ -1,9 +1,9 @@
- var RBUFFER_SIZE = 20*1024*1024;
+ var RBUFFER_SIZE = RELOOPER_BUFFER_SIZE;
var rbuffer = _malloc(RBUFFER_SIZE);
_rl_set_output_buffer(rbuffer, RBUFFER_SIZE);
- var TBUFFER_SIZE = 10*1024*1024;
+ var TBUFFER_SIZE = RELOOPER_BUFFER_SIZE/2;
var tbuffer = _malloc(TBUFFER_SIZE);
var VBUFFER_SIZE = 256;
@@ -15,10 +15,10 @@
},
RelooperGlue['addBlock'] = function(text, branchVar) {
assert(this.r);
- assert(text.length+1 < TBUFFER_SIZE);
+ assert(text.length+1 < TBUFFER_SIZE, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
writeStringToMemory(text, tbuffer);
if (branchVar) {
- assert(branchVar.length+1 < VBUFFER_SIZE);
+ assert(branchVar.length+1 < VBUFFER_SIZE, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
writeStringToMemory(branchVar, vbuffer);
}
var b = _rl_new_block(tbuffer, branchVar ? vbuffer : 0);
@@ -28,14 +28,14 @@
RelooperGlue['addBranch'] = function(from, to, condition, code) {
assert(this.r);
if (condition) {
- assert(condition.length+1 < TBUFFER_SIZE/2);
+ assert(condition.length+1 < TBUFFER_SIZE/2, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
writeStringToMemory(condition, tbuffer);
condition = tbuffer;
} else {
condition = 0; // allow undefined, null, etc. as inputs
}
if (code) {
- assert(code.length+1 < TBUFFER_SIZE/2);
+ assert(code.length+1 < TBUFFER_SIZE/2, 'buffer too small, increase RELOOPER_BUFFER_SIZE');
writeStringToMemory(code, tbuffer + TBUFFER_SIZE/2);
code = tbuffer + TBUFFER_SIZE/2;
} else {
diff --git a/src/settings.js b/src/settings.js
index e00f4e59..15bca4db 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -70,6 +70,8 @@ var MAX_SETJMPS = 20; // size of setjmp table allocated in each function invocat
var MICRO_OPTS = 1; // Various micro-optimizations, like nativizing variables
var RELOOP = 0; // Recreate js native loops from llvm data
var RELOOPER = 'relooper.js'; // Loads the relooper from this path relative to compiler.js
+var RELOOPER_BUFFER_SIZE = 20*1024*1024; // The internal relooper buffer size. Increase if you see assertions
+ // on OutputBuffer.
var USE_TYPED_ARRAYS = 2; // Use typed arrays for the heap. See https://github.com/kripken/emscripten/wiki/Code-Generation-Modes/
// 0 means no typed arrays are used. This mode disallows LLVM optimizations
diff --git a/tools/shared.py b/tools/shared.py
index 853b064d..45551fec 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -304,7 +304,7 @@ def find_temp_directory():
# we re-check sanity when the settings are changed)
# We also re-check sanity and clear the cache when the version changes
-EMSCRIPTEN_VERSION = '1.5.7'
+EMSCRIPTEN_VERSION = '1.5.8'
def generate_sanity():
return EMSCRIPTEN_VERSION + '|' + get_llvm_target() + '|' + LLVM_ROOT