aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-27 20:07:07 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-27 20:07:07 -0700
commited88bc7051a61e05c6e85e792d56513826722d2e (patch)
treed40113a39ebe21626cb193e1a5652f621052e942 /src/preamble.js
parentb1989519a9e66a8c2f5b2174a2eadb53bb8f9f56 (diff)
memory growth must be manually enabled with ALLOW_MEMORY_GROWTH, in which case the eliminator runs in safe mode
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/preamble.js b/src/preamble.js
index b197ef02..24277014 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -576,9 +576,12 @@ var STACK_ROOT, STACKTOP, STACK_MAX;
var STATICTOP;
#if USE_TYPED_ARRAYS
function enlargeMemory() {
+#if ALLOW_MEMORY_GROWTH == 0
+ abort('Cannot enlarge memory arrays. Adjust TOTAL_MEMORY or compile with ALLOW_MEMORY_GROWTH');
+#else
// TOTAL_MEMORY is the current size of the actual array, and STATICTOP is the new top.
#if ASSERTIONS
- Module.printErr('Warning: Enlarging memory arrays, this is not fast, and can also break in high optimization levels where we assume globals are not modified! ' + [STATICTOP, TOTAL_MEMORY]); // XXX perhaps never do elimination optimizations of calls that can lead to resizing, to avoid HEAP[malloc()] = X; where JS semantic will write to the old HEAP if malloc replaces it
+ Module.printErr('Warning: Enlarging memory arrays, this is not fast, and ALLOW_MEMORY_GROWTH is not fully tested with all optimizations on! ' + [STATICTOP, TOTAL_MEMORY]); // We perform safe elimination instead of elimination in this mode, but if you see this error, try to disable it and other optimizations entirely
assert(STATICTOP >= TOTAL_MEMORY);
assert(TOTAL_MEMORY > 4); // So the loop below will not be infinite
#endif
@@ -609,6 +612,7 @@ function enlargeMemory() {
HEAPF64 = new Float64Array(buffer);
HEAP8.set(oldHEAP8);
#endif
+#endif
}
#endif