Skip to content

Commit

Permalink
sh2: fix recompiler regressions (#1760)
Browse files Browse the repository at this point in the history
This change corrects two regressions introduced by my last change.

1. The purge() call in SH2::Cache::power() was, through a call to
Recompiler::invalidate(), accessing the pool array before it was
allocated.

    This purge call was erronous for two reasons:
    -   It was purging a single line, though it *appears* the intent was
        to purge the entire cache.
    -   According to the SH7604 manual, the cache is not initialized on
        reset.

    Therefore, I simply removed the call.

2. The size of the recompiler code cache for both of the two SH2s is now
halved to fit within the recently halved fixed code cache buffer. The
SH2 recompiler is good at reusing previously compiled blocks, so flushes
should not be especially common even with this reduced capacity.
  • Loading branch information
invertego authored Jan 11, 2025
1 parent 331c495 commit 05898a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ares/component/processor/sh2/sh2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ auto SH2::power(bool reset) -> void {

if constexpr(Accuracy::Recompiler) {
if(!reset) {
auto buffer = ares::Memory::FixedAllocator::get().tryAcquire(64_MiB);
recompiler.allocator.resize(64_MiB, bump_allocator::executable, buffer);
auto buffer = ares::Memory::FixedAllocator::get().tryAcquire(32_MiB);
recompiler.allocator.resize(32_MiB, bump_allocator::executable, buffer);
}
recompiler.reset();
}
Expand Down
2 changes: 0 additions & 2 deletions ares/component/processor/sh2/sh7604/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ auto SH2::Cache::purge() -> void {
}

auto SH2::Cache::power() -> void {
purge(4 * 256);

for(n6 n : range(64)) {
if(n.bit(5) == 1 && n.bit(4) == 1 && n.bit(3) == 1) { lruSelect[n] = 0; continue; }
if(n.bit(5) == 0 && n.bit(2) == 1 && n.bit(1) == 1) { lruSelect[n] = 1; continue; }
Expand Down

0 comments on commit 05898a6

Please sign in to comment.