Skip to content

Conversation

wheremyfoodat
Copy link
Collaborator

Fully flushes JIT cache when FlushCache is called. Should fix several games. Tested with Castlevania: Symphony of the Night, which fails to read from memcards without this patch.

Unlike the x64 equivalent, this doesn't use optimized SIMD code for invalidation yet, but it should be fine for now since most ARM users are probably on Apple Silicon which is plenty fast.

Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

Walkthrough

Adds a new public final override method invalidateCache() to DynaRecCPU that zero-fills I-cache state (sets iCacheAddr and iCacheCode to 0xff) and calls uncompileAll() to mark all JIT-compiled blocks as uncompiled.

Changes

Cohort / File(s) Summary
AArch64 JIT cache invalidation
src/core/DynaRec_aa64/recompiler.h
Introduced DynaRecCPU::invalidateCache() (override final) that resets I-cache arrays to 0xff and invokes uncompileAll() to invalidate compiled blocks.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant DynaRecCPU
  participant ICache
  participant JITBlocks

  Caller->>DynaRecCPU: invalidateCache()
  DynaRecCPU->>ICache: fill iCacheAddr/iCacheCode with 0xff
  DynaRecCPU->>JITBlocks: uncompileAll()
  JITBlocks-->>DynaRecCPU: all blocks marked uncompiled
  DynaRecCPU-->>Caller: return
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I nudge the cache with whiskered care,
0xff snow drifts everywhere.
JIT tracks pause, then softly fall,
uncompiled dreams await the call.
In bytes I burrow, swift and sly—
fresh paths to hop, compile, and fly. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/core/DynaRec_aa64/recompiler.h (1)

246-250: Nit: error message says “x64 JIT” in the aa64 JIT

The message can be misleading when thrown from the arm64 dynarec.

Apply this diff:

-            throw std::runtime_error("PGXP not supported in x64 JIT");
+            throw std::runtime_error("PGXP not supported in arm64 JIT");
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f4a00f and 053eb57.

📒 Files selected for processing (1)
  • src/core/DynaRec_aa64/recompiler.h (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/core/DynaRec_aa64/recompiler.h (3)
src/core/r3000a.h (2)
  • void (323-326)
  • void (448-451)
src/core/DynaRec_x64/recompiler.h (4)
  • void (210-213)
  • void (221-226)
  • void (228-232)
  • void (234-238)
src/core/DynaRec_aa64/recompiler.cc (2)
  • uncompileAll (131-139)
  • uncompileAll (131-131)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build
  • GitHub Check: coverage
  • GitHub Check: build-openbios
  • GitHub Check: toolchain
  • GitHub Check: aur-build
  • GitHub Check: macos-build-and-test-toolchain
  • GitHub Check: asan
  • GitHub Check: cross-arm64
🔇 Additional comments (1)
src/core/DynaRec_aa64/recompiler.h (1)

240-245: Cache invalidation integration verified—ready to merge

  • The invalidateCache() override in src/core/DynaRec_aa64/recompiler.h is present and matches the x64 implementation.
  • The base CPU Reset() in src/core/r3000a.h calls invalidateCache().
  • All BIOS/OS “FlushCache” paths (e.g. in src/core/psxmem.cc, Lua bindings, patch manager, web server, assembly widget) invoke g_emulator->m_cpu->invalidateCache().
  • JIT-internal over-size cache flushes in both x64 and aa64 use their respective flushCache() to reset code emitters and re-emit the dispatcher.

This aligns arm64 behavior with x64 semantics; no further changes needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant