mirror of https://github.com/PCSX2/pcsx2.git
aligned_stack:
* Added -fno-strict-aliasing to the ever growing list of gcc optimizations that can potentially cause perfectly good C code to generate entirely broken results. * Removed the preferred-stack=2, since this branch *should* run fine without it now. * Have Release builds in Linux SIGKILL when encountering an unexpected SIGSEGV. * Fixed some deadlock issues with the new console logger (it introduced cancel points, which is a good thing! unless you're the EE recompiler and you swallow up any attempt by GCC to cancel a thread) * Compilation error fixes. git-svn-id: http://pcsx2.googlecode.com/svn/branches/aligned_stack@2049 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
51999656ab
commit
f172829737
|
@ -66,8 +66,8 @@
|
|||
<Add option="-fno-guess-branch-probability" />
|
||||
<Add option="-fno-dse" />
|
||||
<Add option="-fno-tree-dse" />
|
||||
<Add option="-fno-strict-aliasing" />
|
||||
<Add option="-pipe -msse -msse2" />
|
||||
<Add option="-mpreferred-stack-boundary=2" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../../include/Utilities" />
|
||||
<Add directory="../../include" />
|
||||
|
|
|
@ -67,8 +67,8 @@
|
|||
<Add option="-fno-guess-branch-probability" />
|
||||
<Add option="-fno-dse" />
|
||||
<Add option="-fno-tree-dse" />
|
||||
<Add option="-fno-strict-aliasing" />
|
||||
<Add option="-pipe -msse -msse2" />
|
||||
<Add option="-mpreferred-stack-boundary=2" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../../include/x86emitter" />
|
||||
<Add directory="../../include" />
|
||||
|
|
|
@ -146,6 +146,7 @@ namespace Threading
|
|||
void WaitRaw();
|
||||
bool WaitRaw( const wxTimeSpan& timeout );
|
||||
void WaitNoCancel();
|
||||
void WaitNoCancel( const wxTimeSpan& timeout );
|
||||
int Count();
|
||||
|
||||
void Wait();
|
||||
|
|
|
@ -163,6 +163,14 @@ void Threading::Semaphore::WaitNoCancel()
|
|||
pthread_setcancelstate( oldstate, NULL );
|
||||
}
|
||||
|
||||
void Threading::Semaphore::WaitNoCancel( const wxTimeSpan& timeout )
|
||||
{
|
||||
int oldstate;
|
||||
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &oldstate );
|
||||
WaitRaw( timeout );
|
||||
pthread_setcancelstate( oldstate, NULL );
|
||||
}
|
||||
|
||||
int Threading::Semaphore::Count()
|
||||
{
|
||||
int retval;
|
||||
|
|
|
@ -42,25 +42,3 @@
|
|||
|
||||
extern void SetCPUState(u32 sseMXCSR, u32 sseVUMXCSR);
|
||||
extern u32 g_sseVUMXCSR, g_sseMXCSR;
|
||||
|
||||
// SEH - "Built in" Structed Exception Handling support.
|
||||
// This should be available on Windows, via Microsoft or Intel compilers (I'm pretty sure Intel
|
||||
// supports native SEH model). GUNC in Windows, or any compiler in a non-windows platform, will
|
||||
// ned to use setjmp/longjmp instead to exit recompiled code.
|
||||
//
|
||||
#if defined(_WIN32) && !defined(__GNUG__)
|
||||
# define PCSX2_SEH
|
||||
#endif
|
||||
|
||||
#ifndef PCSX2_SEH
|
||||
# include <setjmp.h>
|
||||
|
||||
enum
|
||||
{
|
||||
SetJmp_Dispatcher = 1,
|
||||
SetJmp_Exit,
|
||||
};
|
||||
|
||||
extern __threadlocal jmp_buf SetJmp_RecExecute;
|
||||
extern __threadlocal jmp_buf SetJmp_StateCheck;
|
||||
#endif
|
||||
|
|
|
@ -44,15 +44,15 @@ void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * )
|
|||
// get bad virtual address
|
||||
uptr offset = (u8*)info->si_addr - psM;
|
||||
|
||||
DevCon.Status( "Protected memory cleanup. Offset 0x%x", offset );
|
||||
|
||||
if (offset>=Ps2MemSize::Base)
|
||||
{
|
||||
// Bad mojo! Completely invalid address.
|
||||
// Instigate a crash or abort emulation or something.
|
||||
wxTrap();
|
||||
return;
|
||||
if( !IsDebugBuild )
|
||||
raise( SIGKILL );
|
||||
}
|
||||
|
||||
DevCon.Status( "Protected memory cleanup. Offset 0x%x", offset );
|
||||
mmap_ClearCpuBlock( offset & ~m_pagemask );
|
||||
}
|
||||
|
|
|
@ -96,8 +96,8 @@
|
|||
<Add option="-fno-guess-branch-probability" />
|
||||
<Add option="-fno-dse" />
|
||||
<Add option="-fno-tree-dse" />
|
||||
<Add option="-fno-strict-aliasing" />
|
||||
<Add option="-pipe -msse -msse2" />
|
||||
<Add option="-mpreferred-stack-boundary=2" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DWX_PRECOMP" />
|
||||
<Add directory="$(SvnRootDir)/common/include/" />
|
||||
|
|
|
@ -61,8 +61,9 @@ extern void SysClearExecutionCache(); // clears recompiled execution caches!
|
|||
extern u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller="Unnamed");
|
||||
extern void vSyncDebugStuff( uint frame );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Memory Protection (Used by VTLB, Recompilers, and Texture caches)
|
||||
// --------------------------------------------------------------------------------------
|
||||
#ifdef __LINUX__
|
||||
|
||||
# include <signal.h>
|
||||
|
@ -87,6 +88,33 @@ extern void vSyncDebugStuff( uint frame );
|
|||
# error PCSX2 - Unsupported operating system platform.
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// PCSX2_SEH - Defines existence of "built in" Structed Exception Handling support.
|
||||
// --------------------------------------------------------------------------------------
|
||||
// This should be available on Windows, via Microsoft or Intel compilers (I'm pretty sure Intel
|
||||
// supports native SEH model). GNUC in Windows, or any compiler in a non-windows platform, will
|
||||
// need to use setjmp/longjmp instead to exit recompiled code.
|
||||
//
|
||||
#if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define PCSX2_SEH
|
||||
#else
|
||||
|
||||
# include <setjmp.h>
|
||||
|
||||
// Platforms without SEH need to use SetJmp / LongJmp to deal with exiting the recompiled
|
||||
// code execution pipelines in an efficient manner, since standard C++ exceptions cannot
|
||||
// unwind across dynamically recompiled code.
|
||||
|
||||
enum
|
||||
{
|
||||
SetJmp_Dispatcher = 1,
|
||||
SetJmp_Exit,
|
||||
};
|
||||
|
||||
extern jmp_buf SetJmp_RecExecute;
|
||||
extern jmp_buf SetJmp_StateCheck;
|
||||
#endif
|
||||
|
||||
class pxMessageBoxEvent;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -312,9 +312,7 @@ int m_pendingFlushes = 0;
|
|||
// and this one will magically follow suite. :)
|
||||
void ConsoleLogFrame::Write( ConsoleColors color, const wxString& text )
|
||||
{
|
||||
//#ifdef PCSX2_SEH
|
||||
pthread_testcancel();
|
||||
//#endif
|
||||
|
||||
ScopedLock lock( m_QueueLock );
|
||||
|
||||
|
@ -355,7 +353,7 @@ void ConsoleLogFrame::Write( ConsoleColors color, const wxString& text )
|
|||
++m_WaitingThreadsForFlush;
|
||||
lock.Unlock();
|
||||
|
||||
if( !m_sem_QueueFlushed.WaitRaw( wxTimeSpan( 0,0,0,500 ) ) )
|
||||
if( !m_sem_QueueFlushed.Wait( wxTimeSpan( 0,0,0,500 ) ) )
|
||||
{
|
||||
// Necessary since the main thread could grab the lock and process before
|
||||
// the above function actually returns (gotta love threading!)
|
||||
|
|
|
@ -241,13 +241,19 @@ static DynGenFunc* _DynGen_DispatcherReg()
|
|||
#endif
|
||||
|
||||
// Set to 0 for a speedup in release builds.
|
||||
// [doesn't apply to GCC/Mac, which must always align]
|
||||
#define PCSX2_IOP_FORCED_ALIGN_STACK 0 //1
|
||||
|
||||
|
||||
// For overriding stackframe generation options in Debug builds (possibly useful for troubleshooting)
|
||||
// Typically this value should be the same as IsDevBuild.
|
||||
static const bool GenerateStackFrame = IsDevBuild;
|
||||
|
||||
static DynGenFunc* _DynGen_EnterRecompiledCode()
|
||||
{
|
||||
u8* retval = xGetPtr();
|
||||
|
||||
bool allocatedStack = IsDevBuild || PCSX2_IOP_FORCED_ALIGN_STACK;
|
||||
bool allocatedStack = GenerateStackFrame || PCSX2_IOP_FORCED_ALIGN_STACK;
|
||||
|
||||
// Optimization: The IOP never uses stack-based parameter invocation, so we can avoid
|
||||
// allocating any room on the stack for it (which is important since the IOP's entry
|
||||
|
@ -284,13 +290,12 @@ static DynGenFunc* _DynGen_EnterRecompiledCode()
|
|||
xPUSH( ebx );
|
||||
|
||||
allocatedStack = false;
|
||||
CannotUseCallBecauseItWillUnalignTheGodDamnedStack = !!PCSX2_ASSUME_ALIGNED_STACK;
|
||||
}
|
||||
|
||||
uptr* imm = NULL;
|
||||
if( allocatedStack )
|
||||
{
|
||||
if( IsDevBuild )
|
||||
if( GenerateStackFrame )
|
||||
{
|
||||
// Simulate a CALL function by pushing the call address and EBP onto the stack.
|
||||
// This retains proper stacktrace and stack unwinding (handy in devbuilds!)
|
||||
|
@ -301,11 +306,14 @@ static DynGenFunc* _DynGen_EnterRecompiledCode()
|
|||
// This part simulates the "normal" stackframe prep of "push ebp, mov ebp, esp"
|
||||
xMOV( ptr32[esp+0x08], ebp );
|
||||
xLEA( ebp, ptr32[esp+0x08] );
|
||||
}
|
||||
}
|
||||
|
||||
if( IsDevBuild )
|
||||
{
|
||||
xMOV( &s_store_esp, esp );
|
||||
xMOV( &s_store_ebp, ebp );
|
||||
}
|
||||
}
|
||||
|
||||
xJMP( iopDispatcherReg );
|
||||
if( imm != NULL )
|
||||
|
@ -319,7 +327,7 @@ static DynGenFunc* _DynGen_EnterRecompiledCode()
|
|||
if( allocatedStack )
|
||||
{
|
||||
// pop the nested "simulated call" stackframe, if needed:
|
||||
if( IsDevBuild ) xLEAVE();
|
||||
if( GenerateStackFrame ) xLEAVE();
|
||||
xMOV( edi, ptr[ebp-12] );
|
||||
xMOV( esi, ptr[ebp-8] );
|
||||
xMOV( ebx, ptr[ebp-4] );
|
||||
|
|
|
@ -684,8 +684,17 @@ static void StateThreadCheck_LongJmp()
|
|||
{
|
||||
setjmp( SetJmp_StateCheck );
|
||||
|
||||
int oldstate;
|
||||
|
||||
// Important! Most of the console logging and such has cancel points in it. This is great
|
||||
// in Windows, where SEH lets us safely kill a thread from anywhere we want. This is bad
|
||||
// in Linux, which cannot have a C++ exception cross the recompiler. Hence the changing
|
||||
// of the cancelstate here!
|
||||
|
||||
pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, &oldstate );
|
||||
mtgsThread.RethrowException();
|
||||
SysCoreThread::Get().StateCheckInThread();
|
||||
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &oldstate );
|
||||
}
|
||||
|
||||
static void recExecute()
|
||||
|
@ -847,17 +856,17 @@ void recClear(u32 addr, u32 size)
|
|||
}
|
||||
|
||||
|
||||
#ifdef __GNUG__
|
||||
__threadlocal jmp_buf SetJmp_RecExecute;
|
||||
__threadlocal jmp_buf SetJmp_StateCheck;
|
||||
#ifndef PCSX2_SEH
|
||||
jmp_buf SetJmp_RecExecute;
|
||||
jmp_buf SetJmp_StateCheck;
|
||||
#endif
|
||||
|
||||
static void ExitRec()
|
||||
{
|
||||
#ifdef __GNUG__
|
||||
longjmp( SetJmp_RecExecute, SetJmp_Exit );
|
||||
#else
|
||||
#ifdef PCSX2_SEH
|
||||
throw Exception::ExitRecExecute();
|
||||
#else
|
||||
longjmp( SetJmp_RecExecute, SetJmp_Exit );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue