mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 01:29:41 +01:00
SaveState: Only rehash functions in code a load changed
Every load hashed all known functions again, for the replacement hooks: 2.4-6 ms, about half the load. Functions in module code the load left as it was keep their hash, so only the rest is hashed now (0.5-1 ms). The code is compared on every load for this, not only with a JIT. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a62aa69986
commit
f45f4d5c85
5 files changed
+43
-8
No files matched your search
@@ -909,7 +909,22 @@ namespace MIPSAnalyst {
|
||||
return DetermineRegisterUsage(reg, addr, instrs) == USAGE_CLOBBERED;
|
||||
}
|
||||
|
||||
void HashFunctions() {
|
||||
// Ranges are (address, size), sorted by address and not overlapping.
|
||||
static bool InsideRanges(const std::vector<std::pair<u32, u32>> &ranges, u32 start, u32 end) {
|
||||
start &= 0x3FFFFFFF;
|
||||
end &= 0x3FFFFFFF;
|
||||
auto iter = std::upper_bound(ranges.begin(), ranges.end(), start, [](u32 address, const std::pair<u32, u32> &range) {
|
||||
return address < (range.first & 0x3FFFFFFF);
|
||||
});
|
||||
if (iter == ranges.begin()) {
|
||||
return false;
|
||||
}
|
||||
--iter;
|
||||
const u32 rangeStart = iter->first & 0x3FFFFFFF;
|
||||
return start >= rangeStart && end <= rangeStart + iter->second;
|
||||
}
|
||||
|
||||
static void HashFunctions(const std::vector<std::pair<u32, u32>> &unchanged = {}) {
|
||||
std::lock_guard<std::recursive_mutex> guard(functions_lock);
|
||||
std::vector<u32> buffer;
|
||||
|
||||
@@ -918,6 +933,10 @@ namespace MIPSAnalyst {
|
||||
if (!Memory::IsValidRange(f.start, f.end - f.start + 4)) {
|
||||
continue;
|
||||
}
|
||||
// end is the last instruction.
|
||||
if (f.hasHash && InsideRanges(unchanged, f.start, f.end + 4)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Immediates are masked out, so relocations don't change the hash.
|
||||
buffer.resize((f.end - f.start + 4) / 4);
|
||||
@@ -1311,9 +1330,11 @@ namespace MIPSAnalyst {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RehashFunctions() {
|
||||
void RehashFunctions(const std::vector<std::pair<u32, u32>> &unchanged) {
|
||||
std::vector<std::pair<u32, u32>> sorted = unchanged;
|
||||
std::sort(sorted.begin(), sorted.end());
|
||||
std::lock_guard<std::recursive_mutex> guard(functions_lock);
|
||||
HashFunctions();
|
||||
HashFunctions(sorted);
|
||||
UpdateHashToFunctionMap();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user