CPU/Recompiler/AArch64: Fix crash when icache is enabled

This commit is contained in:
Connor McLaughlin 2020-10-11 15:04:49 +10:00
parent 2ce9baa8ad
commit 36bede11ae
1 changed files with 6 additions and 3 deletions

View File

@ -35,8 +35,9 @@ void CodeGenerator::EmitICacheCheckAndUpdate()
LabelType is_cached;
LabelType ready_to_execute;
EmitConditionalBranch(Condition::LessEqual, false, temp.GetHostRegister(), Value::FromConstantU32(4), &is_cached);
EmitAddCPUStructField(offsetof(State, pending_ticks),
Value::FromConstantU32(static_cast<u32>(m_block->uncached_fetch_ticks)));
EmitLoadCPUStructField(temp.host_reg, RegSize_32, offsetof(State, pending_ticks));
EmitAdd(temp.host_reg, temp.host_reg, Value::FromConstantU32(static_cast<u32>(m_block->uncached_fetch_ticks)), false);
EmitStoreCPUStructField(offsetof(State, pending_ticks), temp);
EmitBranch(&ready_to_execute);
EmitBindLabel(&is_cached);
@ -55,8 +56,10 @@ void CodeGenerator::EmitICacheCheckAndUpdate()
EmitLoadCPUStructField(temp.GetHostRegister(), RegSize_32, offset);
EmitConditionalBranch(Condition::Equal, false, temp.GetHostRegister(), pc, &cache_hit);
EmitAddCPUStructField(offsetof(State, pending_ticks), Value::FromConstantU32(static_cast<u32>(fill_ticks)));
EmitLoadCPUStructField(temp.host_reg, RegSize_32, offsetof(State, pending_ticks));
EmitStoreCPUStructField(offset, pc);
EmitAdd(temp.host_reg, temp.host_reg, Value::FromConstantU32(static_cast<u32>(fill_ticks)), false);
EmitStoreCPUStructField(offsetof(State, pending_ticks), temp);
EmitBindLabel(&cache_hit);
EmitAdd(pc.GetHostRegister(), pc.GetHostRegister(), Value::FromConstantU32(ICACHE_LINE_SIZE), false);
}