Simplified/improved the memory protection model, and optimized the EErec's block fetch slightly. Note: VM builds are still unstable, and most notably crash on almost all FMVs. Still hoping I can find a fix tho. :)

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@596 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
Jake.Stine 2009-01-16 01:18:24 +00:00 committed by Gregory Hainaut
parent 3bf7df410f
commit 42951f240c
5 changed files with 33 additions and 44 deletions

View File

@ -1036,10 +1036,8 @@ static void intExecuteBlock()
{ {
g_EEFreezeRegs = false; g_EEFreezeRegs = false;
PCSX2_MEM_PROTECT_BEGIN()
branch2 = 0; branch2 = 0;
while (!branch2) execI(); while (!branch2) execI();
PCSX2_MEM_PROTECT_END()
} }
void intStep() void intStep()

View File

@ -78,12 +78,6 @@ void cpuReset()
cpuIsInitialized = true; cpuIsInitialized = true;
} }
#ifdef PCSX2_VIRTUAL_MEM
// VM Builds require the exception handler during memInit/Reset operations and
// during the savestate load/save code.
PCSX2_MEM_PROTECT_BEGIN();
#endif
memReset(); memReset();
psxMemReset(); psxMemReset();
vuMicroMemReset(); vuMicroMemReset();
@ -115,9 +109,6 @@ void cpuReset()
rcntInit(); rcntInit();
psxReset(); psxReset();
#ifdef PCSX2_VIRTUAL_MEM
PCSX2_MEM_PROTECT_END();
#endif
} }
void cpuShutdown() void cpuShutdown()

View File

@ -389,9 +389,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
} }
void RunGui() { void RunGui()
{
MSG msg; MSG msg;
PCSX2_MEM_PROTECT_BEGIN();
while( true ) while( true )
{ {
if( PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0 ) if( PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0 )
@ -404,6 +407,8 @@ void RunGui() {
Sleep(10); Sleep(10);
} }
PCSX2_MEM_PROTECT_END();
} }
BOOL Open_File_Proc( std::string& outstr ) BOOL Open_File_Proc( std::string& outstr )

View File

@ -233,7 +233,6 @@ void ExecuteCpu()
timeBeginPeriod( 1 ); timeBeginPeriod( 1 );
PCSX2_MEM_PROTECT_BEGIN();
if( CHECK_EEREC ) if( CHECK_EEREC )
{ {
while( !g_ReturnToGui ) while( !g_ReturnToGui )
@ -250,7 +249,6 @@ void ExecuteCpu()
SysUpdate(); SysUpdate();
} }
} }
PCSX2_MEM_PROTECT_END();
timeEndPeriod( 1 ); timeEndPeriod( 1 );

View File

@ -90,7 +90,7 @@ static u32 s_nInstCacheSize = 0;
static BASEBLOCK* s_pCurBlock = NULL; static BASEBLOCK* s_pCurBlock = NULL;
static BASEBLOCKEX* s_pCurBlockEx = NULL; static BASEBLOCKEX* s_pCurBlockEx = NULL;
static BASEBLOCK* s_pDispatchBlock = NULL; static const BASEBLOCK* s_pDispatchBlock = NULL;
static u32 s_nEndBlock = 0; // what pc the current block ends static u32 s_nEndBlock = 0; // what pc the current block ends
static u32 s_nHasDelay = 0; static u32 s_nHasDelay = 0;
@ -725,32 +725,12 @@ static __declspec(naked,noreturn) void DispatcherReg()
{ {
s_pDispatchBlock = PC_GETBLOCK(cpuRegs.pc); s_pDispatchBlock = PC_GETBLOCK(cpuRegs.pc);
if( s_pDispatchBlock->startpc != cpuRegs.pc )
recRecompile(cpuRegs.pc);
__asm __asm
{ {
/*shr edx, 14
and edx, 0xfffffffc
add edx, recLUT
mov edx, dword ptr [edx]
mov eax, ecx
and eax, 0xfffc
// edx += 2*eax
shl eax, 1
add edx, eax*/
// check if startpc == cpuRegs.pc
mov eax, s_pDispatchBlock mov eax, s_pDispatchBlock
mov ecx, cpuRegs.pc
cmp ecx, dword ptr [eax+BLOCKTYPE_STARTPC]
je CheckPtrReg
// recompile
push cpuRegs.pc // pc
call recRecompile
add esp, 4 // pop old param
mov eax, s_pDispatchBlock
CheckPtrReg:
mov eax, dword ptr [eax] mov eax, dword ptr [eax]
} }
@ -767,11 +747,22 @@ CheckPtrReg:
__forceinline void recExecute() __forceinline void recExecute()
{ {
// Optimization note : Compared pushad against manually pushing the regs one-by-one.
// Manually pushing is faster, especially on Core2's and such. :)
do { do {
__asm { __asm {
pushad
push ebx
push esi
push edi
push ebp
call DispatcherReg call DispatcherReg
popad
pop ebp
pop edi
pop esi
pop ebx
} }
} }
while( !recEventTest() ); while( !recEventTest() );
@ -779,15 +770,21 @@ __forceinline void recExecute()
static void recExecuteBlock() static void recExecuteBlock()
{ {
PCSX2_MEM_PROTECT_BEGIN()
__asm __asm
{ {
pushad push ebx
push esi
push edi
push ebp
call DispatcherReg call DispatcherReg
popad
pop ebp
pop edi
pop esi
pop ebx
} }
recEventTest(); recEventTest();
PCSX2_MEM_PROTECT_END()
} }
#else // _MSC_VER #else // _MSC_VER