backend/arm64: Invalidation fixes

This commit is contained in:
Merry 2022-07-24 13:49:01 +01:00 committed by merry
parent eaf87ec1e4
commit 6885f9a6d8
2 changed files with 21 additions and 6 deletions

View file

@ -113,6 +113,8 @@ void A32AddressSpace::EmitPrelude() {
prelude_info.write_memory_64 = EmitCallTrampoline<&A32::UserCallbacks::MemoryWrite64>(code, conf.callbacks); prelude_info.write_memory_64 = EmitCallTrampoline<&A32::UserCallbacks::MemoryWrite64>(code, conf.callbacks);
prelude_info.end_of_prelude = code.ptr<u32*>(); prelude_info.end_of_prelude = code.ptr<u32*>();
mem.invalidate_all();
} }
size_t A32AddressSpace::GetRemainingSize() { size_t A32AddressSpace::GetRemainingSize() {
@ -132,6 +134,8 @@ EmittedBlockInfo A32AddressSpace::Emit(IR::Block block) {
}); });
Link(block_info); Link(block_info);
mem.invalidate(reinterpret_cast<u32*>(block_info.entry_point), block_info.size);
mem.protect(); mem.protect();
return block_info; return block_info;

View file

@ -56,6 +56,8 @@ struct Jit::Impl final {
HaltReason Run() { HaltReason Run() {
ASSERT(!jit_interface->is_executing); ASSERT(!jit_interface->is_executing);
PerformRequestedCacheInvalidation();
jit_interface->is_executing = true; jit_interface->is_executing = true;
SCOPE_EXIT { SCOPE_EXIT {
jit_interface->is_executing = false; jit_interface->is_executing = false;
@ -63,13 +65,15 @@ struct Jit::Impl final {
HaltReason hr = core.Run(current_address_space, current_state, &halt_reason); HaltReason hr = core.Run(current_address_space, current_state, &halt_reason);
RequestCacheInvalidation(); PerformRequestedCacheInvalidation();
return hr; return hr;
} }
HaltReason Step() { HaltReason Step() {
ASSERT(!jit_interface->is_executing); ASSERT(!jit_interface->is_executing);
PerformRequestedCacheInvalidation();
jit_interface->is_executing = true; jit_interface->is_executing = true;
SCOPE_EXIT { SCOPE_EXIT {
jit_interface->is_executing = false; jit_interface->is_executing = false;
@ -77,7 +81,7 @@ struct Jit::Impl final {
ASSERT_FALSE("Unimplemented"); ASSERT_FALSE("Unimplemented");
RequestCacheInvalidation(); PerformRequestedCacheInvalidation();
return HaltReason{}; return HaltReason{};
} }
@ -161,11 +165,18 @@ struct Jit::Impl final {
} }
private: private:
void RequestCacheInvalidation() { void PerformRequestedCacheInvalidation() {
// ASSERT_FALSE("Unimplemented"); if (invalidate_entire_cache) {
current_address_space.ClearCache();
invalidate_entire_cache = false; invalidate_entire_cache = false;
invalid_cache_ranges.clear(); invalid_cache_ranges.clear();
return;
}
if (!invalid_cache_ranges.empty()) {
ASSERT_FALSE("Unimplemented");
}
} }
Jit* jit_interface; Jit* jit_interface;