mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
jit: Use a hash for invalidate/clear all.
This should make sceKernelICacheClearAll() more useful.
This commit is contained in:
parent
293b5c0cf9
commit
00f9707399
@ -19,7 +19,9 @@
|
||||
#include <cstddef>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ext/xxhash.h"
|
||||
#include "Common.h"
|
||||
#include "Common/Profiler/Profiler.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Common/CommonWindows.h"
|
||||
@ -59,6 +61,15 @@ op_agent_t agent;
|
||||
|
||||
const u32 INVALID_EXIT = 0xFFFFFFFF;
|
||||
|
||||
static uint64_t HashJitBlock(const JitBlock &b) {
|
||||
PROFILE_THIS_SCOPE("jithash");
|
||||
if (JIT_USE_COMPILEDHASH) {
|
||||
// Includes the emuhack (or emuhacks) in memory.
|
||||
return XXH3_64bits(Memory::GetPointer(b.originalAddress), b.originalSize * 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
JitBlockCache::JitBlockCache(MIPSState *mipsState, CodeBlockCommon *codeBlock) :
|
||||
codeBlock_(codeBlock), blocks_(nullptr), num_blocks_(0) {
|
||||
}
|
||||
@ -234,6 +245,9 @@ void JitBlockCache::FinalizeBlock(int block_num, bool block_link) {
|
||||
MIPSOpcode opcode = GetEmuHackOpForBlock(block_num);
|
||||
Memory::Write_Opcode_JIT(b.originalAddress, opcode);
|
||||
|
||||
// Note that this hashes the emuhack too, which is intentional.
|
||||
b.compiledHash = HashJitBlock(b);
|
||||
|
||||
AddBlockMap(block_num);
|
||||
|
||||
if (block_link) {
|
||||
@ -592,8 +606,15 @@ void JitBlockCache::InvalidateChangedBlocks() {
|
||||
if (b.invalid || b.IsPureProxy())
|
||||
continue;
|
||||
|
||||
const u32 emuhack = GetEmuHackOpForBlock(block_num).encoding;
|
||||
if (Memory::ReadUnchecked_U32(b.originalAddress) != emuhack) {
|
||||
bool changed = false;
|
||||
if (JIT_USE_COMPILEDHASH) {
|
||||
changed = b.compiledHash != HashJitBlock(b);
|
||||
} else {
|
||||
const u32 emuhack = GetEmuHackOpForBlock(block_num).encoding;
|
||||
changed = Memory::ReadUnchecked_U32(b.originalAddress) != emuhack;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
DEBUG_LOG(JIT, "Invalidating changed block at %08x", b.originalAddress);
|
||||
DestroyBlock(block_num, DestroyType::INVALIDATE);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@ -33,6 +34,7 @@ const int MAX_JIT_BLOCK_EXITS = 2;
|
||||
#else
|
||||
const int MAX_JIT_BLOCK_EXITS = 8;
|
||||
#endif
|
||||
constexpr bool JIT_USE_COMPILEDHASH = true;
|
||||
|
||||
struct BlockCacheStats {
|
||||
int numBlocks;
|
||||
@ -68,6 +70,7 @@ struct JitBlock {
|
||||
|
||||
u32 originalAddress;
|
||||
MIPSOpcode originalFirstOpcode; //to be able to restore
|
||||
uint64_t compiledHash;
|
||||
u16 codeSize;
|
||||
u16 originalSize;
|
||||
u16 blockNum;
|
||||
|
Loading…
Reference in New Issue
Block a user