mirror of
https://github.com/citra-mirror/citra.git
synced 2024-08-20 02:13:23 +02:00
dyncom: Use unordered_map rather than the terrible 2-level bb_map
Seems (probably just placebo/wishful thinking) to make it slightly faster. Also reduces memory usage and makes shutdown when debugging from MSVC fast.
This commit is contained in:
parent
83c3d37cd0
commit
4a68e91a62
@ -26,7 +26,7 @@
|
|||||||
#define CITRA_IGNORE_EXIT(x)
|
#define CITRA_IGNORE_EXIT(x)
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@ -3309,9 +3309,8 @@ const transop_fp_t arm_instruction_trans[] = {
|
|||||||
INTERPRETER_TRANSLATE(blx_1_thumb)
|
INTERPRETER_TRANSLATE(blx_1_thumb)
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef map<unsigned int, int> bb_map;
|
typedef std::unordered_map<u32, int> bb_map;
|
||||||
bb_map CreamCache[65536];
|
bb_map CreamCache;
|
||||||
bb_map ProfileCache[65536];
|
|
||||||
|
|
||||||
//#define USE_DUMMY_CACHE
|
//#define USE_DUMMY_CACHE
|
||||||
|
|
||||||
@ -3319,14 +3318,12 @@ bb_map ProfileCache[65536];
|
|||||||
unsigned int DummyCache[0x100000];
|
unsigned int DummyCache[0x100000];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HASH(x) ((x + (x << 3) + (x >> 6)) % 65536)
|
|
||||||
void insert_bb(unsigned int addr, int start)
|
void insert_bb(unsigned int addr, int start)
|
||||||
{
|
{
|
||||||
#ifdef USE_DUMMY_CACHE
|
#ifdef USE_DUMMY_CACHE
|
||||||
DummyCache[addr] = start;
|
DummyCache[addr] = start;
|
||||||
#else
|
#else
|
||||||
// CreamCache[addr] = start;
|
CreamCache[addr] = start;
|
||||||
CreamCache[HASH(addr)][addr] = start;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3341,8 +3338,8 @@ int find_bb(unsigned int addr, int &start)
|
|||||||
} else
|
} else
|
||||||
ret = -1;
|
ret = -1;
|
||||||
#else
|
#else
|
||||||
bb_map::const_iterator it = CreamCache[HASH(addr)].find(addr);
|
bb_map::const_iterator it = CreamCache.find(addr);
|
||||||
if (it != CreamCache[HASH(addr)].end()) {
|
if (it != CreamCache.end()) {
|
||||||
start = static_cast<int>(it->second);
|
start = static_cast<int>(it->second);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
#if HYBRID_MODE
|
#if HYBRID_MODE
|
||||||
@ -3473,31 +3470,16 @@ void flush_bb(uint32_t addr)
|
|||||||
uint32_t start;
|
uint32_t start;
|
||||||
|
|
||||||
addr &= 0xfffff000;
|
addr &= 0xfffff000;
|
||||||
for (int i = 0; i < 65536; i ++) {
|
for (it = CreamCache.begin(); it != CreamCache.end(); ) {
|
||||||
for (it = CreamCache[i].begin(); it != CreamCache[i].end(); ) {
|
|
||||||
start = static_cast<uint32_t>(it->first);
|
start = static_cast<uint32_t>(it->first);
|
||||||
//start = (start >> 12) << 12;
|
//start = (start >> 12) << 12;
|
||||||
start &= 0xfffff000;
|
start &= 0xfffff000;
|
||||||
if (start == addr) {
|
if (start == addr) {
|
||||||
//DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first));
|
//DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first));
|
||||||
CreamCache[i].erase(it ++);
|
CreamCache.erase(it++);
|
||||||
} else
|
} else
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 65536; i ++) {
|
|
||||||
for (it = ProfileCache[i].begin(); it != ProfileCache[i].end(); ) {
|
|
||||||
start = static_cast<uint32_t>(it->first);
|
|
||||||
//start = (start >> 12) << 12;
|
|
||||||
start &= 0xfffff000;
|
|
||||||
if (start == addr) {
|
|
||||||
//DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first));
|
|
||||||
ProfileCache[i].erase(it ++);
|
|
||||||
} else
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//DEBUG_LOG(ARM11, "flush bb @ %x\n", addr);
|
//DEBUG_LOG(ARM11, "flush bb @ %x\n", addr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user