From c32173a6a744159f629cdbfbabace4f2061df4d1 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 1 Nov 2014 04:55:53 -0200 Subject: [PATCH] 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. --- .../arm/dyncom/arm_dyncom_interpreter.cpp | 76 +------------------ 1 file changed, 2 insertions(+), 74 deletions(-) diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index fe1501b59..b2442c622 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp @@ -3309,10 +3309,6 @@ const transop_fp_t arm_instruction_trans[] = { INTERPRETER_TRANSLATE(blx_1_thumb) }; -typedef map bb_map; -bb_map CreamCache[65536]; -bb_map ProfileCache[65536]; - //#define USE_DUMMY_CACHE #ifdef USE_DUMMY_CACHE @@ -3324,42 +3320,10 @@ void insert_bb(unsigned int addr, int start) { #ifdef USE_DUMMY_CACHE DummyCache[addr] = start; -#else -// CreamCache[addr] = start; - CreamCache[HASH(addr)][addr] = start; #endif } #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(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 { @@ -3467,41 +3431,6 @@ extern const ISEITEM arm_instruction[]; vector 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(it->first); - //start = (start >> 12) << 12; - start &= 0xfffff000; - if (start == addr) { - //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast(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(it->first); - //start = (start >> 12) << 12; - start &= 0xfffff000; - if (start == addr) { - //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast(it->first)); - ProfileCache[i].erase(it ++); - } else - ++it; - } - } - - //DEBUG_LOG(ARM11, "flush bb @ %x\n", addr); -} - //static uint32_t get_bank_addr(void *addr) //{ // uint64_t address = (uint64_t)addr; @@ -4165,9 +4094,8 @@ void InterpreterMainLoop(ARMul_State* state) #endif /* #if HYBRID_MODE */ #endif /* #if USER_MODE_OPT */ 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) - goto END; + if (InterpreterTranslate(cpu, ptr, cpu->Reg[15]) == FETCH_EXCEPTION) + goto END; } else{ if (InterpreterTranslate(cpu, ptr, cpu->Reg[15]) == FETCH_EXCEPTION)