diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-04-19 14:56:56 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-04-29 13:32:49 +0300 |
commit | 1640a6a67ecbe2a4d9c0c520878e7b1d90ddf137 (patch) | |
tree | 6aa7d8a4343443ac17528c54b29be40c27ab58d1 /src | |
parent | a7dfddc6abee48cc9484fe8f08f45d053f08dae2 (diff) |
Improve SAFE_HEAP assertion messages to be more informative out of the box.
Diffstat (limited to 'src')
-rw-r--r-- | src/preamble.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/preamble.js b/src/preamble.js index 5dd8ada1..2aec94c6 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -186,17 +186,17 @@ function SAFE_HEAP_STORE(dest, value, bytes, isFloat) { #if SAFE_HEAP_LOG Module.print('SAFE_HEAP store: ' + [dest, value, bytes, isFloat]); #endif - assert(dest > 0, 'segmentation fault'); - assert(dest % bytes === 0, 'alignment error'); - assert(dest < Math.max(DYNAMICTOP, STATICTOP), 'segmentation fault (high)'); + if (dest <= 0) abort('segmentation fault storing ' + bytes + ' bytes to address ' + dest); + if (dest % bytes !== 0) abort('alignment error storing to address ' + dest + ', which was expected to be aligned to a multiple of ' + bytes); + if (dest + bytes > Math.max(DYNAMICTOP, STATICTOP)) abort('segmentation fault, exceeded the top of the available heap when storing ' + bytes + ' bytes to address ' + dest + '. STATICTOP=' + STATICTOP + ', DYNAMICTOP=' + DYNAMICTOP); assert(DYNAMICTOP <= TOTAL_MEMORY); setValue(dest, value, getSafeHeapType(bytes, isFloat), 1); } function SAFE_HEAP_LOAD(dest, bytes, isFloat, unsigned) { - assert(dest > 0, 'segmentation fault'); - assert(dest % bytes === 0, 'alignment error'); - assert(dest < Math.max(DYNAMICTOP, STATICTOP), 'segmentation fault (high)'); + if (dest <= 0) abort('segmentation fault loading ' + bytes + ' bytes from address ' + dest); + if (dest % bytes !== 0) abort('alignment error loading from address ' + dest + ', which was expected to be aligned to a multiple of ' + bytes); + if (dest + bytes > Math.max(DYNAMICTOP, STATICTOP)) abort('segmentation fault, exceeded the top of the available heap when loading ' + bytes + ' bytes from address ' + dest + '. STATICTOP=' + STATICTOP + ', DYNAMICTOP=' + DYNAMICTOP); assert(DYNAMICTOP <= TOTAL_MEMORY); var type = getSafeHeapType(bytes, isFloat); var ret = getValue(dest, type, 1); |