diff --git a/common/src/Utilities/Exceptions.cpp b/common/src/Utilities/Exceptions.cpp index 893365f039..7050acb005 100644 --- a/common/src/Utilities/Exceptions.cpp +++ b/common/src/Utilities/Exceptions.cpp @@ -68,12 +68,6 @@ wxString DiagnosticOrigin::ToString( const wxChar* msg ) const } -bool pxAssertImpl_LogIt( const DiagnosticOrigin& origin, const wxChar *msg ) -{ - wxLogError( L"%s", origin.ToString( msg ).c_str() ); - return false; -} - // Because wxTrap isn't available on Linux builds of wxWidgets (non-Debug, typically) void pxTrap() { @@ -94,6 +88,16 @@ void pxTrap() #endif // Win/Unix } + +bool pxAssertImpl_LogIt( const DiagnosticOrigin& origin, const wxChar *msg ) +{ + //wxLogError( L"%s", origin.ToString( msg ).c_str() ); + wxMessageOutputDebug().Printf( L"%s", origin.ToString( msg ).c_str() ); + pxTrap(); + return false; +} + + DEVASSERT_INLINE void pxOnAssert( const DiagnosticOrigin& origin, const wxChar* msg ) { // Recursion guard: Allow at least one recursive call. This is useful because sometimes diff --git a/pcsx2/Memory.cpp b/pcsx2/Memory.cpp index 25b3cc3804..626d7d299c 100644 --- a/pcsx2/Memory.cpp +++ b/pcsx2/Memory.cpp @@ -582,7 +582,7 @@ protected: void OnPageFaultEvent( const PageFaultInfo& info, bool& handled ); }; -static mmap_PageFaultHandler mmap_faultHandler; +static mmap_PageFaultHandler* mmap_faultHandler = NULL; EEVM_MemoryAllocMess* eeMem = NULL; @@ -596,12 +596,13 @@ void memAlloc() if( eeMem == NULL) throw Exception::OutOfMemory( L"memAlloc > failed to allocate PS2's base ram/rom/scratchpad." ); - Source_PageFault.Add( mmap_faultHandler ); + pxAssume(Source_PageFault); + mmap_faultHandler = new mmap_PageFaultHandler(); } void memShutdown() { - Source_PageFault.Remove( mmap_faultHandler ); + safe_delete(mmap_faultHandler); vtlb_free( eeMem, sizeof(*eeMem) ); eeMem = NULL; diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 02f12fdddb..c9433e7914 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -31,16 +31,18 @@ extern void resetNewVif(int idx); template class EventSource< IEventListener_PageFault >; -SrcType_PageFault Source_PageFault; +SrcType_PageFault* Source_PageFault = NULL; EventListener_PageFault::EventListener_PageFault() { - Source_PageFault.Add( *this ); + pxAssume(Source_PageFault); + Source_PageFault->Add( *this ); } EventListener_PageFault::~EventListener_PageFault() throw() { - Source_PageFault.Remove( *this ); + if (Source_PageFault) + Source_PageFault->Remove( *this ); } void SrcType_PageFault::Dispatch( const PageFaultInfo& params ) @@ -108,11 +110,19 @@ void* BaseVirtualMemoryReserve::Reserve( uint size, uptr base, uptr upper_bounds DevCon.WriteLn( Color_Blue, L"%s mapped @ 0x%08X -> 0x%08X [%umb]", Name.c_str(), m_baseptr, (uptr)m_baseptr+reserved_bytes, reserved_bytes / _1mb); - if (m_def_commit) + /*if (m_def_commit) { - HostSys::MmapCommit(m_baseptr, m_def_commit*__pagesize); - HostSys::MemProtect(m_baseptr, m_def_commit*__pagesize, m_prot_mode); - } + const uint camt = m_def_commit * __pagesize; + HostSys::MmapCommit(m_baseptr, camt); + HostSys::MemProtect(m_baseptr, camt, m_prot_mode); + + u8* init = (u8*)m_baseptr; + u8* endpos = init + camt; + for( ; init m_CpuProviders; + ScopedPtr m_VmReserve; ScopedPtr m_VmAllocs; protected: diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index e064df29cf..8b448aa737 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -252,6 +252,8 @@ void Pcsx2App::AllocateCoreStuffs() SysLogMachineCaps(); AppApplySettings(); + if (!m_VmReserve) m_VmReserve = new SysReserveVM(); + if( !m_CpuProviders ) { // FIXME : Some or all of SysCpuProviderPack should be run from the SysExecutor thread, diff --git a/pcsx2/windows/WinSysExec.cpp b/pcsx2/windows/WinSysExec.cpp index 6a11a70c62..b454bea0d8 100644 --- a/pcsx2/windows/WinSysExec.cpp +++ b/pcsx2/windows/WinSysExec.cpp @@ -25,8 +25,8 @@ int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps ) if( eps->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION ) return EXCEPTION_CONTINUE_SEARCH; - Source_PageFault.Dispatch( PageFaultInfo( (uptr)eps->ExceptionRecord->ExceptionInformation[1] ) ); - return Source_PageFault.WasHandled() ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_CONTINUE_SEARCH; + Source_PageFault->Dispatch( PageFaultInfo( (uptr)eps->ExceptionRecord->ExceptionInformation[1] ) ); + return Source_PageFault->WasHandled() ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_CONTINUE_SEARCH; } void InstallSignalHandler() diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index 8b1fb383dc..13724b55ba 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -51,7 +51,7 @@ uptr psxhwLUT[0x10000]; #define HWADDR(mem) (psxhwLUT[mem >> 16] + (mem)) -static RecompiledCodeReserve recMem(L"R3000A recompiled code cache", _1mb * 2); +static RecompiledCodeReserve* recMem = NULL; static BASEBLOCK *recRAM = NULL; // and the ptr to the blocks here static BASEBLOCK *recROM = NULL; // and here @@ -757,7 +757,11 @@ static const uint m_recBlockAllocSize = static void recReserve() { - recMem.Reserve( _16mb, HostMemoryMap::IOPrec ); + if (!recMem) + { + recMem = new RecompiledCodeReserve(L"R3000A recompiled code cache", _1mb * 2); + recMem->Reserve( _16mb, HostMemoryMap::IOPrec ); + } } static void recAlloc() @@ -786,14 +790,14 @@ static void recAlloc() if( s_pInstCache == NULL ) throw Exception::OutOfMemory( L"R3000 InstCache." ); - ProfilerRegisterSource( "IOP Rec", recMem, recMem.GetReserveSizeInBytes() ); + ProfilerRegisterSource( "IOP Rec", *recMem, recMem->GetReserveSizeInBytes() ); _DynGen_Dispatchers(); } void recResetIOP() { recAlloc(); - recMem.Reset(); + recMem->Reset(); DevCon.WriteLn( "iR3000A Recompiler reset." ); @@ -836,14 +840,14 @@ void recResetIOP() recBlocks.Reset(); g_psxMaxRecMem = 0; - recPtr = recMem; + recPtr = *recMem; psxbranch = 0; } static void recShutdown() { ProfilerTerminateSource( "IOPRec" ); - recMem.Free(); + safe_delete( recMem ); safe_aligned_free( m_recBlockAlloc ); @@ -1191,7 +1195,7 @@ static void __fastcall iopRecRecompile( const u32 startpc ) pxAssert( startpc ); // if recPtr reached the mem limit reset whole mem - if (recPtr >= (recMem.GetPtrEnd() - _64kb)) { + if (recPtr >= (recMem->GetPtrEnd() - _64kb)) { recResetIOP(); } @@ -1380,7 +1384,7 @@ StartRecomp: } } - pxAssert( xGetPtr() < recMem.GetPtrEnd() ); + pxAssert( xGetPtr() < recMem->GetPtrEnd() ); pxAssert(xGetPtr() - recPtr < _64kb); s_pCurBlockEx->x86size = xGetPtr() - recPtr; diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index ff81eee333..b3eb7783a5 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -64,7 +64,7 @@ bool g_cpuFlushedPC, g_cpuFlushedCode, g_recompilingDelaySlot, g_maySignalExcept #define X86 static const int RECCONSTBUF_SIZE = 16384 * 2; // 64 bit consts in 32 bit units -static RecompiledCodeReserve recMem(L"R5900-32 recompiled code cache", _1mb * 4); +static RecompiledCodeReserve* recMem = NULL; static u32* recConstBuf = NULL; // 64-bit pseudo-immediates static BASEBLOCK *recRAM = NULL; // and the ptr to the blocks here @@ -562,7 +562,8 @@ static void recReserve() if ( !x86caps.hasStreamingSIMD2Extensions ) recThrowHardwareDeficiency( L"SSE2" ); - recMem.Reserve( _64mb, HostMemoryMap::EErec ); + recMem = new RecompiledCodeReserve(L"R5900-32 recompiled code cache", _1mb * 4); + recMem->Reserve( _64mb, HostMemoryMap::EErec ); } static void recAlloc() @@ -595,7 +596,7 @@ static void recAlloc() // No errors.. Proceed with initialization: - ProfilerRegisterSource( "EE Rec", recMem, recMem.GetReserveSizeInBytes() ); + ProfilerRegisterSource( "EE Rec", *recMem, recMem->GetReserveSizeInBytes() ); _DynGen_Dispatchers(); x86FpuState = FPU_STATE; @@ -624,7 +625,7 @@ static void recResetRaw() Console.WriteLn( Color_StrongBlack, "EE/iR5900-32 Recompiler Reset" ); - recMem.Reset(); + recMem->Reset(); maxrecmem = 0; @@ -674,9 +675,9 @@ static void recResetRaw() recLUT_SetPage(recLUT, hwLUT, recROM1, 0xa000, i, i - 0x1e00); } - x86SetPtr(recMem); + x86SetPtr(*recMem); - recPtr = recMem; + recPtr = *recMem; recConstBufPtr = recConstBuf; x86FpuState = FPU_STATE; @@ -686,7 +687,7 @@ static void recResetRaw() static void recShutdown() { ProfilerTerminateSource( "EERec" ); - recMem.Free(); + safe_delete( recMem ); recBlocks.Reset(); safe_aligned_free( m_recBlockAlloc ); @@ -1355,7 +1356,7 @@ static void __fastcall recRecompile( const u32 startpc ) pxAssume( startpc ); // if recPtr reached the mem limit reset whole mem - if (recPtr >= (recMem.GetPtrEnd() - _64kb)) { + if (recPtr >= (recMem->GetPtrEnd() - _64kb)) { AtomicExchange( eeRecNeedsReset, true ); } else if ((recConstBufPtr - recConstBuf) >= RECCONSTBUF_SIZE - 64) { @@ -1844,7 +1845,7 @@ StartRecomp: } } - pxAssert( xGetPtr() < recMem.GetPtrEnd() ); + pxAssert( xGetPtr() < recMem->GetPtrEnd() ); pxAssert( recConstBufPtr < recConstBuf + RECCONSTBUF_SIZE ); pxAssert( x86FpuState == 0 );