aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-17 13:55:13 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-17 13:55:13 -0800
commitdf588104c7df7316a113fdf9930d3d16f7ce2567 (patch)
tree7b92b2deac6edc103c80bab27232fce302abb589
parent5a2bcaf0462768ac0ce03cf610e285c3b244cb7c (diff)
fix SAFE_HEAP check for TOTAL_MEMORY which is unneeded without typed arrays
-rw-r--r--src/preamble.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 8a0f6eb6..293ddcf6 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -24,8 +24,13 @@ var ACCEPTABLE_SAFE_HEAP_ERRORS = 0;
function SAFE_HEAP_ACCESS(dest, type, store, ignore) {
//if (dest === A_NUMBER) print ([dest, type, store] + ' ' + new Error().stack); // Something like this may be useful, in debugging
+#if USE_TYPED_ARRAYS
+ // When using typed arrays, reads over the top of TOTAL_MEMORY will fail silently, so we must
+ // correct that by growing TOTAL_MEMORY as needed. Without typed arrays, memory is a normal
+ // JS array so it will work (potentially slowly, depending on the engine).
assert(dest < STATICTOP);
assert(STATICTOP <= TOTAL_MEMORY);
+#endif
#if USE_TYPED_ARRAYS == 2
return; // It is legitimate to violate the load-store assumption in this case