More replacement-related renames

This commit is contained in:
Nemoumbra committed 2026-11-07 18:37:03 +03:00
1 parent 7ab6f32052
commit e63d608cb0
5 files changed
+18 -18

No files matched your search

+9 -9
View File
@@ -2303,7 +2303,7 @@ void Replacement_Init() {
}
void Replacement_Shutdown() {
RestoreReplacedInstructions(0, 0xFFFFFFFF);
RemoveReplacements(0, 0xFFFFFFFF);
replacementNameLookup.clear();
syphonFilterArrivals.clear();
syphonFilterFadeHolds.clear();
@@ -2353,7 +2353,7 @@ const ReplacementTableEntry *GetReplacementFunc(size_t i) {
return &entries[i];
}
static bool WriteReplaceInstruction(u32 address, int index, u32 funcStart, u32 funcSize, u64 funcHash) {
static bool InstallReplacement(u32 address, int index, u32 funcStart, u32 funcSize, u64 funcHash) {
if (!Memory::IsValid4AlignedAddress(address)) {
return false;
}
@@ -2375,7 +2375,7 @@ static bool WriteReplaceInstruction(u32 address, int index, u32 funcStart, u32 f
return true;
}
void WriteReplaceInstructions(u32 address, u64 hash, int size) {
void InstallReplacements(u32 address, u64 hash, int size) {
std::vector<int> indexes = GetReplacementFuncIndexes(hash, size);
const u64 funcHash = indexes.empty() ? 0 : HashReplacedFunc(address, size);
for (int index : indexes) {
@@ -2386,17 +2386,17 @@ void WriteReplaceInstructions(u32 address, u64 hash, int size) {
for (u32 offset = 0; offset < (u32)size; offset += 4) {
const u32 op = Memory::Read_Instruction(address + offset).encoding;
if (op == MIPS_MAKE_JR_RA()) {
if (WriteReplaceInstruction(address + offset, index, address, size, funcHash)) {
if (InstallReplacement(address + offset, index, address, size, funcHash)) {
didReplace = true;
}
}
}
} else if (entry->flags & REPFLAG_HOOK) {
if (WriteReplaceInstruction(address + entry->hookOffset, index, address, size, funcHash)) {
if (InstallReplacement(address + entry->hookOffset, index, address, size, funcHash)) {
didReplace = true;
}
} else {
if (WriteReplaceInstruction(address, index, address, size, funcHash)) {
if (InstallReplacement(address, index, address, size, funcHash)) {
didReplace = true;
}
}
@@ -2407,7 +2407,7 @@ void WriteReplaceInstructions(u32 address, u64 hash, int size) {
}
}
void RestoreReplacedInstruction(u32 address) {
void RemoveReplacement(u32 address) {
const u32 key = address & Memory::BLOCK_SHADOW_MASK;
auto iter = installedReplacements.find(key);
if (iter != installedReplacements.end()) {
@@ -2450,7 +2450,7 @@ void Replacement_RepairStaleHookOps(const std::vector<std::pair<u32, u32>> &hook
}
}
void RestoreReplacedInstructions(u32 startAddr, u32 endAddr) {
void RemoveReplacements(u32 startAddr, u32 endAddr) {
if (endAddr == startAddr)
return;
// Need to be in order, or we'll hang.
@@ -2480,7 +2480,7 @@ void RestoreReplacedInstructions(u32 startAddr, u32 endAddr) {
INFO_LOG(Log::HLE, "Restored %d replaced funcs between %08x-%08x", (int)restored.size(), startAddr, endAddr);
}
void Replacement_CheckRange(u32 address, u32 length) {
void RemoveModifiedReplacementsInRange(u32 address, u32 length) {
const u32 start = address & Memory::BLOCK_SHADOW_MASK;
const u32 end = length >= Memory::BLOCK_SHADOW_MASK ? Memory::BLOCK_SHADOW_MASK : start + length;
std::vector<u32> dropped;
+4 -4
View File
@@ -79,9 +79,9 @@ const ReplacementTableEntry *GetReplacementFunc(size_t index);
// entry: the JIT's block there, or the hook value if there's none. The CPU cores look up every
// instruction with a nonzero entry when they run or compile it, and substitute the CallRepl
// pseudo-op.
void WriteReplaceInstructions(u32 address, u64 hash, int size);
void RestoreReplacedInstruction(u32 address);
void RestoreReplacedInstructions(u32 startAddr, u32 endAddr);
void InstallReplacements(u32 address, u64 hash, int size);
void RemoveReplacement(u32 address);
void RemoveReplacements(u32 startAddr, u32 endAddr);
// The address and original instruction of every installed hook.
std::vector<std::pair<u32, u32>> Replacement_GetHookedOps();
// Some old savestates have hook ops in memory, which the CPU would now take as illegal and which
@@ -89,7 +89,7 @@ std::vector<std::pair<u32, u32>> Replacement_GetHookedOps();
// session hooked at the same addresses (booting the game hooked the same module there).
void Replacement_RepairStaleHookOps(const std::vector<std::pair<u32, u32>> &hookedOps);
// Drops hooks in functions the game has changed. Called when the icache is invalidated over them.
void Replacement_CheckRange(u32 address, u32 length);
void RemoveModifiedReplacementsInRange(u32 address, u32 length);
// The JIT's hook value, which its dispatcher sends to the compiler. Rewrites the hooks' entries.
void Replacement_SetBlockShadowHook(u32 value);
+2 -2
View File
@@ -552,7 +552,7 @@ void MIPSState::InvalidateICacheRangeImmediate(u32 address, u32 length) {
me->InvalidateICacheRangeDeferred(address, length);
}
if (!IsMediaEngine()) {
Replacement_CheckRange(address, length);
RemoveModifiedReplacementsInRange(address, length);
}
if (!jit) {
// Nothing to do.
@@ -573,7 +573,7 @@ void MIPSState::ProcessPendingInvalidates() {
pending.swap(pendingInvalidates_);
for (const auto &p : pending) {
if (!IsMediaEngine())
Replacement_CheckRange(p.addr, p.size);
RemoveModifiedReplacementsInRange(p.addr, p.size);
if (jit && !all) {
jit->InvalidateCacheAt(p.addr, p.size);
}
+2 -2
View File
@@ -1309,7 +1309,7 @@ namespace MIPSAnalyst {
functions.erase(prevMatch, functions.end());
}
RestoreReplacedInstructions(startAddr, endAddr);
RemoveReplacements(startAddr, endAddr);
if (functions.empty()) {
hashToFunction.clear();
@@ -1386,7 +1386,7 @@ namespace MIPSAnalyst {
std::lock_guard<std::recursive_mutex> guard(functions_lock);
for (size_t i = 0; i < functions.size(); i++) {
WriteReplaceInstructions(functions[i].start, functions[i].hash, functions[i].size);
InstallReplacements(functions[i].start, functions[i].hash, functions[i].size);
}
}
+1 -1
View File
@@ -293,7 +293,7 @@ int g_screenshotFailures;
if (p.mode == p.MODE_READ) {
g_loadCount++;
hookedOps = Replacement_GetHookedOps();
RestoreReplacedInstructions(0, 0xFFFFFFFF);
RemoveReplacements(0, 0xFFFFFFFF);
codeCompare.ranges = __KernelModuleCodeRanges();
}
Memory::DoState(p, &codeCompare);