diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 26 | ||||
-rw-r--r-- | src/library_sdl.js | 1 | ||||
-rw-r--r-- | src/parseTools.js | 8 | ||||
-rw-r--r-- | src/preamble.js | 11 |
4 files changed, 30 insertions, 16 deletions
diff --git a/src/library.js b/src/library.js index bd9491af..ab560ad4 100644 --- a/src/library.js +++ b/src/library.js @@ -1281,10 +1281,15 @@ var Library = { // Converts a value we have as signed, into an unsigned value. For // example, -1 in int32 would be a very large number as unsigned. -function unSign(value, bits, ignore) { - if (value >= 0) return value; +function unSign(value, bits, ignore, sig) { + if (value >= 0) { #if CHECK_SIGNS - if (!ignore) CorrectionsMonitor.note('UnSign'); + if (!ignore) CorrectionsMonitor.note('UnSign', 1, sig); +#endif + return value; + } +#if CHECK_SIGNS + if (!ignore) CorrectionsMonitor.note('UnSign', 0, sig); #endif return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts : Math.pow(2, bits) + value; @@ -1293,8 +1298,13 @@ function unSign(value, bits, ignore) { // Converts a value we have as unsigned, into a signed value. For // example, 200 in a uint8 would be a negative number. -function reSign(value, bits, ignore) { - if (value <= 0) return value; +function reSign(value, bits, ignore, sig) { + if (value <= 0) { +#if CHECK_SIGNS + if (!ignore) CorrectionsMonitor.note('ReSign', 1, sig); +#endif + return value; + } var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32 : Math.pow(2, bits-1); #if CHECK_SIGNS @@ -1303,7 +1313,7 @@ function reSign(value, bits, ignore) { if (value >= half) { #if CHECK_SIGNS if (!ignore) { - CorrectionsMonitor.note('ReSign'); + CorrectionsMonitor.note('ReSign', 0, sig); noted = true; } #endif @@ -1315,11 +1325,11 @@ function reSign(value, bits, ignore) { // would indeed give the exact same result. if (bits === 32 && (value|0) !== value && typeof value !== 'boolean') { if (!ignore) { - CorrectionsMonitor.note('ReSign'); + CorrectionsMonitor.note('ReSign', 0, sig); noted = true; } } - if (!noted) CorrectionsMonitor.note('ReSign', true); + if (!noted) CorrectionsMonitor.note('ReSign', 1, sig); #endif return value; } diff --git a/src/library_sdl.js b/src/library_sdl.js index dbd509ed..909292ba 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -170,6 +170,7 @@ mergeInto(Library, { } surfData.ctx.putImageData(surfData.image, 0, 0); } + __shutdownRuntime__(); throw 'SDL_Quit!'; }, diff --git a/src/parseTools.js b/src/parseTools.js index 5dec458e..bd68888b 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -850,7 +850,9 @@ function handleOverflow(text, bits) { if (!bits) return text; var correct = correctOverflows(); warn(!correct || bits <= 32, 'Cannot correct overflows of this many bits: ' + bits); - if (CHECK_OVERFLOWS) return 'CHECK_OVERFLOW(' + text + ', ' + bits + ')'; + if (CHECK_OVERFLOWS) return 'CHECK_OVERFLOW(' + text + ', ' + bits + ', ' + Math.floor(correctSpecificOverflow() && !AUTO_OPTIMIZE) + ( + AUTO_OPTIMIZE ? ', "' + Debugging.getIdentifier(Framework.currItem.lineNum) + '"' : '' + ) + ')'; if (!correct) return text; if (bits <= 32) { return '(' + text + ')&' + (Math.pow(2, bits) - 1); @@ -897,7 +899,9 @@ function makeSignOp(value, type, op) { } } } - return op + 'Sign(' + value + ', ' + bits + ', ' + Math.floor(correctSpecificSign()) + ')'; // If we are correcting a specific sign here, do not check for it + return op + 'Sign(' + value + ', ' + bits + ', ' + Math.floor(correctSpecificSign() && !AUTO_OPTIMIZE) + ( + AUTO_OPTIMIZE ? ', "' + Debugging.getIdentifier(Framework.currItem.lineNum) + '"' : '' + ) + ')'; // If we are correcting a specific sign here, do not check for it } else { return value; } diff --git a/src/preamble.js b/src/preamble.js index cb4e8571..1a4fdff3 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -117,7 +117,6 @@ var CorrectionsMonitor = { if (this.corrections >= this.MAX_ALLOWED) abort('\n\nToo many corrections!'); } #if AUTO_OPTIMIZE - if (succeed) return; // XXX - enable this later on, as a profiling tool if (!sig) sig = (new Error().stack).toString().split('\n')[2].split(':').slice(-1)[0]; // Spidermonkey-specific FIXME sig = type + '|' + sig; @@ -157,18 +156,18 @@ function cRound(x) { //======================================== // Debugging tools - Mathop overflows //======================================== -function CHECK_OVERFLOW(value, bits, ignore) { +function CHECK_OVERFLOW(value, bits, ignore, sig) { if (ignore) return value; var twopbits = Math.pow(2, bits); var twopbits1 = Math.pow(2, bits-1); // For signedness issue here, see settings.js, CHECK_SIGNED_OVERFLOWS #if CHECK_SIGNED_OVERFLOWS if (value === Infinity || value === -Infinity || value >= twopbits1 || value < -twopbits1) { - CorrectionsMonitor.note('SignedOverflow'); + CorrectionsMonitor.note('SignedOverflow', 0, sig); if (value === Infinity || value === -Infinity || Math.abs(value) >= twopbits) CorrectionsMonitor.note('Overflow'); #else if (value === Infinity || value === -Infinity || Math.abs(value) >= twopbits) { - CorrectionsMonitor.note('Overflow'); + CorrectionsMonitor.note('Overflow', 0, sig); #endif #if CORRECT_OVERFLOWS // Fail on >32 bits - we warned at compile time @@ -178,9 +177,9 @@ function CHECK_OVERFLOW(value, bits, ignore) { #endif } else { #if CHECK_SIGNED_OVERFLOWS - CorrectionsMonitor.note('SignedOverflow', 1); + CorrectionsMonitor.note('SignedOverflow', 1, sig); #endif - CorrectionsMonitor.note('Overflow', 1); + CorrectionsMonitor.note('Overflow', 1, sig); } return value; } |