Rename MemoryAlloc to MemoryManagement, and other nits
This commit is contained in:
parent
0d75d1d25f
commit
4cde30e92a
7 changed files with 32 additions and 73 deletions
|
@ -95,7 +95,7 @@ namespace ChocolArm64.Memory
|
||||||
|
|
||||||
int cpuId = getCpuId();
|
int cpuId = getCpuId();
|
||||||
|
|
||||||
MemoryAlloc.Free(funcPtr);
|
MemoryManagement.Free(funcPtr);
|
||||||
|
|
||||||
return (cpuId & (1 << 13)) != 0;
|
return (cpuId & (1 << 13)) != 0;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
ulong codeLength = (ulong)code.Length;
|
ulong codeLength = (ulong)code.Length;
|
||||||
|
|
||||||
IntPtr funcPtr = MemoryAlloc.Allocate(codeLength);
|
IntPtr funcPtr = MemoryManagement.Allocate(codeLength);
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ namespace ChocolArm64.Memory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryAlloc.Reprotect(funcPtr, codeLength, MemoryProtection.Execute);
|
MemoryManagement.Reprotect(funcPtr, codeLength, MemoryProtection.Execute);
|
||||||
|
|
||||||
return funcPtr;
|
return funcPtr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ChocolArm64.Memory
|
namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
public static class MemoryAlloc
|
public static class MemoryManagement
|
||||||
{
|
{
|
||||||
public static bool HasWriteWatchSupport => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
public static bool HasWriteWatchSupport => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
IntPtr sizeNint = new IntPtr((long)size);
|
IntPtr sizeNint = new IntPtr((long)size);
|
||||||
|
|
||||||
return MemoryAllocWindows.Allocate(sizeNint);
|
return MemoryManagementWindows.Allocate(sizeNint);
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
{
|
{
|
||||||
return MemoryAllocUnix.Allocate(size);
|
return MemoryManagementUnix.Allocate(size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -33,12 +33,12 @@ namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
IntPtr sizeNint = new IntPtr((long)size);
|
IntPtr sizeNint = new IntPtr((long)size);
|
||||||
|
|
||||||
return MemoryAllocWindows.AllocateWriteTracked(sizeNint);
|
return MemoryManagementWindows.AllocateWriteTracked(sizeNint);
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
{
|
{
|
||||||
return MemoryAllocUnix.Allocate(size);
|
return MemoryManagementUnix.Allocate(size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -54,12 +54,12 @@ namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
IntPtr sizeNint = new IntPtr((long)size);
|
IntPtr sizeNint = new IntPtr((long)size);
|
||||||
|
|
||||||
result = MemoryAllocWindows.Reprotect(address, sizeNint, permission);
|
result = MemoryManagementWindows.Reprotect(address, sizeNint, permission);
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
{
|
{
|
||||||
result = MemoryAllocUnix.Reprotect(address, size, permission);
|
result = MemoryManagementUnix.Reprotect(address, size, permission);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -76,12 +76,12 @@ namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
return MemoryAllocWindows.Free(address);
|
return MemoryManagementWindows.Free(address);
|
||||||
}
|
}
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
|
||||||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
{
|
{
|
||||||
return MemoryAllocUnix.Free(address);
|
return MemoryManagementUnix.Free(address);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -101,7 +101,7 @@ namespace ChocolArm64.Memory
|
||||||
//write tracking support on the OS.
|
//write tracking support on the OS.
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
return MemoryAllocWindows.GetModifiedPages(address, size, addresses, out count);
|
return MemoryManagementWindows.GetModifiedPages(address, size, addresses, out count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
|
|
||||||
namespace ChocolArm64.Memory
|
namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
static class MemoryAllocUnix
|
static class MemoryManagementUnix
|
||||||
{
|
{
|
||||||
public static IntPtr Allocate(ulong size)
|
public static IntPtr Allocate(ulong size)
|
||||||
{
|
{
|
|
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace ChocolArm64.Memory
|
namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
static class MemoryAllocWindows
|
static class MemoryManagementWindows
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
private enum AllocationType : uint
|
private enum AllocationType : uint
|
|
@ -7,7 +7,7 @@ using System.Runtime.Intrinsics.X86;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
using static ChocolArm64.Memory.CompareExchange128;
|
using static ChocolArm64.Memory.CompareExchange128;
|
||||||
using static ChocolArm64.Memory.MemoryAlloc;
|
using static ChocolArm64.Memory.MemoryManagement;
|
||||||
|
|
||||||
namespace ChocolArm64.Memory
|
namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ namespace ChocolArm64.Memory
|
||||||
|
|
||||||
internal IntPtr PageTable => _pageTable;
|
internal IntPtr PageTable => _pageTable;
|
||||||
|
|
||||||
public bool HasWriteWatchSupport => MemoryAlloc.HasWriteWatchSupport;
|
public bool HasWriteWatchSupport => MemoryManagement.HasWriteWatchSupport;
|
||||||
|
|
||||||
public long AddressSpaceSize { get; }
|
public long AddressSpaceSize { get; }
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ namespace ChocolArm64.Translation
|
||||||
private const int IntGpTmp2Index = ReservedLocalsCount + 4;
|
private const int IntGpTmp2Index = ReservedLocalsCount + 4;
|
||||||
private const int UserIntTempStart = ReservedLocalsCount + 5;
|
private const int UserIntTempStart = ReservedLocalsCount + 5;
|
||||||
|
|
||||||
|
|
||||||
//Vectors are part of another "set" of locals.
|
//Vectors are part of another "set" of locals.
|
||||||
private const int VecGpTmp1Index = ReservedLocalsCount + 0;
|
private const int VecGpTmp1Index = ReservedLocalsCount + 0;
|
||||||
private const int VecGpTmp2Index = ReservedLocalsCount + 1;
|
private const int VecGpTmp2Index = ReservedLocalsCount + 1;
|
||||||
|
@ -174,7 +173,7 @@ namespace ChocolArm64.Translation
|
||||||
_ilBlock.Add(new ILBarrier());
|
_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
|
//Bit 0 of all conditions is basically a negation bit, so
|
||||||
//inverting this bit has the effect of inverting the condition.
|
//inverting this bit has the effect of inverting the condition.
|
||||||
|
@ -640,62 +639,12 @@ namespace ChocolArm64.Translation
|
||||||
|
|
||||||
public void EmitCallPropGet(Type objType, string propName)
|
public void EmitCallPropGet(Type objType, string propName)
|
||||||
{
|
{
|
||||||
if (objType == null)
|
EmitCall(objType, $"get_{propName}");
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(objType));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (propName == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(propName));
|
|
||||||
}
|
|
||||||
|
|
||||||
EmitCall(objType.GetMethod($"get_{propName}"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EmitCallPropSet(Type objType, string propName)
|
public void EmitCallPropSet(Type objType, string propName)
|
||||||
{
|
{
|
||||||
if (objType == null)
|
EmitCall(objType, $"set_{propName}");
|
||||||
{
|
|
||||||
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}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EmitCall(Type objType, string mthdName)
|
public void EmitCall(Type objType, string mthdName)
|
||||||
|
@ -713,6 +662,16 @@ namespace ChocolArm64.Translation
|
||||||
EmitCall(objType.GetMethod(mthdName));
|
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)
|
public void EmitPrivateCall(Type objType, string mthdName)
|
||||||
{
|
{
|
||||||
if (objType == null)
|
if (objType == null)
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.HLE
|
||||||
|
|
||||||
public unsafe DeviceMemory()
|
public unsafe DeviceMemory()
|
||||||
{
|
{
|
||||||
RamPointer = MemoryAlloc.AllocateWriteTracked(RamSize);
|
RamPointer = MemoryManagement.AllocateWriteTracked(RamSize);
|
||||||
|
|
||||||
_ramPtr = (byte*)RamPointer;
|
_ramPtr = (byte*)RamPointer;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ namespace Ryujinx.HLE
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
MemoryAlloc.Free(RamPointer);
|
MemoryManagement.Free(RamPointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue