mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-29 20:47:11 +02:00
misc: Replace references to IntPtr/UIntPtr with nint/nuint + code cleanups.
This commit is contained in:
parent
a09d314817
commit
dfb4854d19
172 changed files with 902 additions and 914 deletions
|
@ -15,7 +15,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
IMemoryManager memoryManager,
|
||||
ulong address,
|
||||
AddressTable<ulong> funcTable,
|
||||
IntPtr dispatchStubPtr,
|
||||
nint dispatchStubPtr,
|
||||
ExecutionMode executionMode,
|
||||
Architecture targetArch)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32
|
|||
IMemoryManager memoryManager,
|
||||
ulong address,
|
||||
AddressTable<ulong> funcTable,
|
||||
IntPtr dispatchStubPtr,
|
||||
nint dispatchStubPtr,
|
||||
bool isThumb,
|
||||
Architecture targetArch)
|
||||
{
|
||||
|
|
|
@ -24,10 +24,10 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
|||
public readonly MemoryManagerType MemoryManagerType;
|
||||
public readonly TailMerger TailMerger;
|
||||
public readonly AddressTable<ulong> FuncTable;
|
||||
public readonly IntPtr DispatchStubPointer;
|
||||
public readonly nint DispatchStubPointer;
|
||||
|
||||
private readonly RegisterSaveRestore _registerSaveRestore;
|
||||
private readonly IntPtr _pageTablePointer;
|
||||
private readonly nint _pageTablePointer;
|
||||
|
||||
public Context(
|
||||
CodeWriter writer,
|
||||
|
@ -36,8 +36,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
|||
TailMerger tailMerger,
|
||||
AddressTable<ulong> funcTable,
|
||||
RegisterSaveRestore registerSaveRestore,
|
||||
IntPtr dispatchStubPointer,
|
||||
IntPtr pageTablePointer)
|
||||
nint dispatchStubPointer,
|
||||
nint pageTablePointer)
|
||||
{
|
||||
Writer = writer;
|
||||
RegisterAllocator = registerAllocator;
|
||||
|
@ -226,7 +226,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
|||
}
|
||||
}
|
||||
|
||||
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, IntPtr dispatchStubPtr, bool isThumb)
|
||||
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, nint dispatchStubPtr, bool isThumb)
|
||||
{
|
||||
MultiBlock multiBlock = Decoder<InstEmit>.DecodeMulti(cpuPreset, memoryManager, address, isThumb);
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
|||
TailMerger tailMerger,
|
||||
Action writeEpilogue,
|
||||
AddressTable<ulong> funcTable,
|
||||
IntPtr funcPtr,
|
||||
nint funcPtr,
|
||||
int spillBaseOffset,
|
||||
uint nextAddress,
|
||||
Operand guestAddress,
|
||||
|
|
|
@ -324,27 +324,27 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
|||
Udf(context, encoding, 0);
|
||||
}
|
||||
|
||||
private static IntPtr GetBkptHandlerPtr()
|
||||
private static nint GetBkptHandlerPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Break);
|
||||
}
|
||||
|
||||
private static IntPtr GetSvcHandlerPtr()
|
||||
private static nint GetSvcHandlerPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.SupervisorCall);
|
||||
}
|
||||
|
||||
private static IntPtr GetUdfHandlerPtr()
|
||||
private static nint GetUdfHandlerPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Undefined);
|
||||
}
|
||||
|
||||
private static IntPtr GetCntpctEl0Ptr()
|
||||
private static nint GetCntpctEl0Ptr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<Get64>(NativeInterface.GetCntpctEl0);
|
||||
}
|
||||
|
||||
private static IntPtr CheckSynchronizationPtr()
|
||||
private static nint CheckSynchronizationPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<GetBool>(NativeInterface.CheckSynchronization);
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
|||
private static void WriteCall(
|
||||
ref Assembler asm,
|
||||
RegisterAllocator regAlloc,
|
||||
IntPtr funcPtr,
|
||||
nint funcPtr,
|
||||
bool skipContext,
|
||||
int spillBaseOffset,
|
||||
int? resultRegister,
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64
|
|||
IMemoryManager memoryManager,
|
||||
ulong address,
|
||||
AddressTable<ulong> funcTable,
|
||||
IntPtr dispatchStubPtr,
|
||||
nint dispatchStubPtr,
|
||||
Architecture targetArch)
|
||||
{
|
||||
if (targetArch == Architecture.Arm64)
|
||||
|
|
|
@ -20,11 +20,11 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
|||
public readonly RegisterAllocator RegisterAllocator;
|
||||
public readonly TailMerger TailMerger;
|
||||
public readonly AddressTable<ulong> FuncTable;
|
||||
public readonly IntPtr DispatchStubPointer;
|
||||
public readonly nint DispatchStubPointer;
|
||||
|
||||
private readonly MultiBlock _multiBlock;
|
||||
private readonly RegisterSaveRestore _registerSaveRestore;
|
||||
private readonly IntPtr _pageTablePointer;
|
||||
private readonly nint _pageTablePointer;
|
||||
|
||||
public Context(
|
||||
CodeWriter writer,
|
||||
|
@ -33,8 +33,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
|||
RegisterSaveRestore registerSaveRestore,
|
||||
MultiBlock multiBlock,
|
||||
AddressTable<ulong> funcTable,
|
||||
IntPtr dispatchStubPointer,
|
||||
IntPtr pageTablePointer)
|
||||
nint dispatchStubPointer,
|
||||
nint pageTablePointer)
|
||||
{
|
||||
Writer = writer;
|
||||
RegisterAllocator = registerAllocator;
|
||||
|
@ -304,7 +304,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
|||
}
|
||||
}
|
||||
|
||||
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, IntPtr dispatchStubPtr)
|
||||
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, nint dispatchStubPtr)
|
||||
{
|
||||
MultiBlock multiBlock = Decoder.DecodeMulti(cpuPreset, memoryManager, address);
|
||||
|
||||
|
|
|
@ -144,27 +144,27 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
|||
return name == InstName.Svc;
|
||||
}
|
||||
|
||||
private static IntPtr GetBrkHandlerPtr()
|
||||
private static nint GetBrkHandlerPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Break);
|
||||
}
|
||||
|
||||
private static IntPtr GetSvcHandlerPtr()
|
||||
private static nint GetSvcHandlerPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.SupervisorCall);
|
||||
}
|
||||
|
||||
private static IntPtr GetUdfHandlerPtr()
|
||||
private static nint GetUdfHandlerPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Undefined);
|
||||
}
|
||||
|
||||
private static IntPtr GetCntpctEl0Ptr()
|
||||
private static nint GetCntpctEl0Ptr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<Get64>(NativeInterface.GetCntpctEl0);
|
||||
}
|
||||
|
||||
private static IntPtr CheckSynchronizationPtr()
|
||||
private static nint CheckSynchronizationPtr()
|
||||
{
|
||||
return Marshal.GetFunctionPointerForDelegate<GetBool>(NativeInterface.CheckSynchronization);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
|||
TailMerger tailMerger,
|
||||
Action writeEpilogue,
|
||||
AddressTable<ulong> funcTable,
|
||||
IntPtr dispatchStubPtr,
|
||||
nint dispatchStubPtr,
|
||||
InstName name,
|
||||
ulong pc,
|
||||
uint encoding,
|
||||
|
@ -298,7 +298,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
|||
TailMerger tailMerger,
|
||||
Action writeEpilogue,
|
||||
AddressTable<ulong> funcTable,
|
||||
IntPtr funcPtr,
|
||||
nint funcPtr,
|
||||
int spillBaseOffset,
|
||||
ulong pc,
|
||||
Operand guestAddress,
|
||||
|
@ -369,7 +369,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
|||
private static void WriteCall(
|
||||
ref Assembler asm,
|
||||
RegisterAllocator regAlloc,
|
||||
IntPtr funcPtr,
|
||||
nint funcPtr,
|
||||
int spillBaseOffset,
|
||||
int? resultRegister,
|
||||
params ulong[] callArgs)
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||
public static partial IntPtr FlushInstructionCache(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize);
|
||||
public static partial nint FlushInstructionCache(nint hProcess, nint lpAddress, nuint dwSize);
|
||||
|
||||
public static void Initialize(IJitMemoryAllocator allocator)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
}
|
||||
}
|
||||
|
||||
public unsafe static IntPtr Map(ReadOnlySpan<byte> code)
|
||||
public unsafe static nint Map(ReadOnlySpan<byte> code)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
|
||||
int funcOffset = Allocate(code.Length);
|
||||
|
||||
IntPtr funcPtr = _jitRegion.Pointer + funcOffset;
|
||||
nint funcPtr = _jitRegion.Pointer + funcOffset;
|
||||
|
||||
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
{
|
||||
fixed (byte* codePtr = code)
|
||||
{
|
||||
JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length);
|
||||
JitSupportDarwin.Copy(funcPtr, (nint)codePtr, (ulong)code.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
|
||||
if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||
{
|
||||
FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (UIntPtr)code.Length);
|
||||
FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (nuint)code.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
}
|
||||
}
|
||||
|
||||
public static void Unmap(IntPtr pointer)
|
||||
public static void Unmap(nint pointer)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
}
|
||||
}
|
||||
|
||||
public void Invalidate(IntPtr basePointer, ulong size)
|
||||
public void Invalidate(nint basePointer, ulong size)
|
||||
{
|
||||
if (_needsInvalidation)
|
||||
{
|
||||
|
|
|
@ -8,9 +8,9 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||
static partial class JitSupportDarwin
|
||||
{
|
||||
[LibraryImport("libarmeilleure-jitsupport", EntryPoint = "armeilleure_jit_memcpy")]
|
||||
public static partial void Copy(IntPtr dst, IntPtr src, ulong n);
|
||||
public static partial void Copy(nint dst, nint src, ulong n);
|
||||
|
||||
[LibraryImport("libc", EntryPoint = "sys_icache_invalidate", SetLastError = true)]
|
||||
public static partial void SysIcacheInvalidate(IntPtr start, IntPtr len);
|
||||
public static partial void SysIcacheInvalidate(nint start, nint len);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,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)
|
||||
{
|
||||
|
@ -110,10 +110,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
|
|||
_lock = new();
|
||||
}
|
||||
|
||||
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));
|
||||
|
|
|
@ -6,13 +6,13 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64
|
|||
{
|
||||
class StackWalker : IStackWalker
|
||||
{
|
||||
public IEnumerable<ulong> GetCallStack(IntPtr framePointer, IntPtr codeRegionStart, int codeRegionSize, IntPtr codeRegion2Start, int codeRegion2Size)
|
||||
public IEnumerable<ulong> GetCallStack(nint framePointer, nint codeRegionStart, int codeRegionSize, nint codeRegion2Start, int codeRegion2Size)
|
||||
{
|
||||
List<ulong> functionPointers = new();
|
||||
|
||||
while (true)
|
||||
{
|
||||
IntPtr functionPointer = Marshal.ReadIntPtr(framePointer, IntPtr.Size);
|
||||
nint functionPointer = Marshal.ReadIntPtr(framePointer, nint.Size);
|
||||
|
||||
if ((functionPointer < codeRegionStart || functionPointer >= codeRegionStart + codeRegionSize) &&
|
||||
(functionPointer < codeRegion2Start || functionPointer >= codeRegion2Start + codeRegion2Size))
|
||||
|
|
|
@ -5,6 +5,6 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
{
|
||||
interface IStackWalker
|
||||
{
|
||||
IEnumerable<ulong> GetCallStack(IntPtr framePointer, IntPtr codeRegionStart, int codeRegionSize, IntPtr codeRegion2Start, int codeRegion2Size);
|
||||
IEnumerable<ulong> GetCallStack(nint framePointer, nint codeRegionStart, int codeRegionSize, nint codeRegion2Start, int codeRegion2Size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
return GetContext().CntpctEl0;
|
||||
}
|
||||
|
||||
public static ulong GetFunctionAddress(IntPtr framePointer, ulong address)
|
||||
public static ulong GetFunctionAddress(nint framePointer, ulong address)
|
||||
{
|
||||
return (ulong)Context.Translator.GetOrTranslatePointer(framePointer, address, GetContext().ExecutionMode);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.Cpu.LightningJit.State
|
|||
|
||||
private readonly NativeContext _nativeContext;
|
||||
|
||||
internal IntPtr NativeContextPtr => _nativeContext.BasePtr;
|
||||
internal nint NativeContextPtr => _nativeContext.BasePtr;
|
||||
|
||||
private bool _interrupted;
|
||||
private readonly ICounter _counter;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Ryujinx.Cpu.LightningJit.State
|
|||
|
||||
private readonly IJitMemoryBlock _block;
|
||||
|
||||
public IntPtr BasePtr => _block.Pointer;
|
||||
public nint BasePtr => _block.Pointer;
|
||||
|
||||
public NativeContext(IJitMemoryAllocator allocator)
|
||||
{
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
{
|
||||
class TranslatedFunction
|
||||
{
|
||||
public IntPtr FuncPointer { get; }
|
||||
public nint FuncPointer { get; }
|
||||
public ulong GuestSize { get; }
|
||||
|
||||
public TranslatedFunction(IntPtr funcPointer, ulong guestSize)
|
||||
public TranslatedFunction(nint funcPointer, ulong guestSize)
|
||||
{
|
||||
FuncPointer = funcPointer;
|
||||
GuestSize = guestSize;
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
_noWxCache?.ClearEntireThreadLocalCache();
|
||||
}
|
||||
|
||||
internal IntPtr GetOrTranslatePointer(IntPtr framePointer, ulong address, ExecutionMode mode)
|
||||
internal nint GetOrTranslatePointer(nint framePointer, ulong address, ExecutionMode mode)
|
||||
{
|
||||
if (_noWxCache != null)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
private TranslatedFunction Translate(ulong address, ExecutionMode mode)
|
||||
{
|
||||
CompiledFunction func = Compile(address, mode);
|
||||
IntPtr funcPointer = JitCache.Map(func.Code);
|
||||
nint funcPointer = JitCache.Map(func.Code);
|
||||
|
||||
return new TranslatedFunction(funcPointer, (ulong)func.GuestCodeLength);
|
||||
}
|
||||
|
|
|
@ -10,31 +10,31 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace Ryujinx.Cpu.LightningJit
|
||||
{
|
||||
delegate void DispatcherFunction(IntPtr nativeContext, ulong startAddress);
|
||||
delegate void DispatcherFunction(nint nativeContext, ulong startAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Represents a stub manager.
|
||||
/// </summary>
|
||||
class TranslatorStubs : IDisposable
|
||||
{
|
||||
private delegate ulong GetFunctionAddressDelegate(IntPtr framePointer, ulong address);
|
||||
private delegate ulong GetFunctionAddressDelegate(nint framePointer, ulong address);
|
||||
|
||||
private readonly Lazy<IntPtr> _slowDispatchStub;
|
||||
private readonly Lazy<nint> _slowDispatchStub;
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
private readonly AddressTable<ulong> _functionTable;
|
||||
private readonly NoWxCache _noWxCache;
|
||||
private readonly GetFunctionAddressDelegate _getFunctionAddressRef;
|
||||
private readonly IntPtr _getFunctionAddress;
|
||||
private readonly Lazy<IntPtr> _dispatchStub;
|
||||
private readonly nint _getFunctionAddress;
|
||||
private readonly Lazy<nint> _dispatchStub;
|
||||
private readonly Lazy<DispatcherFunction> _dispatchLoop;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dispatch stub.
|
||||
/// </summary>
|
||||
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
||||
public IntPtr DispatchStub
|
||||
public nint DispatchStub
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
/// Gets the slow dispatch stub.
|
||||
/// </summary>
|
||||
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
||||
public IntPtr SlowDispatchStub
|
||||
public nint SlowDispatchStub
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
/// Generates a <see cref="DispatchStub"/>.
|
||||
/// </summary>
|
||||
/// <returns>Generated <see cref="DispatchStub"/></returns>
|
||||
private IntPtr GenerateDispatchStub()
|
||||
private nint GenerateDispatchStub()
|
||||
{
|
||||
List<int> branchToFallbackOffsets = new();
|
||||
|
||||
|
@ -226,7 +226,7 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
/// Generates a <see cref="SlowDispatchStub"/>.
|
||||
/// </summary>
|
||||
/// <returns>Generated <see cref="SlowDispatchStub"/></returns>
|
||||
private IntPtr GenerateSlowDispatchStub()
|
||||
private nint GenerateSlowDispatchStub()
|
||||
{
|
||||
CodeWriter writer = new();
|
||||
|
||||
|
@ -350,12 +350,12 @@ namespace Ryujinx.Cpu.LightningJit
|
|||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
IntPtr pointer = Map(writer.AsByteSpan());
|
||||
nint pointer = Map(writer.AsByteSpan());
|
||||
|
||||
return Marshal.GetDelegateForFunctionPointer<DispatcherFunction>(pointer);
|
||||
}
|
||||
|
||||
private IntPtr Map(ReadOnlySpan<byte> code)
|
||||
private nint Map(ReadOnlySpan<byte> code)
|
||||
{
|
||||
if (_noWxCache != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue