mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Debugger: Speed up GetFunctionSize().
Tested games with lots of functions, it's just never worth generating the full active symbols. Direct lookup saves 0.005s startup on desktop in a typical game.
This commit is contained in:
parent
676ed6c15d
commit
e2425a1e00
1 changed files with 27 additions and 3 deletions
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
|
@ -619,8 +620,31 @@ u32 SymbolMap::FindPossibleFunctionAtAfter(u32 address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 SymbolMap::GetFunctionSize(u32 startAddress) {
|
u32 SymbolMap::GetFunctionSize(u32 startAddress) {
|
||||||
if (activeNeedUpdate_)
|
if (activeNeedUpdate_) {
|
||||||
UpdateActiveSymbols();
|
std::lock_guard<std::recursive_mutex> guard(lock_);
|
||||||
|
|
||||||
|
// This is common, from the jit. Direct lookup is faster than updating active symbols.
|
||||||
|
auto mod = activeModuleEnds.lower_bound(startAddress);
|
||||||
|
std::pair<int, u32> funcKey;
|
||||||
|
if (mod == activeModuleEnds.end()) {
|
||||||
|
// Could still be mod 0, backwards compatibility.
|
||||||
|
if (!sawUnknownModule)
|
||||||
|
return INVALID_ADDRESS;
|
||||||
|
funcKey.first = 0;
|
||||||
|
funcKey.second = startAddress;
|
||||||
|
} else {
|
||||||
|
if (mod->second.start > startAddress)
|
||||||
|
return INVALID_ADDRESS;
|
||||||
|
funcKey.first = mod->second.index;
|
||||||
|
funcKey.second = startAddress - mod->second.start;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto func = functions.find(funcKey);
|
||||||
|
if (func == functions.end())
|
||||||
|
return INVALID_ADDRESS;
|
||||||
|
|
||||||
|
return func->second.size;
|
||||||
|
}
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> guard(lock_);
|
std::lock_guard<std::recursive_mutex> guard(lock_);
|
||||||
auto it = activeFunctions.find(startAddress);
|
auto it = activeFunctions.find(startAddress);
|
||||||
|
@ -684,7 +708,7 @@ void SymbolMap::UpdateActiveSymbols() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, u32> activeModuleIndexes;
|
std::unordered_map<int, u32> activeModuleIndexes;
|
||||||
for (auto it = activeModuleEnds.begin(), end = activeModuleEnds.end(); it != end; ++it) {
|
for (auto it = activeModuleEnds.begin(), end = activeModuleEnds.end(); it != end; ++it) {
|
||||||
activeModuleIndexes[it->second.index] = it->second.start;
|
activeModuleIndexes[it->second.index] = it->second.start;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue