diff options
| author | 2014-11-30 08:35:03 -0500 | |
|---|---|---|
| committer | 2014-11-30 08:35:03 -0500 | |
| commit | 13005d54aad06beabe66d8abfce76a96dfd6ae65 (patch) | |
| tree | 27278954457981ea89b067c25bc1c76fc09a6f88 | |
| parent | Merge pull request #234 from lioncash/unused (diff) | |
| parent | dyncom: Use unordered_map rather than the terrible 2-level bb_map (diff) | |
| download | yuzu-13005d54aad06beabe66d8abfce76a96dfd6ae65.tar.gz yuzu-13005d54aad06beabe66d8abfce76a96dfd6ae65.tar.xz yuzu-13005d54aad06beabe66d8abfce76a96dfd6ae65.zip | |
Merge pull request #235 from yuriks/dyncom-map
dyncom: Use unordered_map rather than the terrible 2-level bb_map
Diffstat (limited to '')
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 48 |
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 aa2b271e7..233cd3e3a 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> |
| @@ -3307,9 +3307,8 @@ const transop_fp_t arm_instruction_trans[] = { | |||
| 3307 | INTERPRETER_TRANSLATE(blx_1_thumb) | 3307 | INTERPRETER_TRANSLATE(blx_1_thumb) |
| 3308 | }; | 3308 | }; |
| 3309 | 3309 | ||
| 3310 | typedef map<unsigned int, int> bb_map; | 3310 | typedef std::unordered_map<u32, int> bb_map; |
| 3311 | bb_map CreamCache[65536]; | 3311 | bb_map CreamCache; |
| 3312 | bb_map ProfileCache[65536]; | ||
| 3313 | 3312 | ||
| 3314 | //#define USE_DUMMY_CACHE | 3313 | //#define USE_DUMMY_CACHE |
| 3315 | 3314 | ||
| @@ -3317,14 +3316,12 @@ bb_map ProfileCache[65536]; | |||
| 3317 | unsigned int DummyCache[0x100000]; | 3316 | unsigned int DummyCache[0x100000]; |
| 3318 | #endif | 3317 | #endif |
| 3319 | 3318 | ||
| 3320 | #define HASH(x) ((x + (x << 3) + (x >> 6)) % 65536) | ||
| 3321 | void insert_bb(unsigned int addr, int start) | 3319 | void insert_bb(unsigned int addr, int start) |
| 3322 | { | 3320 | { |
| 3323 | #ifdef USE_DUMMY_CACHE | 3321 | #ifdef USE_DUMMY_CACHE |
| 3324 | DummyCache[addr] = start; | 3322 | DummyCache[addr] = start; |
| 3325 | #else | 3323 | #else |
| 3326 | // CreamCache[addr] = start; | 3324 | CreamCache[addr] = start; |
| 3327 | CreamCache[HASH(addr)][addr] = start; | ||
| 3328 | #endif | 3325 | #endif |
| 3329 | } | 3326 | } |
| 3330 | 3327 | ||
| @@ -3339,8 +3336,8 @@ int find_bb(unsigned int addr, int &start) | |||
| 3339 | } else | 3336 | } else |
| 3340 | ret = -1; | 3337 | ret = -1; |
| 3341 | #else | 3338 | #else |
| 3342 | bb_map::const_iterator it = CreamCache[HASH(addr)].find(addr); | 3339 | bb_map::const_iterator it = CreamCache.find(addr); |
| 3343 | if (it != CreamCache[HASH(addr)].end()) { | 3340 | if (it != CreamCache.end()) { |
| 3344 | start = static_cast<int>(it->second); | 3341 | start = static_cast<int>(it->second); |
| 3345 | ret = 0; | 3342 | ret = 0; |
| 3346 | #if HYBRID_MODE | 3343 | #if HYBRID_MODE |
| @@ -3471,30 +3468,15 @@ void flush_bb(uint32_t addr) | |||
| 3471 | uint32_t start; | 3468 | uint32_t start; |
| 3472 | 3469 | ||
| 3473 | addr &= 0xfffff000; | 3470 | addr &= 0xfffff000; |
| 3474 | for (int i = 0; i < 65536; i ++) { | 3471 | for (it = CreamCache.begin(); it != CreamCache.end(); ) { |
| 3475 | for (it = CreamCache[i].begin(); it != CreamCache[i].end(); ) { | 3472 | start = static_cast<uint32_t>(it->first); |
| 3476 | start = static_cast<uint32_t>(it->first); | 3473 | //start = (start >> 12) << 12; |
| 3477 | //start = (start >> 12) << 12; | 3474 | start &= 0xfffff000; |
| 3478 | start &= 0xfffff000; | 3475 | if (start == addr) { |
| 3479 | if (start == addr) { | 3476 | //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first)); |
| 3480 | //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first)); | 3477 | CreamCache.erase(it++); |
| 3481 | CreamCache[i].erase(it ++); | 3478 | } else |
| 3482 | } else | 3479 | ++it; |
| 3483 | ++it; | ||
| 3484 | } | ||
| 3485 | } | ||
| 3486 | |||
| 3487 | for (int i = 0; i < 65536; i ++) { | ||
| 3488 | for (it = ProfileCache[i].begin(); it != ProfileCache[i].end(); ) { | ||
| 3489 | start = static_cast<uint32_t>(it->first); | ||
| 3490 | //start = (start >> 12) << 12; | ||
| 3491 | start &= 0xfffff000; | ||
| 3492 | if (start == addr) { | ||
| 3493 | //DEBUG_LOG(ARM11, "[ERASE][0x%08x]\n", static_cast<int>(it->first)); | ||
| 3494 | ProfileCache[i].erase(it ++); | ||
| 3495 | } else | ||
| 3496 | ++it; | ||
| 3497 | } | ||
| 3498 | } | 3480 | } |
| 3499 | 3481 | ||
| 3500 | //DEBUG_LOG(ARM11, "flush bb @ %x\n", addr); | 3482 | //DEBUG_LOG(ARM11, "flush bb @ %x\n", addr); |