aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-07 10:25:15 -0500
committerAlon Zakai <alonzakai@gmail.com>2014-02-07 10:25:15 -0500
commitcb877f31cd61716774d5d3f532bf6082bdcf4162 (patch)
treee9b5ae0651f4f02f1a559749c852e8731ff9cff3 /src/preamble.js
parentc95b10cff38fabf23a763d1889d024f6dabd4955 (diff)
improve safe heap tests in asm mode
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 9a65b092..25ef1fb3 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -188,6 +188,8 @@ function SAFE_HEAP_STORE(dest, value, bytes, isFloat) {
#endif
assert(dest > 0, 'segmentation fault');
assert(dest % bytes === 0);
+ assert(dest < Math.max(DYNAMICTOP, STATICTOP));
+ assert(DYNAMICTOP <= TOTAL_MEMORY);
setValue(dest, value, getSafeHeapType(bytes, isFloat), 1);
}
@@ -197,6 +199,8 @@ function SAFE_HEAP_LOAD(dest, bytes, isFloat, unsigned) {
#endif
assert(dest > 0, 'segmentation fault');
assert(dest % bytes === 0);
+ assert(dest < Math.max(DYNAMICTOP, STATICTOP));
+ assert(DYNAMICTOP <= TOTAL_MEMORY);
var type = getSafeHeapType(bytes, isFloat);
var ret = getValue(dest, type, 1);
if (unsigned) ret = unSign(ret, parseInt(type.substr(1)), 1);