dyncom: Remove two huge global arrays of std::map

Dyncom had two global array that together allocated 128K instances of
std::map during startup. They appear to be related to the dynamic
compilation support and thus are currently unused in Citra. If they need
to be reintroduced in the future, a more performant way of storing this
data should be used.

This removes a long (~12s) delay during process shutdown when using the
Windows Debug heap, as well as reducing memory usage by 8MB.
This commit is contained in:
Yuri Kunde Schlesner 2014-11-01 04:55:53 -02:00
parent d48f7ec7b4
commit c32173a6a7

View file

@ -3309,10 +3309,6 @@ const transop_fp_t arm_instruction_trans[] = {
INTERPRETER_TRANSLATE(blx_1_thumb) INTERPRETER_TRANSLATE(blx_1_thumb)
}; };
typedef map<unsigned int, int> bb_map;
bb_map CreamCache[65536];
bb_map ProfileCache[65536];
//#define USE_DUMMY_CACHE //#define USE_DUMMY_CACHE
#ifdef USE_DUMMY_CACHE #ifdef USE_DUMMY_CACHE
@ -3324,42 +3320,10 @@ void insert_bb(unsigned int addr, int start)
{ {
#ifdef USE_DUMMY_CACHE #ifdef USE_DUMMY_CACHE
DummyCache[addr] = start; DummyCache[addr] = start;
#else
// CreamCache[addr] = start;
CreamCache[HASH(addr)][addr] = start;
#endif #endif
} }
#define TRANS_THRESHOLD 65000 #define TRANS_THRESHOLD 65000
int find_bb(unsigned int addr, int &start)
{
int ret = -1;
#ifdef USE_DUMMY_CACHE
start = DummyCache[addr];
if (start) {
ret = 0;
} else
ret = -1;
#else
bb_map::const_iterator it = CreamCache[HASH(addr)].find(addr);
if (it != CreamCache[HASH(addr)].end()) {
start = static_cast<int>(it->second);
ret = 0;
#if HYBRID_MODE
#if PROFILE
#else
/* increase the bb counter */
if(get_bb_prof(cpu, addr, 1) == TRANS_THRESHOLD){
push_to_compiled(cpu, addr);
}
#endif
#endif
} else {
ret = -1;
}
#endif
return ret;
}
enum { enum {
@ -3467,41 +3431,6 @@ extern const ISEITEM arm_instruction[];
vector<uint64_t> code_page_set; vector<uint64_t> code_page_set;
void flush_bb(uint32_t addr)
{
bb_map::iterator it;
uint32_t start;
addr &= 0xfffff000;
for (int i = 0; i < 65536; i ++) {
for (it = CreamCache[i].begin(); it != CreamCache[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));
CreamCache[i].erase(it ++);
} else
++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);
}
//static uint32_t get_bank_addr(void *addr) //static uint32_t get_bank_addr(void *addr)
//{ //{
// uint64_t address = (uint64_t)addr; // uint64_t address = (uint64_t)addr;
@ -4165,7 +4094,6 @@ void InterpreterMainLoop(ARMul_State* state)
#endif /* #if HYBRID_MODE */ #endif /* #if HYBRID_MODE */
#endif /* #if USER_MODE_OPT */ #endif /* #if USER_MODE_OPT */
if (true){//if(is_fast_interp_code(core, phys_addr)){ if (true){//if(is_fast_interp_code(core, phys_addr)){
if (find_bb(phys_addr, ptr) == -1)
if (InterpreterTranslate(cpu, ptr, cpu->Reg[15]) == FETCH_EXCEPTION) if (InterpreterTranslate(cpu, ptr, cpu->Reg[15]) == FETCH_EXCEPTION)
goto END; goto END;
} }