mirror of https://github.com/PCSX2/pcsx2.git
Disabled global optimization properly, and enabled Incremental Link, on devel builds. Minor code changes compile fairly instantly now. ;) I'll make some property sheets for enabled/disabled LTCG/WPO in the future.
Added a new Threading class: ScopedLock. Used as an automatic unlocking mutex (safe for use with C++ exceptions, and cleaner/simpler code too). It works like C#'s "using" and "lock" directives, for those familiar with that. Optimized the AtomicExchange implementations for MSVC. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@798 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
2fa30cabf4
commit
7c00edfc07
|
@ -142,7 +142,7 @@
|
|||
ConfigurationType="4"
|
||||
InheritedPropertySheets="..\3rdparty.vsprops"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
WholeProgramOptimization="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -166,6 +166,7 @@
|
|||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
WholeProgramOptimization="false"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
BufferSecurityCheck="false"
|
||||
|
|
|
@ -157,7 +157,7 @@
|
|||
ConfigurationType="4"
|
||||
InheritedPropertySheets="..\3rdparty.vsprops"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
WholeProgramOptimization="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -181,6 +181,7 @@
|
|||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
EnableFiberSafeOptimizations="true"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories=""$(ProjectDir)";"$(ProjectDir)\include""
|
||||
PreprocessorDefinitions="PTW32_STATIC_LIB;PTW32_BUILD_INLINED;__CLEANUP_SEH;WIN32;NDEBUG;_LIB"
|
||||
StringPooling="true"
|
||||
|
|
|
@ -168,8 +168,6 @@ ptw32_InterlockedExchange (volatile PTW32_INTERLOCKED_LPLONG location,
|
|||
#pragma disable_message (200)
|
||||
#endif
|
||||
|
||||
LONG result;
|
||||
|
||||
/*
|
||||
* The XCHG instruction always locks the bus with or without the
|
||||
* LOCKED prefix. This makes it significantly slower than CMPXCHG on
|
||||
|
@ -186,14 +184,15 @@ ptw32_InterlockedExchange (volatile PTW32_INTERLOCKED_LPLONG location,
|
|||
#if defined(_MSC_VER) || defined(__WATCOMC__) || (defined(__BORLANDC__) && defined(HAVE_TASM32))
|
||||
#define HAVE_INLINABLE_INTERLOCKED_XCHG
|
||||
|
||||
// pcsx2: Optimized this slightly for MSVC, which automatically knowns when to
|
||||
// push/pop registers and how to return eax as a result without using a temp var.
|
||||
|
||||
{
|
||||
_asm {
|
||||
//PUSH ecx
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV eax,dword ptr [value]
|
||||
XCHG dword ptr [ecx],eax
|
||||
MOV dword ptr [result], eax
|
||||
//POP ecx
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV eax,dword ptr [value]
|
||||
XCHG dword ptr [ecx],eax
|
||||
//MOV dword ptr [result], eax
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -215,22 +214,20 @@ ptw32_InterlockedExchange (volatile PTW32_INTERLOCKED_LPLONG location,
|
|||
* Can we do without the PUSH/POP instructions?
|
||||
*/
|
||||
_asm {
|
||||
//PUSH ecx
|
||||
//PUSH edx
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV edx,dword ptr [value]
|
||||
L1: MOV eax,dword ptr [ecx]
|
||||
CMPXCHG dword ptr [ecx],edx
|
||||
JNZ L1
|
||||
MOV dword ptr [result], eax
|
||||
//POP edx
|
||||
//POP ecx
|
||||
MOV ecx,dword ptr [location]
|
||||
MOV edx,dword ptr [value]
|
||||
L1: MOV eax,dword ptr [ecx]
|
||||
CMPXCHG dword ptr [ecx],edx
|
||||
JNZ L1
|
||||
//MOV dword ptr [result], eax
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
#define HAVE_INLINABLE_INTERLOCKED_XCHG
|
||||
|
||||
LONG result;
|
||||
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
|
@ -264,6 +261,8 @@ L1: MOV eax,dword ptr [ecx]
|
|||
:"m" (*location), "r" (value));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
@ -279,8 +278,6 @@ L1: MOV eax,dword ptr [ecx]
|
|||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
return result;
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
#pragma enable_message (200)
|
||||
#endif
|
||||
|
|
|
@ -140,7 +140,7 @@
|
|||
ConfigurationType="4"
|
||||
InheritedPropertySheets="..\3rdparty.vsprops"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
WholeProgramOptimization="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -164,6 +164,7 @@
|
|||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
WholeProgramOptimization="false"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
WarningLevel="3"
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "Threading.h"
|
||||
#include "Linux.h"
|
||||
#include "../x86/ix86/ix86.h"
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
#include "deci2_netmp.h"
|
||||
#include "deci2_ttyp.h"
|
||||
|
||||
#include "Threading.h"
|
||||
|
||||
#define PROTO_DCMP 0x0001
|
||||
#define PROTO_ITTYP 0x0110
|
||||
#define PROTO_IDBGP 0x0130
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "VUmicro.h"
|
||||
#include "deci2.h"
|
||||
|
||||
#include "Threading.h"
|
||||
using namespace Threading;
|
||||
|
||||
using namespace R5900;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "Threading.h"
|
||||
#include "HostGui.h"
|
||||
|
||||
#include "VUmicro.h"
|
||||
|
@ -92,6 +91,7 @@ static void trim( string& line )
|
|||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This function should be called once during program execution.
|
||||
void SysDetect()
|
||||
{
|
||||
|
@ -160,6 +160,7 @@ void SysDetect()
|
|||
Console::ClearColor();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Allocates memory for all PS2 systems.
|
||||
bool SysAllocateMem()
|
||||
{
|
||||
|
@ -187,10 +188,12 @@ bool SysAllocateMem()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Allocates memory for all recompilers, and force-disables any recs that fail to initialize.
|
||||
// This should be done asap, since the recompilers tend to demand a lot of system resources, and prefer
|
||||
// to have those resources at specific address ranges. The sooner memory is allocated, the better.
|
||||
// This should be done asap, since the recompilers tend to demand a lot of system resources,
|
||||
// and prefer to have those resources at specific address ranges. The sooner memory is
|
||||
// allocated, the better.
|
||||
//
|
||||
// Returns FALSE on *critical* failure (GUI should issue a msg and exit).
|
||||
void SysAllocateDynarecs()
|
||||
{
|
||||
|
@ -259,6 +262,7 @@ void SysAllocateDynarecs()
|
|||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This should be called last thing before Pcsx2 exits.
|
||||
void SysShutdownMem()
|
||||
{
|
||||
|
@ -269,6 +273,7 @@ void SysShutdownMem()
|
|||
memShutdown();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// This should generally be called right before calling SysShutdownMem(), although you can optionally
|
||||
// use it in conjunction with SysAllocDynarecs to allocate/free the dynarec resources on the fly (as
|
||||
// risky as it might be, since dynarecs could very well fail on the second attempt).
|
||||
|
@ -285,6 +290,7 @@ void SysShutdownDynarecs()
|
|||
bool g_ReturnToGui = false; // set to exit the execution of the emulator and return control to the GUI
|
||||
bool g_EmulationInProgress = false; // Set TRUE if a game is actively running (set to false on reset)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Resets all PS2 cpu execution caches, which does not affect that actual PS2 state/condition.
|
||||
// This can be called at any time outside the context of a Cpu->Execute() block without
|
||||
// bad things happening (recompilers will slow down for a brief moment since rec code blocks
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "MemcpyFast.h"
|
||||
#include "SafeArray.h"
|
||||
#include "Misc.h"
|
||||
#include "Threading.h" // to use threading stuff, include the Threading namespace in your file.
|
||||
|
||||
|
||||
enum PageProtectionMode
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace Threading
|
|||
|
||||
void Thread::Close()
|
||||
{
|
||||
if( m_terminated ) return;
|
||||
pthread_cancel( m_thread );
|
||||
pthread_join( m_thread, NULL );
|
||||
}
|
||||
|
|
|
@ -67,8 +67,7 @@ namespace Threading
|
|||
void Unlock();
|
||||
};
|
||||
|
||||
// Returns the number of available logical CPUs (cores plus
|
||||
// hyperthreaded cpus)
|
||||
// Returns the number of available logical CPUs (cores plus hyperthreaded cpus)
|
||||
extern void CountLogicalCores( int LogicalCoresPerPhysicalCPU, int PhysicalCoresPerPhysicalCPU );
|
||||
|
||||
// Releases a timeslice to other threads.
|
||||
|
@ -80,6 +79,24 @@ namespace Threading
|
|||
// sleeps the current thread for the given number of milliseconds.
|
||||
extern void Sleep( int ms );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Thread - Helper class for the basics of starting/managing simple threads.
|
||||
//
|
||||
// Use this as a base class for your threaded procedure, and implement the 'int Callback()'
|
||||
// method. Use Start() and Close() to start and shutdown the thread, and use m_post_event
|
||||
// internally to post/receive events for the thread (make a public accessor for it in your
|
||||
// derived class if your thread utilizes the post).
|
||||
//
|
||||
// Notes:
|
||||
// * To ensure thread safety against C++'s bizarre and not-thread-friendly object
|
||||
// constructors and destructors, you *must* use Start() and Close(). There is a built-
|
||||
// in Close() called on destruction, which should work for very simple threads (that
|
||||
// do not have any special shutdown code of their own), but
|
||||
//
|
||||
// * Constructing threads as static vars isn't recommended since it can potentially con-
|
||||
// fuse w32pthreads, if the static initializers are executed out-of-order (C++ offers
|
||||
// no dependency options for ensuring correct static var initializations).
|
||||
//
|
||||
class Thread : NoncopyableObject
|
||||
{
|
||||
protected:
|
||||
|
@ -106,12 +123,36 @@ namespace Threading
|
|||
// on linux).
|
||||
static void* _internal_callback( void* func );
|
||||
|
||||
// Implemented by derrived class to handle threading actions!
|
||||
// Implemented by derived class to handle threading actions!
|
||||
virtual int Callback()=0;
|
||||
};
|
||||
|
||||
// Our fundamental interlocking functions. All other useful interlocks can
|
||||
// be derrived from these little beasties!
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ScopedLock: Helper class for using Mutexes.
|
||||
// Using this class provides an exception-safe (and generally clean) method of locking
|
||||
// code inside a mutex.
|
||||
class ScopedLock : NoncopyableObject
|
||||
{
|
||||
protected:
|
||||
MutexLock& m_lock;
|
||||
|
||||
public:
|
||||
virtual ~ScopedLock()
|
||||
{
|
||||
m_lock.Unlock();
|
||||
}
|
||||
|
||||
ScopedLock( MutexLock& locker ) :
|
||||
m_lock( locker )
|
||||
{
|
||||
m_lock.Lock();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Our fundamental interlocking functions. All other useful interlocks can be derived
|
||||
// from these little beasties!
|
||||
|
||||
extern long pcsx2_InterlockedExchange(volatile long* Target, long srcval);
|
||||
extern long pcsx2_InterlockedCompareExchange( volatile long* target, long srcval, long comp );
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
WholeProgramOptimization="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -134,6 +134,8 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
InlineFunctionExpansion="0"
|
||||
FavorSizeOrSpeed="1"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
|
@ -162,6 +164,7 @@
|
|||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="zlib.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)-dev.exe"
|
||||
LinkIncremental="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "Win32.h"
|
||||
|
||||
#include "System.h"
|
||||
#include "Threading.h"
|
||||
#include "ix86/ix86_types.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -120,30 +119,26 @@ namespace Threading
|
|||
{
|
||||
__asm
|
||||
{
|
||||
//PUSH ecx
|
||||
mov ecx,dword ptr [target]
|
||||
mov eax,dword ptr [srcval]
|
||||
lock xadd dword ptr [ecx],eax
|
||||
mov dword ptr [result], eax
|
||||
//POP ecx
|
||||
|
||||
// msvc smartly returns eax for us without so much as a compiler warning even...
|
||||
//mov dword ptr [result], eax
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__asm
|
||||
{
|
||||
//PUSH ecx
|
||||
//PUSH edx
|
||||
mov ecx,dword ptr [target]
|
||||
//L1:
|
||||
mov eax,dword ptr [srcval]
|
||||
xadd dword ptr [ecx],eax
|
||||
//jnz L1
|
||||
mov dword ptr [result], eax
|
||||
//POP edx
|
||||
//POP ecx
|
||||
|
||||
// msvc smartly returns eax for us without so much as a compiler warning even...
|
||||
//mov dword ptr [result], eax
|
||||
}
|
||||
}
|
||||
return result;
|
||||
// return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
OutputFile="$(OutDir)\$(ProjectName)-dbg.dll"
|
||||
ModuleDefinitionFile=".\CDVDiso.def"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -148,7 +147,6 @@
|
|||
GenerateManifest="false"
|
||||
ModuleDefinitionFile=".\CDVDiso.def"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
|
@ -180,7 +178,7 @@
|
|||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\common\vsprops\plugin_svnroot.vsprops;..\..\..\..\common\vsprops\BaseProperties.vsprops;..\..\..\..\common\vsprops\3rdpartyDeps.vsprops"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
WholeProgramOptimization="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -204,6 +202,7 @@
|
|||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
WholeProgramOptimization="false"
|
||||
PreprocessorDefinitions="NDEBUG;_USRDLL"
|
||||
StringPooling="true"
|
||||
MinimalRebuild="false"
|
||||
|
@ -228,12 +227,10 @@
|
|||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="bzip2.lib zlib.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName).dll"
|
||||
LinkIncremental="2"
|
||||
GenerateManifest="false"
|
||||
ModuleDefinitionFile=".\CDVDiso.def"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
|
Loading…
Reference in New Issue