From 76c55fb93de2861d19fb7c7664c325554d43ff9c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 21 Nov 2010 23:03:08 -0800 Subject: [PATCH] optimize SAFE_HEAP for speed and enable additional tests --- src/preamble.js | 13 +++++++------ tests/runner.py | 4 ---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/preamble.js b/src/preamble.js index 16b55d53f..3993bd969 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -25,19 +25,20 @@ function SAFE_HEAP_ACCESS(dest, type, store) { // Note that this will pass even with unions: You can store X, load X, then store Y and load Y. // You cannot, however, do the nonportable act of store X and load Y! if (store) { - HEAP_HISTORY[dest] = [{ type: type, /*stack: new Error().stack */ }]; // |stack| is useful for debugging + HEAP_HISTORY[dest] = type; // [{ type: type, stack: new Error().stack }]; // |stack| is useful for debugging. Also uncomment the lines later down } else { if (!HEAP[dest] && HEAP[dest] !== 0 && HEAP[dest] !== false) { // false can be the result of a mathop comparator throw('Warning: Reading an invalid value at ' + dest + ' :: ' + new Error().stack + '\n'); } var history = HEAP_HISTORY[dest]; - 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 && history[0].type !== type) { + if (history === null) return; + assert(history); +// 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) { print('Load-store consistency assumption failure! ' + dest); print('\n'); - print(history.map(function(item) { - return item.type + ' :: ' + JSON.stringify(item.stack); - }).join('\n\n')); + print(JSON.stringify(history)); print('\n'); print('LOAD: ' + type + ', ' + new Error().stack); print('\n'); diff --git a/tests/runner.py b/tests/runner.py index c01f1ceb4..24f620f7f 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -1016,16 +1016,12 @@ if 'benchmark' not in sys.argv: ### 'Big' tests def test_fannkuch(self): - global SAFE_HEAP; SAFE_HEAP = 0 # Too slow for that - results = [ (1,0), (2,1), (3,2), (4,4), (5,7), (6,10), (7, 16), (8,22) ] for i, j in results: src = open(path_from_root(['tests', 'fannkuch.cpp']), 'r').read() self.do_test(src, 'Pfannkuchen(%d) = %d.' % (i,j), [str(i)], no_build=i>1) def test_raytrace(self): - global SAFE_HEAP; SAFE_HEAP = 0 # Too slow for that - src = open(path_from_root(['tests', 'raytrace.cpp']), 'r').read() output = open(path_from_root(['tests', 'raytrace.ppm']), 'r').read() self.do_test(src, output, ['3', '16'])