mvu: use static array for dispatcher code

I don't understand why but standard mmap blew up Vtune
This commit is contained in:
Gregory Hainaut 2016-11-25 21:18:49 +01:00
parent 7ec8c7f9fe
commit 4fca5f4d88
1 changed files with 12 additions and 7 deletions

View File

@ -23,6 +23,8 @@
//------------------------------------------------------------------ //------------------------------------------------------------------
// Micro VU - Main Functions // Micro VU - Main Functions
//------------------------------------------------------------------ //------------------------------------------------------------------
static u8 __pagealigned vu0_RecDispatchers[mVUdispCacheSize];
static u8 __pagealigned vu1_RecDispatchers[mVUdispCacheSize];
static __fi void mVUthrowHardwareDeficiency(const wxChar* extFail, int vuIndex) { static __fi void mVUthrowHardwareDeficiency(const wxChar* extFail, int vuIndex) {
throw Exception::HardwareDeficiency() throw Exception::HardwareDeficiency()
@ -63,9 +65,8 @@ void mVUinit(microVU& mVU, uint vuIndex) {
mVUreserveCache(mVU); mVUreserveCache(mVU);
mVU.dispCache = SysMmapEx(0, mVUdispCacheSize, 0,(mVU.index ? "Micro VU1 Dispatcher" : "Micro VU0 Dispatcher")); if (vuIndex) mVU.dispCache = vu1_RecDispatchers;
if (!mVU.dispCache) throw Exception::OutOfMemory (mVU.index ? L"Micro VU1 Dispatcher" : L"Micro VU0 Dispatcher"); else mVU.dispCache = vu0_RecDispatchers;
memset(mVU.dispCache, 0xcc, mVUdispCacheSize);
mVU.regAlloc.reset(new microRegAlloc(mVU.index)); mVU.regAlloc.reset(new microRegAlloc(mVU.index));
} }
@ -76,9 +77,9 @@ void mVUreset(microVU& mVU, bool resetReserve) {
// Restore reserve to uncommitted state // Restore reserve to uncommitted state
if (resetReserve) mVU.cache_reserve->Reset(); if (resetReserve) mVU.cache_reserve->Reset();
if (mVU.index) Perf::any.map((uptr)&mVU.dispCache, mVUdispCacheSize, "mVU1 Dispatcher"); HostSys::MemProtect(mVU.dispCache, mVUdispCacheSize, PageAccess_ReadWrite());
else Perf::any.map((uptr)&mVU.dispCache, mVUdispCacheSize, "mVU0 Dispatcher"); memset(mVU.dispCache, 0xcc, mVUdispCacheSize);
x86SetPtr(mVU.dispCache); x86SetPtr(mVU.dispCache);
mVUdispatcherAB(mVU); mVUdispatcherAB(mVU);
mVUdispatcherCD(mVU); mVUdispatcherCD(mVU);
@ -116,13 +117,17 @@ void mVUreset(microVU& mVU, bool resetReserve) {
mVU.prog.quick[i].block = NULL; mVU.prog.quick[i].block = NULL;
mVU.prog.quick[i].prog = NULL; mVU.prog.quick[i].prog = NULL;
} }
HostSys::MemProtect(mVU.dispCache, mVUdispCacheSize, PageAccess_ExecOnly());
if (mVU.index) Perf::any.map((uptr)&mVU.dispCache, mVUdispCacheSize, "mVU1 Dispatcher");
else Perf::any.map((uptr)&mVU.dispCache, mVUdispCacheSize, "mVU0 Dispatcher");
} }
// Free Allocated Resources // Free Allocated Resources
void mVUclose(microVU& mVU) { void mVUclose(microVU& mVU) {
safe_delete (mVU.cache_reserve); safe_delete (mVU.cache_reserve);
SafeSysMunmap(mVU.dispCache, mVUdispCacheSize);
// Delete Programs and Block Managers // Delete Programs and Block Managers
for (u32 i = 0; i < (mVU.progSize / 2); i++) { for (u32 i = 0; i < (mVU.progSize / 2); i++) {