misc: Replace references to IntPtr/UIntPtr with nint/nuint + code cleanups.

This commit is contained in:
Evan Husted
2024-10-26 08:46:41 -05:00
parent a09d314817
commit dfb4854d19
172 changed files with 902 additions and 914 deletions

View File

@@ -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)
{