From 1acc81c25dd889aeb5f1e0cce99b70d1c6ca6ca2 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Mon, 12 Dec 2016 19:20:26 +0100 Subject: [PATCH] vif: don't allocate vifblock hash on the heap Avoid an extra indirection to access the hash bucket (Find function) --- pcsx2/x86/newVif.h | 2 +- pcsx2/x86/newVif_Dynarec.cpp | 11 +++-------- pcsx2/x86/newVif_Unpack.cpp | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pcsx2/x86/newVif.h b/pcsx2/x86/newVif.h index f78211e0d5..830aa7708d 100644 --- a/pcsx2/x86/newVif.h +++ b/pcsx2/x86/newVif.h @@ -86,7 +86,7 @@ struct nVifStruct { RecompiledCodeReserve* recReserve; u8* recWritePtr; // current write pos into the reserve - HashBucket<_tParams>* vifBlocks; // Vif Blocks + HashBucket<_tParams> vifBlocks; // Vif Blocks nVifStruct(); }; diff --git a/pcsx2/x86/newVif_Dynarec.cpp b/pcsx2/x86/newVif_Dynarec.cpp index fbbcc5a4cd..4e06268a9c 100644 --- a/pcsx2/x86/newVif_Dynarec.cpp +++ b/pcsx2/x86/newVif_Dynarec.cpp @@ -23,7 +23,7 @@ #include "Utilities/Perf.h" static void recReset(int idx) { - nVif[idx].vifBlocks->clear(); + nVif[idx].vifBlocks.clear(); nVif[idx].recReserve->Reset(); @@ -40,17 +40,12 @@ void dVifReserve(int idx) { void dVifReset(int idx) { pxAssertDev(nVif[idx].recReserve, "Dynamic VIF recompiler reserve must be created prior to VIF use or reset!"); - if(!nVif[idx].vifBlocks) - nVif[idx].vifBlocks = new HashBucket<_tParams>(); - recReset(idx); } void dVifClose(int idx) { if (nVif[idx].recReserve) nVif[idx].recReserve->Reset(); - - safe_delete(nVif[idx].vifBlocks); } void dVifRelease(int idx) { @@ -303,7 +298,7 @@ _vifT static __ri void dVifExecuteUnpack(const u8* data, uptr x86, bool isFill) _vifT __fi uptr dVifCompile(nVifBlock& key) { nVifStruct& v = nVif[idx]; - nVifBlock* block = v.vifBlocks->find(&key); + nVifBlock* block = v.vifBlocks.find(&key); // Cache hit if (likely(block != nullptr)) @@ -321,7 +316,7 @@ _vifT __fi uptr dVifCompile(nVifBlock& key) { xSetPtr(v.recWritePtr); key.startPtr = (uptr)xGetAlignedCallTarget(); - v.vifBlocks->add(key); + v.vifBlocks.add(key); VifUnpackSSE_Dynarec(v, key).CompileRoutine(); diff --git a/pcsx2/x86/newVif_Unpack.cpp b/pcsx2/x86/newVif_Unpack.cpp index 78f8006306..3fae1bea01 100644 --- a/pcsx2/x86/newVif_Unpack.cpp +++ b/pcsx2/x86/newVif_Unpack.cpp @@ -73,7 +73,6 @@ static const __aligned16 Fnptr_VifUnpackLoop UnpackLoopTable[2][2][2] = { nVifStruct::nVifStruct() { - vifBlocks = NULL; } void reserveNewVif(int idx)