diff options
author | gdkchan <gab.dark.100@gmail.com> | 2023-01-10 19:16:59 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-10 19:16:59 -0300 |
commit | 5e0f8e873857ce3ca3f532aff0936beb28e412c8 (patch) | |
tree | 576e5110c076b7d1f4d94e608ee21493f5b48879 /Ryujinx.Memory/MemoryManagementUnix.cs | |
parent | d16288a2a87f0979df30ba69d4fe10660177b6ac (diff) |
Implement JIT Arm64 backend (#4114)1.1.536
* Implement JIT Arm64 backend
* PPTC version bump
* Address some feedback from Arm64 JIT PR
* Address even more PR feedback
* Remove unused IsPageAligned function
* Sync Qc flag before calls
* Fix comment and remove unused enum
* Address riperiperi PR feedback
* Delete Breakpoint IR instruction that was only implemented for Arm64
Diffstat (limited to 'Ryujinx.Memory/MemoryManagementUnix.cs')
-rw-r--r-- | Ryujinx.Memory/MemoryManagementUnix.cs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/Ryujinx.Memory/MemoryManagementUnix.cs b/Ryujinx.Memory/MemoryManagementUnix.cs index df3fcea9..affcff92 100644 --- a/Ryujinx.Memory/MemoryManagementUnix.cs +++ b/Ryujinx.Memory/MemoryManagementUnix.cs @@ -13,17 +13,17 @@ namespace Ryujinx.Memory { private static readonly ConcurrentDictionary<IntPtr, ulong> _allocations = new ConcurrentDictionary<IntPtr, ulong>(); - public static IntPtr Allocate(ulong size) + public static IntPtr Allocate(ulong size, bool forJit) { - return AllocateInternal(size, MmapProts.PROT_READ | MmapProts.PROT_WRITE); + return AllocateInternal(size, MmapProts.PROT_READ | MmapProts.PROT_WRITE, forJit); } - public static IntPtr Reserve(ulong size) + public static IntPtr Reserve(ulong size, bool forJit) { - return AllocateInternal(size, MmapProts.PROT_NONE); + return AllocateInternal(size, MmapProts.PROT_NONE, forJit); } - private static IntPtr AllocateInternal(ulong size, MmapProts prot, bool shared = false) + private static IntPtr AllocateInternal(ulong size, MmapProts prot, bool forJit, bool shared = false) { MmapFlags flags = MmapFlags.MAP_ANONYMOUS; @@ -41,6 +41,16 @@ namespace Ryujinx.Memory flags |= MmapFlags.MAP_NORESERVE; } + if (OperatingSystem.IsMacOSVersionAtLeast(10, 14) && forJit) + { + flags |= MmapFlags.MAP_JIT_DARWIN; + + if (prot == (MmapProts.PROT_READ | MmapProts.PROT_WRITE)) + { + prot |= MmapProts.PROT_EXEC; + } + } + IntPtr ptr = mmap(IntPtr.Zero, size, prot, flags, -1, 0); if (ptr == new IntPtr(-1L)) @@ -57,9 +67,16 @@ namespace Ryujinx.Memory return ptr; } - public static bool Commit(IntPtr address, ulong size) + public static bool Commit(IntPtr address, ulong size, bool forJit) { - return mprotect(address, size, MmapProts.PROT_READ | MmapProts.PROT_WRITE) == 0; + MmapProts prot = MmapProts.PROT_READ | MmapProts.PROT_WRITE; + + if (OperatingSystem.IsMacOSVersionAtLeast(10, 14) && forJit) + { + prot |= MmapProts.PROT_EXEC; + } + + return mprotect(address, size, prot) == 0; } public static bool Decommit(IntPtr address, ulong size) |