diff --git a/ChocolArm64/Memory/CompareExchange128.cs b/ChocolArm64/Memory/CompareExchange128.cs index 0fbe10f2cf..1618ff0fbc 100644 --- a/ChocolArm64/Memory/CompareExchange128.cs +++ b/ChocolArm64/Memory/CompareExchange128.cs @@ -95,7 +95,7 @@ namespace ChocolArm64.Memory int cpuId = getCpuId(); - MemoryAlloc.Free(funcPtr); + MemoryManagement.Free(funcPtr); return (cpuId & (1 << 13)) != 0; } @@ -104,7 +104,7 @@ namespace ChocolArm64.Memory { ulong codeLength = (ulong)code.Length; - IntPtr funcPtr = MemoryAlloc.Allocate(codeLength); + IntPtr funcPtr = MemoryManagement.Allocate(codeLength); unsafe { @@ -118,7 +118,7 @@ namespace ChocolArm64.Memory } } - MemoryAlloc.Reprotect(funcPtr, codeLength, MemoryProtection.Execute); + MemoryManagement.Reprotect(funcPtr, codeLength, MemoryProtection.Execute); return funcPtr; } diff --git a/ChocolArm64/Memory/MemoryAlloc.cs b/ChocolArm64/Memory/MemoryManagement.cs similarity index 81% rename from ChocolArm64/Memory/MemoryAlloc.cs rename to ChocolArm64/Memory/MemoryManagement.cs index a24299cd70..fa4bc4fac2 100644 --- a/ChocolArm64/Memory/MemoryAlloc.cs +++ b/ChocolArm64/Memory/MemoryManagement.cs @@ -4,7 +4,7 @@ using System.Runtime.InteropServices; namespace ChocolArm64.Memory { - public static class MemoryAlloc + public static class MemoryManagement { public static bool HasWriteWatchSupport => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); @@ -14,12 +14,12 @@ namespace ChocolArm64.Memory { IntPtr sizeNint = new IntPtr((long)size); - return MemoryAllocWindows.Allocate(sizeNint); + return MemoryManagementWindows.Allocate(sizeNint); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - return MemoryAllocUnix.Allocate(size); + return MemoryManagementUnix.Allocate(size); } else { @@ -33,12 +33,12 @@ namespace ChocolArm64.Memory { IntPtr sizeNint = new IntPtr((long)size); - return MemoryAllocWindows.AllocateWriteTracked(sizeNint); + return MemoryManagementWindows.AllocateWriteTracked(sizeNint); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - return MemoryAllocUnix.Allocate(size); + return MemoryManagementUnix.Allocate(size); } else { @@ -54,12 +54,12 @@ namespace ChocolArm64.Memory { IntPtr sizeNint = new IntPtr((long)size); - result = MemoryAllocWindows.Reprotect(address, sizeNint, permission); + result = MemoryManagementWindows.Reprotect(address, sizeNint, permission); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - result = MemoryAllocUnix.Reprotect(address, size, permission); + result = MemoryManagementUnix.Reprotect(address, size, permission); } else { @@ -76,12 +76,12 @@ namespace ChocolArm64.Memory { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - return MemoryAllocWindows.Free(address); + return MemoryManagementWindows.Free(address); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - return MemoryAllocUnix.Free(address); + return MemoryManagementUnix.Free(address); } else { @@ -101,7 +101,7 @@ namespace ChocolArm64.Memory //write tracking support on the OS. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - return MemoryAllocWindows.GetModifiedPages(address, size, addresses, out count); + return MemoryManagementWindows.GetModifiedPages(address, size, addresses, out count); } else { diff --git a/ChocolArm64/Memory/MemoryAllocUnix.cs b/ChocolArm64/Memory/MemoryManagementUnix.cs similarity index 98% rename from ChocolArm64/Memory/MemoryAllocUnix.cs rename to ChocolArm64/Memory/MemoryManagementUnix.cs index 857c1c5042..9fe1aef094 100644 --- a/ChocolArm64/Memory/MemoryAllocUnix.cs +++ b/ChocolArm64/Memory/MemoryManagementUnix.cs @@ -3,7 +3,7 @@ using System; namespace ChocolArm64.Memory { - static class MemoryAllocUnix + static class MemoryManagementUnix { public static IntPtr Allocate(ulong size) { diff --git a/ChocolArm64/Memory/MemoryAllocWindows.cs b/ChocolArm64/Memory/MemoryManagementWindows.cs similarity index 99% rename from ChocolArm64/Memory/MemoryAllocWindows.cs rename to ChocolArm64/Memory/MemoryManagementWindows.cs index 82be8b1e4f..4029332843 100644 --- a/ChocolArm64/Memory/MemoryAllocWindows.cs +++ b/ChocolArm64/Memory/MemoryManagementWindows.cs @@ -4,7 +4,7 @@ using System.Runtime.InteropServices; namespace ChocolArm64.Memory { - static class MemoryAllocWindows + static class MemoryManagementWindows { [Flags] private enum AllocationType : uint diff --git a/ChocolArm64/Memory/MemoryManager.cs b/ChocolArm64/Memory/MemoryManager.cs index 78af1a90cd..3c51956028 100644 --- a/ChocolArm64/Memory/MemoryManager.cs +++ b/ChocolArm64/Memory/MemoryManager.cs @@ -7,7 +7,7 @@ using System.Runtime.Intrinsics.X86; using System.Threading; using static ChocolArm64.Memory.CompareExchange128; -using static ChocolArm64.Memory.MemoryAlloc; +using static ChocolArm64.Memory.MemoryManagement; namespace ChocolArm64.Memory { @@ -29,7 +29,7 @@ namespace ChocolArm64.Memory internal IntPtr PageTable => _pageTable; - public bool HasWriteWatchSupport => MemoryAlloc.HasWriteWatchSupport; + public bool HasWriteWatchSupport => MemoryManagement.HasWriteWatchSupport; public long AddressSpaceSize { get; } diff --git a/ChocolArm64/Translation/ILEmitterCtx.cs b/ChocolArm64/Translation/ILEmitterCtx.cs index 8cd36602aa..f7e61bc999 100644 --- a/ChocolArm64/Translation/ILEmitterCtx.cs +++ b/ChocolArm64/Translation/ILEmitterCtx.cs @@ -55,7 +55,6 @@ namespace ChocolArm64.Translation private const int IntGpTmp2Index = ReservedLocalsCount + 4; private const int UserIntTempStart = ReservedLocalsCount + 5; - //Vectors are part of another "set" of locals. private const int VecGpTmp1Index = ReservedLocalsCount + 0; private const int VecGpTmp2Index = ReservedLocalsCount + 1; @@ -174,7 +173,7 @@ namespace ChocolArm64.Translation _ilBlock.Add(new ILBarrier()); } - private Condition GetInverseCond(Condition cond) + private static Condition GetInverseCond(Condition cond) { //Bit 0 of all conditions is basically a negation bit, so //inverting this bit has the effect of inverting the condition. @@ -640,62 +639,12 @@ namespace ChocolArm64.Translation public void EmitCallPropGet(Type objType, string propName) { - if (objType == null) - { - throw new ArgumentNullException(nameof(objType)); - } - - if (propName == null) - { - throw new ArgumentNullException(nameof(propName)); - } - - EmitCall(objType.GetMethod($"get_{propName}")); + EmitCall(objType, $"get_{propName}"); } public void EmitCallPropSet(Type objType, string propName) { - if (objType == null) - { - throw new ArgumentNullException(nameof(objType)); - } - - if (propName == null) - { - throw new ArgumentNullException(nameof(propName)); - } - - EmitCall(objType.GetMethod($"set_{propName}")); - } - - public void EmitCallPrivatePropGet(Type objType, string propName) - { - if (objType == null) - { - throw new ArgumentNullException(nameof(objType)); - } - - if (propName == null) - { - throw new ArgumentNullException(nameof(propName)); - } - - EmitPrivateCall(objType, $"get_{propName}"); - } - - public void EmitCallPrivatePropSet(Type objType, string propName) - { - if (objType == null) - { - throw new ArgumentNullException(nameof(objType)); - } - - if (propName == null) - { - throw new ArgumentNullException(nameof(propName)); - } - - EmitPrivateCall(objType, $"set_{propName}"); + EmitCall(objType, $"set_{propName}"); } public void EmitCall(Type objType, string mthdName) @@ -713,6 +662,16 @@ namespace ChocolArm64.Translation EmitCall(objType.GetMethod(mthdName)); } + public void EmitCallPrivatePropGet(Type objType, string propName) + { + EmitPrivateCall(objType, $"get_{propName}"); + } + + public void EmitCallPrivatePropSet(Type objType, string propName) + { + EmitPrivateCall(objType, $"set_{propName}"); + } + public void EmitPrivateCall(Type objType, string mthdName) { if (objType == null) diff --git a/Ryujinx.HLE/DeviceMemory.cs b/Ryujinx.HLE/DeviceMemory.cs index 1ff6f1dc7f..dc43903f11 100644 --- a/Ryujinx.HLE/DeviceMemory.cs +++ b/Ryujinx.HLE/DeviceMemory.cs @@ -14,7 +14,7 @@ namespace Ryujinx.HLE public unsafe DeviceMemory() { - RamPointer = MemoryAlloc.AllocateWriteTracked(RamSize); + RamPointer = MemoryManagement.AllocateWriteTracked(RamSize); _ramPtr = (byte*)RamPointer; } @@ -178,7 +178,7 @@ namespace Ryujinx.HLE protected virtual void Dispose(bool disposing) { - MemoryAlloc.Free(RamPointer); + MemoryManagement.Free(RamPointer); } } } \ No newline at end of file