diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-12-05 12:49:32 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-12-05 12:49:32 -0800 |
commit | ae4e12ba45e1cedfdbeb1894bb8d5a4f97647a4d (patch) | |
tree | 20a07bb7c3d0ca918e785be751e90b503da4e398 /src | |
parent | b65e0996fdb8aefd873c26fe18edd861e6a95f92 (diff) |
safe heap tweaks
Diffstat (limited to 'src')
-rw-r--r-- | src/preamble.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/preamble.js b/src/preamble.js index c816fd57..7ae7e0ad 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -21,6 +21,8 @@ var HEAP_HISTORY = {}; function SAFE_HEAP_CLEAR(dest) { HEAP_HISTORY[dest] = []; } +var SAFE_HEAP_ERRORS = 0; +var ACCEPTABLE_SAFE_HEAP_ERRORS = 0; function SAFE_HEAP_ACCESS(dest, type, store) { if (type && type[type.length-1] == '*') type = 'i32'; // pointers are ints, for our purposes here // Note that this will pass even with unions: You can store X, load X, then store Y and load Y. @@ -33,7 +35,7 @@ function SAFE_HEAP_ACCESS(dest, type, store) { } var history = HEAP_HISTORY[dest]; if (history === null) return; - assert(history); + assert(history, 'Must have a history for a safe heap load!'); // assert((history && history[0]) /* || HEAP[dest] === 0 */, "Loading from where there was no store! " + dest + ',' + HEAP[dest] + ',' + type + ', \n\n' + new Error().stack + '\n'); // if (history[0].type !== type) { if (history !== type) { @@ -43,7 +45,8 @@ function SAFE_HEAP_ACCESS(dest, type, store) { print('\n'); print('LOAD: ' + type + ', ' + new Error().stack); print('\n'); - assert(0, 'Load-store consistency assumption failure!'); + SAFE_HEAP_ERRORS++; + assert(SAFE_HEAP_ERRORS <= ACCEPTABLE_SAFE_HEAP_ERRORS, 'Load-store consistency assumption failure!'); } } } |