mirror of https://github.com/PCSX2/pcsx2.git
newHostVM: improving error handling and memory management (WIP)
git-svn-id: http://pcsx2.googlecode.com/svn/branches/newHostVM@3979 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
a61e678a12
commit
b568256653
|
@ -189,6 +189,9 @@ struct R3000Acpu {
|
|||
s32 (*ExecuteBlock)( s32 eeCycles ); // executes the given number of EE cycles.
|
||||
void (*Clear)(u32 Addr, u32 Size);
|
||||
void (*Shutdown)();
|
||||
|
||||
uint (*GetCacheReserve)();
|
||||
void (*SetCacheReserve)( uint reserveInMegs );
|
||||
};
|
||||
|
||||
extern R3000Acpu *psxCpu;
|
||||
|
|
|
@ -376,6 +376,9 @@ struct R5900cpu
|
|||
// doesn't matter if we're stripping it out soon. ;)
|
||||
//
|
||||
void (*Clear)(u32 Addr, u32 Size);
|
||||
|
||||
uint (*GetCacheReserve)();
|
||||
void (*SetCacheReserve)( uint reserveInMegs );
|
||||
};
|
||||
|
||||
extern R5900cpu *Cpu;
|
||||
|
|
|
@ -1397,12 +1397,26 @@ StartRecomp:
|
|||
s_pCurBlockEx = NULL;
|
||||
}
|
||||
|
||||
static void recSetCacheReserve( uint reserveInMegs )
|
||||
{
|
||||
//m_ConfiguredCacheReserve = reserveInMegs * _1mb;
|
||||
}
|
||||
|
||||
static uint recGetCacheReserve()
|
||||
{
|
||||
return 0;
|
||||
//return m_ConfiguredCacheReserve / _1mb;
|
||||
}
|
||||
|
||||
R3000Acpu psxRec = {
|
||||
recReserve,
|
||||
recResetIOP,
|
||||
recExecute,
|
||||
recExecuteBlock,
|
||||
recClearIOP,
|
||||
recShutdown
|
||||
recShutdown,
|
||||
|
||||
recGetCacheReserve,
|
||||
recSetCacheReserve
|
||||
};
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ bool g_cpuFlushedPC, g_cpuFlushedCode, g_recompilingDelaySlot, g_maySignalExcept
|
|||
static const int RECCONSTBUF_SIZE = 16384 * 2; // 64 bit consts in 32 bit units
|
||||
|
||||
static RecompiledCodeReserve* recMem = NULL;
|
||||
static uptr m_ConfiguredCacheReserve = _64mb;
|
||||
|
||||
static u32* recConstBuf = NULL; // 64-bit pseudo-immediates
|
||||
static BASEBLOCK *recRAM = NULL; // and the ptr to the blocks here
|
||||
|
@ -548,6 +549,42 @@ static void recThrowHardwareDeficiency( const wxChar* extFail )
|
|||
.SetUserMsg(pxsFmt(_("%s Extensions not found. The R5900-32 recompiler requires a host CPU with MMX, SSE, and SSE2 extensions."), extFail ));
|
||||
}
|
||||
|
||||
// This error message is shared by R5900, R3000, and microVU recompilers. It is not used by the
|
||||
// SuperVU recompiler, since it has its own customized message.
|
||||
wxString GetMsg_RecVmFailed( const char* recName )
|
||||
{
|
||||
return pxE( ".Error:Recompiler:VirtualMemoryAlloc",
|
||||
pxsFmt(
|
||||
"The %s recompiler was unable to reserve contiguous memory required "
|
||||
"for internal caches. This problem may be fixable by reducing the default "
|
||||
"cache sizes for all PCSX2 recompilers, found under Host Settings.",
|
||||
recName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static void recReserveCache()
|
||||
{
|
||||
if (!recMem) recMem = new RecompiledCodeReserve(L"R5900-32 Recompiler Cache", _1mb * 4);
|
||||
|
||||
recMem->Reserve( m_ConfiguredCacheReserve, HostMemoryMap::EErec );
|
||||
|
||||
while (!recMem->IsOk() && (m_ConfiguredCacheReserve >= 16))
|
||||
{
|
||||
m_ConfiguredCacheReserve /= 2;
|
||||
recMem->Reserve( m_ConfiguredCacheReserve * _1mb, HostMemoryMap::EErec );
|
||||
}
|
||||
|
||||
if (!recMem->IsOk())
|
||||
{
|
||||
throw Exception::VirtualMemoryMapConflict()
|
||||
.SetDiagMsg(pxsFmt( L"R5900-32 recompiled code cache could not be mapped." ))
|
||||
.SetUserMsg(GetMsg_RecVmFailed("R5900-32"));
|
||||
}
|
||||
|
||||
ProfilerRegisterSource( "EE Rec", *recMem, recMem->GetReserveSizeInBytes() );
|
||||
}
|
||||
|
||||
static void recReserve()
|
||||
{
|
||||
// Hardware Requirements Check...
|
||||
|
@ -561,8 +598,7 @@ static void recReserve()
|
|||
if ( !x86caps.hasStreamingSIMD2Extensions )
|
||||
recThrowHardwareDeficiency( L"SSE2" );
|
||||
|
||||
recMem = new RecompiledCodeReserve(L"R5900-32 Recompiler Cache", _1mb * 4);
|
||||
recMem->Reserve( _64mb, HostMemoryMap::EErec );
|
||||
recReserveCache();
|
||||
}
|
||||
|
||||
static void recAlloc()
|
||||
|
@ -595,7 +631,6 @@ static void recAlloc()
|
|||
|
||||
// No errors.. Proceed with initialization:
|
||||
|
||||
ProfilerRegisterSource( "EE Rec", *recMem, recMem->GetReserveSizeInBytes() );
|
||||
_DynGen_Dispatchers();
|
||||
|
||||
x86FpuState = FPU_STATE;
|
||||
|
@ -1885,6 +1920,16 @@ static void recThrowException( const BaseException& ex )
|
|||
#endif
|
||||
}
|
||||
|
||||
static void recSetCacheReserve( uint reserveInMegs )
|
||||
{
|
||||
m_ConfiguredCacheReserve = reserveInMegs * _1mb;
|
||||
}
|
||||
|
||||
static uint recGetCacheReserve()
|
||||
{
|
||||
return m_ConfiguredCacheReserve / _1mb;
|
||||
}
|
||||
|
||||
R5900cpu recCpu =
|
||||
{
|
||||
recReserve,
|
||||
|
@ -1898,4 +1943,7 @@ R5900cpu recCpu =
|
|||
recThrowException,
|
||||
recThrowException,
|
||||
recClear,
|
||||
|
||||
recGetCacheReserve,
|
||||
recSetCacheReserve,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue