misc: Use nint/nuint instead of IntPtr/UIntPtr

This commit is contained in:
KeatonTheBot
2025-11-23 13:42:38 -06:00
parent 2d720fea03
commit c1e24961f9
163 changed files with 845 additions and 845 deletions
+12 -12
View File
@@ -24,7 +24,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private readonly CacheMemoryAllocator _cacheAllocator;
public CacheMemoryAllocator Allocator => _cacheAllocator;
public IntPtr Pointer => _region.Block.Pointer;
public nint Pointer => _region.Block.Pointer;
public MemoryCache(IJitMemoryAllocator allocator, ulong size)
{
@@ -111,10 +111,10 @@ namespace Ryujinx.Cpu.LightningJit.Cache
{
public readonly int Offset;
public readonly int Size;
public readonly IntPtr FuncPtr;
public readonly nint FuncPtr;
private int _useCount;
public ThreadLocalCacheEntry(int offset, int size, IntPtr funcPtr)
public ThreadLocalCacheEntry(int offset, int size, nint funcPtr)
{
Offset = offset;
Size = size;
@@ -140,9 +140,9 @@ namespace Ryujinx.Cpu.LightningJit.Cache
_pendingMap = new(_sharedCache.ReprotectAsRx, RegisterFunction);
}
public unsafe IntPtr Map(IntPtr framePointer, ReadOnlySpan<byte> code, ulong guestAddress, ulong guestSize)
public unsafe nint Map(nint framePointer, ReadOnlySpan<byte> code, ulong guestAddress, ulong guestSize)
{
if (TryGetThreadLocalFunction(guestAddress, out IntPtr funcPtr))
if (TryGetThreadLocalFunction(guestAddress, out nint funcPtr))
{
return funcPtr;
}
@@ -167,7 +167,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
}
}
public unsafe IntPtr MapPageAligned(ReadOnlySpan<byte> code)
public unsafe nint MapPageAligned(ReadOnlySpan<byte> code)
{
lock (_lock)
{
@@ -179,7 +179,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Debug.Assert((funcOffset & ((int)MemoryBlock.GetPageSize() - 1)) == 0);
IntPtr funcPtr = _sharedCache.Pointer + funcOffset;
nint funcPtr = _sharedCache.Pointer + funcOffset;
code.CopyTo(new Span<byte>((void*)funcPtr, code.Length));
_sharedCache.ReprotectAsRx(funcOffset, sizeAligned);
@@ -188,7 +188,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
}
}
private bool TryGetThreadLocalFunction(ulong guestAddress, out IntPtr funcPtr)
private bool TryGetThreadLocalFunction(ulong guestAddress, out nint funcPtr)
{
if ((_threadLocalCache ??= new()).TryGetValue(guestAddress, out var entry))
{
@@ -209,12 +209,12 @@ namespace Ryujinx.Cpu.LightningJit.Cache
return true;
}
funcPtr = IntPtr.Zero;
funcPtr = nint.Zero;
return false;
}
private void ClearThreadLocalCache(IntPtr framePointer)
private void ClearThreadLocalCache(nint framePointer)
{
// Try to delete functions that are already on the shared cache
// and no longer being executed.
@@ -296,14 +296,14 @@ namespace Ryujinx.Cpu.LightningJit.Cache
_threadLocalCache = null;
}
private unsafe IntPtr AddThreadLocalFunction(ReadOnlySpan<byte> code, ulong guestAddress)
private unsafe nint AddThreadLocalFunction(ReadOnlySpan<byte> code, ulong guestAddress)
{
int alignedSize = BitUtils.AlignUp(code.Length, (int)MemoryBlock.GetPageSize());
int funcOffset = _localCache.Allocate(alignedSize);
Debug.Assert((funcOffset & (int)(MemoryBlock.GetPageSize() - 1)) == 0);
IntPtr funcPtr = _localCache.Pointer + funcOffset;
nint funcPtr = _localCache.Pointer + funcOffset;
code.CopyTo(new Span<byte>((void*)funcPtr, code.Length));
(_threadLocalCache ??= new()).Add(guestAddress, new(funcOffset, code.Length, funcPtr));