summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2014-11-29 17:42:39 -0200
committerGravatar Yuri Kunde Schlesner2014-11-29 17:42:39 -0200
commit4a68e91a6291b13b31156948d5189955b698b63b (patch)
treec5195d6b168ef794b47882f09c2fce2e686b32f9 /src
parentMerge pull request #227 from vaguilar/fix-warnings (diff)
downloadyuzu-4a68e91a6291b13b31156948d5189955b698b63b.tar.gz
yuzu-4a68e91a6291b13b31156948d5189955b698b63b.tar.xz
yuzu-4a68e91a6291b13b31156948d5189955b698b63b.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/core/arm/dyncom/arm_dyncom_interpreter.cpp48
1 files changed, 15 insertions, 33 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
index f899e2e8a..04d534723 100644
--- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
+++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp
@@ -26,7 +26,7 @@
26#define CITRA_IGNORE_EXIT(x) 26#define CITRA_IGNORE_EXIT(x)
27 27
28#include <algorithm> 28#include <algorithm>
29#include <map> 29#include <unordered_map>
30#include <stdio.h> 30#include <stdio.h>
31#include <assert.h> 31#include <assert.h>
32#include <cstdio> 32#include <cstdio>
@@ -3309,9 +3309,8 @@ const transop_fp_t arm_instruction_trans[] = {
3309 INTERPRETER_TRANSLATE(blx_1_thumb) 3309 INTERPRETER_TRANSLATE(blx_1_thumb)
3310}; 3310};
3311 3311
3312typedef map<unsigned int, int> bb_map; 3312typedef std::unordered_map<u32, int> bb_map;
3313bb_map CreamCache[65536]; 3313bb_map CreamCache;
3314bb_map ProfileCache[65536];
3315 3314
3316//#define USE_DUMMY_CACHE 3315//#define USE_DUMMY_CACHE
3317 3316
@@ -3319,14 +3318,12 @@ bb_map ProfileCache[65536];
3319unsigned int DummyCache[0x100000]; 3318unsigned int DummyCache[0x100000];
3320#endif 3319#endif
3321 3320
3322#define HASH(x) ((x + (x << 3) + (x >> 6)) % 65536)
3323void insert_bb(unsigned int addr, int start) 3321void insert_bb(unsigned int addr, int start)
3324{ 3322{
3325#ifdef USE_DUMMY_CACHE 3323#ifdef USE_DUMMY_CACHE
3326 DummyCache[addr] = start; 3324 DummyCache[addr] = start;
3327#else 3325#else
3328// CreamCache[addr] = start; 3326 CreamCache[addr] = start;
3329 CreamCache[HASH(addr)][addr] = start;
3330#endif 3327#endif
3331} 3328}
3332 3329
@@ -3341,8 +3338,8 @@ int find_bb(unsigned int addr, int &start)
3341 } else 3338 } else
3342 ret = -1; 3339 ret = -1;
3343#else 3340#else
3344 bb_map::const_iterator it = CreamCache[HASH(addr)].find(addr); 3341 bb_map::const_iterator it = CreamCache.find(addr);
3345 if (it != CreamCache[HASH(addr)].end()) { 3342 if (it != CreamCache.end()) {
3346 start = static_cast<int>(it->second); 3343 start = static_cast<int>(it->second);
3347 ret = 0; 3344 ret = 0;
3348#if HYBRID_MODE 3345#if HYBRID_MODE
@@ -3473,30 +3470,15 @@ void flush_bb(uint32_t addr)
3473 uint32_t start; 3470 uint32_t start;
3474 3471
3475 addr &= 0xfffff000; 3472 addr &= 0xfffff000;
3476 for (int i = 0; i < 65536; i ++) { 3473 for (it = CreamCache.begin(); it != CreamCache.end(); ) {
3477 for (it = CreamCache[i].begin(); it != CreamCache[i].end(); ) { 3474 start = static_cast<uint32_t>(it->first);
3478 start = static_cast<uint32_t>(it->first); 3475 //start = (start >> 12) << 12;
3479 //start = (start >> 12) << 12; 3476 start &= 0xfffff000;
3480 start &= 0xfffff000; 3477 if (start == addr) {
3481 if (start == addr) { 3478 //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first));
3482 //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first)); 3479 CreamCache.erase(it++);
3483 CreamCache[i].erase(it ++); 3480 } else
3484 } else 3481 ++it;
3485 ++it;
3486 }
3487 }
3488
3489 for (int i = 0; i < 65536; i ++) {
3490 for (it = ProfileCache[i].begin(); it != ProfileCache[i].end(); ) {
3491 start = static_cast<uint32_t>(it->first);
3492 //start = (start >> 12) << 12;
3493 start &= 0xfffff000;
3494 if (start == addr) {
3495 //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first));
3496 ProfileCache[i].erase(it ++);
3497 } else
3498 ++it;
3499 }
3500 } 3482 }
3501 3483
3502 //DEBUG_LOG(ARM11, "flush bb @ %x\n", addr); 3484 //DEBUG_LOG(ARM11, "flush bb @ %x\n", addr);