Speed up uncompiled code by "IFDEF'ing" disabled code, rare asserts, etc.

This commit is contained in:
Jeff Parsons 2015-07-18 14:21:09 -07:00
commit ad9585b346
13 changed files with 796 additions and 777 deletions

View file

@ -1536,7 +1536,7 @@ ChipSet.prototype.updateRTCTime = function()
* Step 3: Update the RTC date/time and deal with Update Interrupts
*/
var nCyclesDelta = nCyclesUpdate - this.nRTCCyclesLastUpdate;
this.assert(nCyclesDelta >= 0);
// DEBUG: this.assert(nCyclesDelta >= 0);
var nSecondsDelta = Math.floor(nCyclesDelta / nCyclesPerSecond);
/*
@ -1546,7 +1546,7 @@ ChipSet.prototype.updateRTCTime = function()
* (nCyclesDelta % nCyclesPerSecond) back into nRTCCyclesLastUpdate, so that we will eventually
* see a one-second delta.
*/
this.assert(nSecondsDelta <= 1);
// DEBUG: this.assert(nSecondsDelta <= 1);
/*
* Make sure that CMOS.STATUSB.SET isn't set; if it is, then the once-per-second RTC updates must be
@ -3673,11 +3673,11 @@ ChipSet.prototype.getTimerCycleLimit = function(iTimer, nCycles)
if (timer.fCounting) {
var nCyclesUpdate = this.cpu.getCycles(this.fScaleTimers);
var ticksElapsed = ((nCyclesUpdate - timer.nCyclesStart) / this.nTicksDivisor) | 0;
this.assert(ticksElapsed >= 0);
// DEBUG: this.assert(ticksElapsed >= 0);
var countStart = this.getTimerStart(iTimer);
var count = countStart - ticksElapsed;
if (timer.mode == ChipSet.PIT_CTRL.MODE3) count -= ticksElapsed;
this.assert(count > 0);
// DEBUG: this.assert(count > 0);
var nCyclesRemain = (count * this.nTicksDivisor) | 0;
if (timer.mode == ChipSet.PIT_CTRL.MODE3) nCyclesRemain >>= 1;
if (nCycles > nCyclesRemain) nCycles = nCyclesRemain;

View file

@ -90,7 +90,7 @@ var TYPEDARRAYS = (typeof ArrayBuffer !== 'undefined');
* we'll have to rethink that choice OR provide a Debugger command that dynamically enables/disables as much of
* the backtracking support as possible.
*/
var BACKTRACK = !COMPILED;
var BACKTRACK = false; // !COMPILED;
/**
* @define {boolean}

View file

@ -364,7 +364,8 @@ Memory.prototype = {
* memory blocks installed at the programmed address, and so we arrived here at a block with
* no controller AND no data.
*/
Component.assert(adw != null);
// DEBUG: Component.assert(adw != null);
if (adw && this.size == adw.length << 2) {
var i;
if (FATARRAYS) {
@ -635,7 +636,7 @@ Memory.prototype = {
* @param {number} addr
*/
writeShortDefault: function writeShortDefault(off, w, addr) {
Component.assert(!(w & ~0xffff));
// DEBUG: Component.assert(!(w & ~0xffff));
this.writeByte(off, w & 0xff, addr);
this.writeByte(off + 1, w >> 8, addr);
},
@ -662,7 +663,7 @@ Memory.prototype = {
* @return {number}
*/
readByteMemory: function readByteMemory(off, addr) {
Component.assert(off >= 0 && off < this.size);
// DEBUG: Component.assert(off >= 0 && off < this.size);
if (FATARRAYS) {
return this.ab[off];
}
@ -677,7 +678,7 @@ Memory.prototype = {
* @return {number}
*/
readShortMemory: function readShortMemory(off, addr) {
Component.assert(off >= 0 && off < this.size - 1);
// DEBUG: Component.assert(off >= 0 && off < this.size - 1);
if (FATARRAYS) {
return this.ab[off] | (this.ab[off + 1] << 8);
}
@ -701,7 +702,7 @@ Memory.prototype = {
* @return {number}
*/
readLongMemory: function readLongMemory(off, addr) {
Component.assert(off >= 0 && off < this.size - 3);
// DEBUG: Component.assert(off >= 0 && off < this.size - 3);
if (FATARRAYS) {
return this.ab[off] | (this.ab[off + 1] << 8) | (this.ab[off + 2] << 16) | (this.ab[off + 3] << 24);
}
@ -723,7 +724,7 @@ Memory.prototype = {
* @param {number} addr
*/
writeByteMemory: function writeByteMemory(off, b, addr) {
Component.assert(off >= 0 && off < this.size && (b & 0xff) == b);
// DEBUG: Component.assert(off >= 0 && off < this.size && (b & 0xff) == b);
if (FATARRAYS) {
this.ab[off] = b;
} else {
@ -742,7 +743,7 @@ Memory.prototype = {
* @param {number} addr
*/
writeShortMemory: function writeShortMemory(off, w, addr) {
Component.assert(off >= 0 && off < this.size - 1 && (w & 0xffff) == w);
// DEBUG: Component.assert(off >= 0 && off < this.size - 1 && (w & 0xffff) == w);
if (FATARRAYS) {
this.ab[off] = (w & 0xff);
this.ab[off + 1] = (w >> 8);
@ -768,7 +769,7 @@ Memory.prototype = {
* @param {number} addr
*/
writeLongMemory: function writeLongMemory(off, l, addr) {
Component.assert(off >= 0 && off < this.size - 3);
// DEBUG: Component.assert(off >= 0 && off < this.size - 3);
if (FATARRAYS) {
this.ab[off] = (l & 0xff);
this.ab[off + 1] = (l >> 8) & 0xff;
@ -1029,7 +1030,7 @@ Memory.prototype = {
* @return {number}
*/
readByteBigEndian: function readByteBigEndian(off, addr) {
Component.assert(off >= 0 && off < this.size);
// DEBUG: Component.assert(off >= 0 && off < this.size);
return this.ab[off];
},
/**
@ -1041,7 +1042,7 @@ Memory.prototype = {
* @return {number}
*/
readByteLittleEndian: function readByteLittleEndian(off, addr) {
Component.assert(off >= 0 && off < this.size);
// DEBUG: Component.assert(off >= 0 && off < this.size);
return this.ab[off];
},
/**
@ -1053,7 +1054,7 @@ Memory.prototype = {
* @return {number}
*/
readShortBigEndian: function readShortBigEndian(off, addr) {
Component.assert(off >= 0 && off < this.size - 1);
// DEBUG: Component.assert(off >= 0 && off < this.size - 1);
return this.dv.getUint16(off, true);
},
/**
@ -1065,7 +1066,7 @@ Memory.prototype = {
* @return {number}
*/
readShortLittleEndian: function readShortLittleEndian(off, addr) {
Component.assert(off >= 0 && off < this.size - 1);
// DEBUG: Component.assert(off >= 0 && off < this.size - 1);
/*
* TODO: It remains to be seen if there's any advantage to checking the offset
* for an aligned read vs. always reading the bytes separately; it seems a safe bet
@ -1082,7 +1083,7 @@ Memory.prototype = {
* @return {number}
*/
readLongBigEndian: function readLongBigEndian(off, addr) {
Component.assert(off >= 0 && off < this.size - 3);
// DEBUG: Component.assert(off >= 0 && off < this.size - 3);
return this.dv.getInt32(off, true);
},
/**
@ -1094,7 +1095,7 @@ Memory.prototype = {
* @return {number}
*/
readLongLittleEndian: function readLongLittleEndian(off, addr) {
Component.assert(off >= 0 && off < this.size - 3);
// DEBUG: Component.assert(off >= 0 && off < this.size - 3);
/*
* TODO: It remains to be seen if there's any advantage to checking the offset
* for an aligned read vs. always reading the bytes separately; it seems a safe bet
@ -1111,7 +1112,7 @@ Memory.prototype = {
* @param {number} addr
*/
writeByteBigEndian: function writeByteBigEndian(off, b, addr) {
Component.assert(off >= 0 && off < this.size);
// DEBUG: Component.assert(off >= 0 && off < this.size);
this.ab[off] = b;
this.fDirty = true;
},
@ -1124,7 +1125,7 @@ Memory.prototype = {
* @param {number} b
*/
writeByteLittleEndian: function writeByteLittleEndian(off, b, addr) {
Component.assert(off >= 0 && off < this.size);
// DEBUG: Component.assert(off >= 0 && off < this.size);
this.ab[off] = b;
this.fDirty = true;
},
@ -1137,7 +1138,7 @@ Memory.prototype = {
* @param {number} w
*/
writeShortBigEndian: function writeShortBigEndian(off, w, addr) {
Component.assert(off >= 0 && off < this.size - 1);
// DEBUG: Component.assert(off >= 0 && off < this.size - 1);
this.dv.setUint16(off, w, true);
this.fDirty = true;
},
@ -1150,7 +1151,7 @@ Memory.prototype = {
* @param {number} w
*/
writeShortLittleEndian: function writeShortLittleEndian(off, w, addr) {
Component.assert(off >= 0 && off < this.size - 1);
// DEBUG: Component.assert(off >= 0 && off < this.size - 1);
/*
* TODO: It remains to be seen if there's any advantage to checking the offset
* for an aligned write vs. always writing the bytes separately; it seems a safe bet
@ -1173,7 +1174,7 @@ Memory.prototype = {
* @param {number} addr
*/
writeLongBigEndian: function writeLongBigEndian(off, l, addr) {
Component.assert(off >= 0 && off < this.size - 3);
// DEBUG: Component.assert(off >= 0 && off < this.size - 3);
this.dv.setInt32(off, l, true);
this.fDirty = true;
},
@ -1186,7 +1187,7 @@ Memory.prototype = {
* @param {number} addr
*/
writeLongLittleEndian: function writeLongLittleEndian(off, l, addr) {
Component.assert(off >= 0 && off < this.size - 3);
// DEBUG: Component.assert(off >= 0 && off < this.size - 3);
/*
* TODO: It remains to be seen if there's any advantage to checking the offset
* for an aligned write vs. always writing the bytes separately; it seems a safe bet
@ -1238,7 +1239,7 @@ Memory.prototype = {
* @return {number}
*/
readBackTrackIndex: function readBackTrackIndex(off) {
Component.assert(off >= 0 && off < this.size);
// DEBUG: Component.assert(off >= 0 && off < this.size);
return this.abtIndexes[off];
},
/**
@ -1251,7 +1252,7 @@ Memory.prototype = {
*/
writeBackTrackIndex: function writeBackTrackIndex(off, bti) {
var btiPrev;
Component.assert(off >= 0 && off < this.size);
// DEBUG: Component.assert(off >= 0 && off < this.size);
btiPrev = this.abtIndexes[off];
this.abtIndexes[off] = bti;
return btiPrev;

View file

@ -2064,7 +2064,8 @@ X86CPU.prototype.setCSBase = function(addr)
*/
X86CPU.prototype.advanceIP = function(inc)
{
this.assert(inc > 0);
// DEBUG: this.assert(inc > 0);
this.regLIP = (this.regLIP + inc)|0;
/*
* Properly comparing regLIP to regLIPLimit would normally require coercing both to unsigned
@ -2109,7 +2110,8 @@ X86CPU.prototype.advanceIP = function(inc)
*/
X86CPU.prototype.rewindIP = function(dec)
{
this.assert(dec < 0);
// DEBUG: this.assert(dec < 0);
this.regLIP = (this.regLIP + dec)|0;
/*
* Since rewindIP() is used only for discrete "intra-instruction" IP adjustments, there should be no need
@ -3683,7 +3685,8 @@ X86CPU.prototype.pushWord = function(w)
*/
X86CPU.prototype.checkINTR = function()
{
this.assert(this.intFlags);
// DEBUG: this.assert(this.intFlags);
if (!(this.opFlags & X86.OPFLAG.NOINTR)) {
/*
* As discussed above, the 8086/8088 give hardware interrupts higher priority than the TRAP interrupt,
@ -4003,6 +4006,9 @@ X86CPU.prototype.stepCPU = function(nMinCycles)
nDebugState = 1;
}
/*
* SAMPLER:
*
if (SAMPLER) {
if (++this.iSampleFreq >= this.nSampleFreq) {
this.iSampleFreq = 0;
@ -4029,16 +4035,24 @@ X86CPU.prototype.stepCPU = function(nMinCycles)
}
}
}
*/
this.opFlags = 0;
/*
* DEBUG || PREFETCH:
*
if (DEBUG || PREFETCH) {
this.nBusCycles = 0;
this.nSnapCycles = this.nStepCycles;
}
*/
this.aOps[this.getIPByte()].call(this);
/*
* DEBUG || PREFETCH:
*
if (PREFETCH) {
var nSpareCycles = (this.nSnapCycles - this.nStepCycles) - this.nBusCycles;
if (nSpareCycles >= 4) {
@ -4047,9 +4061,9 @@ X86CPU.prototype.stepCPU = function(nMinCycles)
}
if (DEBUG) {
/*
* Make sure that every instruction is assessing a cycle cost, and that the cost is a net positive.
*/
//
// Make sure that every instruction is assessing a cycle cost, and that the cost is a net positive.
//
if (this.aFlags.fComplete && this.nStepCycles >= this.nSnapCycles && !(this.opFlags & X86.OPFLAG_PREFIXES)) {
this.println("cycle miscount: " + (this.nSnapCycles - this.nStepCycles));
this.setIP(this.opLIP - this.segCS.base);
@ -4057,6 +4071,7 @@ X86CPU.prototype.stepCPU = function(nMinCycles)
break;
}
}
*/
} while (this.nStepCycles > 0);

View file

@ -3723,8 +3723,11 @@ X86.fnFaultMessage = function(nFault, nError, fHalt)
/*
* However, the foregoing notwithstanding, if MESSAGE.HALT is enabled along with all the other required
* MESSAGE bits, then we want to halt regardless.
*
* TODO: Eventually remove the code below that halts on all MODEL_80386 GP_FAULTs; this is just to make it
* easier to catch bad faults on DeskPro 386 configurations.
*/
if (DEBUG && nFault == X86.EXCEPTION.GP_FAULT || this.messageEnabled(bitsMessage | Messages.HALT)) {
if (DEBUGGER && this.model == X86.MODEL_80386 && nFault == X86.EXCEPTION.GP_FAULT || this.messageEnabled(bitsMessage | Messages.HALT)) {
fHalt = true;
}