JIT: Consider the block cache full a few block before it is, to allow space for proxy blocks.

Should fix the following crash:

Core/MIPS/JitCommon/JitBlockCache.cpp:190

JitBlock &b = blocks_[num_blocks_];
This commit is contained in:
Henrik Rydgård 2023-05-02 21:52:43 +02:00
parent eee4640962
commit 1a2d599942
2 changed files with 5 additions and 4 deletions

View file

@ -76,7 +76,7 @@ static uint64_t HashJitBlock(const JitBlock &b) {
}
JitBlockCache::JitBlockCache(MIPSState *mipsState, CodeBlockCommon *codeBlock) :
codeBlock_(codeBlock), blocks_(nullptr), num_blocks_(0) {
codeBlock_(codeBlock) {
}
JitBlockCache::~JitBlockCache() {
@ -90,7 +90,8 @@ bool JitBlock::ContainsAddress(u32 em_address) {
}
bool JitBlockCache::IsFull() const {
return num_blocks_ >= MAX_NUM_BLOCKS - 1;
// -10 to safely leave space for some proxy blocks, which we don't check before we allocate (not ideal, but should work).
return num_blocks_ >= MAX_NUM_BLOCKS - 10;
}
void JitBlockCache::Init() {

View file

@ -184,10 +184,10 @@ private:
MIPSOpcode GetEmuHackOpForBlock(int block_num) const;
CodeBlockCommon *codeBlock_;
JitBlock *blocks_;
JitBlock *blocks_ = nullptr;
std::unordered_multimap<u32, int> proxyBlockMap_;
int num_blocks_;
int num_blocks_ = 0;
std::unordered_multimap<u32, int> links_to_;
std::map<std::pair<u32,u32>, u32> block_map_; // (end_addr, start_addr) -> number