diff --git a/Source/Core/Common/Src/Thunk.cpp b/Source/Core/Common/Src/Thunk.cpp index aad55cb3c4..1792df3e77 100644 --- a/Source/Core/Common/Src/Thunk.cpp +++ b/Source/Core/Common/Src/Thunk.cpp @@ -23,8 +23,6 @@ #include "ABI.h" #include "Thunk.h" -ThunkManager thunks; - #define THUNK_ARENA_SIZE 1024*1024*1 namespace diff --git a/Source/Core/Common/Src/Thunk.h b/Source/Core/Common/Src/Thunk.h index 44cfc0c4cb..ac40babe4c 100644 --- a/Source/Core/Common/Src/Thunk.h +++ b/Source/Core/Common/Src/Thunk.h @@ -43,13 +43,17 @@ class ThunkManager : public Gen::XCodeBlock const u8 *load_regs; public: - void Init(); - void Reset(); - void Shutdown(); - + ThunkManager() { + Init(); + } + ~ThunkManager() { + Shutdown(); + } void *ProtectFunction(void *function, int num_params); +private: + void Init(); + void Shutdown(); + void Reset(); }; -extern ThunkManager thunks; - #endif // _THUNK_H_ diff --git a/Source/Core/Core/Src/HW/HW.cpp b/Source/Core/Core/Src/HW/HW.cpp index f049b61d31..70f6ae21fd 100644 --- a/Source/Core/Core/Src/HW/HW.cpp +++ b/Source/Core/Core/Src/HW/HW.cpp @@ -45,7 +45,6 @@ namespace HW { CoreTiming::Init(); - thunks.Init(); // not really hw, but this way we know it's inited early :P State_Init(); // Init the whole Hardware @@ -85,7 +84,6 @@ namespace HW } State_Shutdown(); - thunks.Shutdown(); CoreTiming::Shutdown(); } diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/IR_X86.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/IR_X86.cpp index 4431ff361e..73f34abd77 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/IR_X86.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/IR_X86.cpp @@ -48,6 +48,8 @@ The register allocation is just a simple forward greedy allocator. #include "../../ConfigManager.h" #include "x64Emitter.h" +static ThunkManager thunks; + using namespace IREmitter; using namespace Gen; diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.h b/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.h index 4943f43ed1..38646b05bd 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.h +++ b/Source/Core/Core/Src/PowerPC/JitCommon/JitAsmCommon.h @@ -19,6 +19,7 @@ #define _JITASMCOMMON_H #include "../JitCommon/Jit_Util.h" +#include "Thunk.h" class CommonAsmRoutines : public EmuCodeBlock { protected: @@ -69,6 +70,9 @@ public: // In: ECX: Address to write to. // In: XMM0: Bottom 32-bit slot holds the float to be written. const u8 GC_ALIGNED16(*singleStoreQuantized[8]); + +private: + ThunkManager thunks; }; #endif diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.h b/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.h index 9fca638d59..a99b07d74c 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.h +++ b/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.h @@ -21,6 +21,7 @@ #include "Common.h" #include "x64Emitter.h" #include "x64Analyzer.h" +#include "Thunk.h" // Declarations and definitions // ---------- @@ -53,6 +54,8 @@ public: const u8 *GetReadTrampoline(const InstructionInfo &info); const u8 *GetWriteTrampoline(const InstructionInfo &info); +private: + ThunkManager thunks; }; #endif diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.h b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.h index dbc730df17..b9f41bd259 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.h +++ b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.h @@ -19,6 +19,7 @@ #define _JITUTIL_H #include "x64Emitter.h" +#include "Thunk.h" // Like XCodeBlock but has some utilities for memory access. class EmuCodeBlock : public Gen::XCodeBlock { @@ -39,6 +40,8 @@ public: void ForceSinglePrecisionS(Gen::X64Reg xmm); void ForceSinglePrecisionP(Gen::X64Reg xmm); +protected: + ThunkManager thunks; }; #endif // _JITUTIL_H