diff options
author | Vladimir Vukicevic <vladimirv@dugeo.com> | 2013-02-26 23:04:11 -0500 |
---|---|---|
committer | Vladimir Vukicevic <vladimirv@dugeo.com> | 2013-02-26 23:04:11 -0500 |
commit | 31186ef9edb06e9bc695fca2c3a14677e8f137a1 (patch) | |
tree | cba5aba62602283b6d6a9d3e23f126dd6feb1482 /src/preamble.js | |
parent | a28b5d53d75b428b1bee1efd39ac6d01d68d56d2 (diff) |
Add CHECK_HEAP_ALIGN to perform runtime alignment checks
Adds a much cheaper CHECK_HEAP_ALIGN option to do heap access
alignment checks. Less extensive than SAFE_HEAP, but also much
cheaper.
Diffstat (limited to 'src/preamble.js')
-rw-r--r-- | src/preamble.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/preamble.js b/src/preamble.js index 6f4b49de..71b123e7 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -150,6 +150,25 @@ function SAFE_HEAP_COPY_HISTORY(dest, src) { //========================================== #endif +#if CHECK_HEAP_ALIGN +//======================================== +// Debugging tools - alignment check +//======================================== +function CHECK_ALIGN_8(addr) { + assert((addr & 7) == 0, "address must be 8-byte aligned, is " + addr + "!"); + return addr; +} +function CHECK_ALIGN_4(addr) { + assert((addr & 3) == 0, "address must be 4-byte aligned, is " + addr + "!"); + return addr; +} +function CHECK_ALIGN_2(addr) { + assert((addr & 1) == 0, "address must be 2-byte aligned!"); + return addr; +} +#endif + + #if CHECK_OVERFLOWS //======================================== // Debugging tools - Mathop overflows |