Merge pull request #803 from cxd4/speed-plz

re-ordered CPU interpreter main loop if/else branch predictor
This commit is contained in:
zilmar 2015-12-04 12:41:39 +11:00
commit 8b8c7fa2bb
1 changed files with 50 additions and 51 deletions

View File

@ -276,67 +276,66 @@ void CInterpreterCPU::ExecuteCPU()
{ {
while (!Done) while (!Done)
{ {
if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) if (!g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex))
{ {
/*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP, PROGRAM_COUNTER);
{ R4300iOp::m_NextInstruction = NORMAL;
WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); continue;
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]); }
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/
m_R4300i_Opcode[Opcode.op]();
NextTimer -= CountPerOp;
switch (R4300iOp::m_NextInstruction) /* if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER < 0x80380000)
{ {
case NORMAL: WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER));
PROGRAM_COUNTER += 4; // WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]);
break; // WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
case DELAY_SLOT: } */
R4300iOp::m_NextInstruction = JUMP; m_R4300i_Opcode[Opcode.op]();
PROGRAM_COUNTER += 4; NextTimer -= CountPerOp;
break;
case PERMLOOP_DO_DELAY: switch (R4300iOp::m_NextInstruction)
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE; {
PROGRAM_COUNTER += 4; case NORMAL:
break; PROGRAM_COUNTER += 4;
case JUMP:
{
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{
TestTimer = false;
if (NextTimer < 0)
{
g_SystemTimer->TimerDone();
}
if (bDoSomething)
{
g_SystemEvents->ExecuteEvents();
}
}
}
break; break;
case PERMLOOP_DELAY_DONE: case DELAY_SLOT:
PROGRAM_COUNTER = JumpToLocation; R4300iOp::m_NextInstruction = JUMP;
R4300iOp::m_NextInstruction = NORMAL; PROGRAM_COUNTER += 4;
CInterpreterCPU::InPermLoop(); break;
g_SystemTimer->TimerDone(); case PERMLOOP_DO_DELAY:
R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE;
PROGRAM_COUNTER += 4;
break;
case JUMP:
{
bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer);
PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL;
if (CheckTimer)
{
TestTimer = false;
if (NextTimer < 0)
{
g_SystemTimer->TimerDone();
}
if (bDoSomething) if (bDoSomething)
{ {
g_SystemEvents->ExecuteEvents(); g_SystemEvents->ExecuteEvents();
} }
break;
default:
g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
} }
else break;
{ case PERMLOOP_DELAY_DONE:
g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP, PROGRAM_COUNTER); PROGRAM_COUNTER = JumpToLocation;
R4300iOp::m_NextInstruction = NORMAL; R4300iOp::m_NextInstruction = NORMAL;
CInterpreterCPU::InPermLoop();
g_SystemTimer->TimerDone();
if (bDoSomething)
{
g_SystemEvents->ExecuteEvents();
}
break;
default:
g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
} }
} }