Skip to content

Fix native macOS arm64 dynarec support#631

Open
resvel wants to merge 3 commits into
libretro:developfrom
resvel:macos-arm64-dynarec-fixes
Open

Fix native macOS arm64 dynarec support#631
resvel wants to merge 3 commits into
libretro:developfrom
resvel:macos-arm64-dynarec-fixes

Conversation

@resvel

@resvel resvel commented May 3, 2026

Copy link
Copy Markdown

This PR fixes native Apple Silicon macOS dynarec support when building Mupen64Plus-Next with the aarch64 dynarec.

Problem

On native macOS arm64, the dynamic recompiler could crash or jump through corrupted trampoline/register state. The dynarec also needed a working macOS JIT memory path using MAP_JIT.

Changes

  • Restore a known-good macOS arm64 MAP_JIT allocation path.
  • Fix ARM64 dynarec trampoline register handling on macOS.
  • Tighten register address masks and add RDRAM bounds guards.

Testing

Built locally on Apple Silicon macOS:

make -j4 platform=osx

This completed successfully and produced an arm64 mupen64plus_next_libretro.dylib.

Compatibility

The macOS-specific JIT behavior is guarded to macOS/arm64 paths. Non-macOS behavior should be unchanged except for the bounds/masking safety checks.

resvel added 3 commits May 3, 2026 12:55
Narrow RI and RSP register index masks from 0xffff to the correct bit
widths (0x1f / 0x7), preventing out-of-range array indexing. Add
explicit bounds checks in rdram read/write paths so out-of-range
register accesses emit a warning and return safely instead of
crashing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant