Revert "misc: chore: Remove redundant code"

This reverts commit 05a88ccc94.
This commit is contained in:
KeatonTheBot
2025-03-15 20:00:22 -05:00
parent 7960ea643f
commit efd5a104b6
109 changed files with 412 additions and 271 deletions
@@ -4,8 +4,7 @@ using System.Runtime.Versioning;
namespace Ryujinx.Cpu.AppleHv
{
[SupportedOSPlatform("macos")]
class HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment)
: PrivateMemoryAllocatorImpl<HvMemoryBlockAllocator.Block>(blockAlignment, MemoryAllocationFlags.None)
class HvMemoryBlockAllocator : PrivateMemoryAllocatorImpl<HvMemoryBlockAllocator.Block>
{
public class Block : PrivateMemoryAllocator.Block
{
@@ -37,6 +36,13 @@ namespace Ryujinx.Cpu.AppleHv
}
}
private readonly HvIpaAllocator _ipaAllocator;
public HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment) : base(blockAlignment, MemoryAllocationFlags.None)
{
_ipaAllocator = ipaAllocator;
}
public HvMemoryBlockAllocation Allocate(ulong size, ulong alignment)
{
var allocation = Allocate(size, alignment, CreateBlock);
@@ -46,7 +52,7 @@ namespace Ryujinx.Cpu.AppleHv
private Block CreateBlock(MemoryBlock memory, ulong size)
{
return new Block(ipaAllocator, memory, size);
return new Block(_ipaAllocator, memory, size);
}
}
}
@@ -5,6 +5,7 @@ using Ryujinx.Memory.Tracking;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Ryujinx.Cpu.AppleHv
{
private const ulong InterruptIntervalNs = 16 * 1000000; // 16 ms
private static ulong _interruptTimeDeltaTicks;
private static ulong _interruptTimeDeltaTicks = 0;
public readonly ulong Handle;
public readonly HvVcpuExit* ExitInfo;
+1
View File
@@ -5,6 +5,7 @@ using Ryujinx.Memory.Tracking;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
@@ -8,6 +8,7 @@ using Ryujinx.Memory.Tracking;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Ryujinx.Cpu.Jit
@@ -14,7 +14,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Size = size;
}
public int CompareTo(CacheEntry other)
public int CompareTo([AllowNull] CacheEntry other)
{
return Offset.CompareTo(other.Offset);
}
@@ -18,7 +18,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Size = size;
}
public int CompareTo(MemoryBlock other)
public int CompareTo([AllowNull] MemoryBlock other)
{
return Offset.CompareTo(other.Offset);
}
@@ -28,7 +28,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private static readonly Lock _lock = new();
private static bool _initialized;
private static readonly List<ReservedRegion> _jitRegions = [];
private static int _activeRegionIndex;
private static int _activeRegionIndex = 0;
[SupportedOSPlatform("windows")]
[LibraryImport("kernel32.dll", SetLastError = true)]
@@ -75,9 +75,12 @@ namespace Ryujinx.Cpu.LightningJit.Cache
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
fixed (byte* codePtr = code)
unsafe
{
JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length);
fixed (byte* codePtr = code)
{
JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length);
}
}
}
else
@@ -20,7 +20,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Size = size;
}
public int CompareTo(Range other)
public int CompareTo([AllowNull] Range other)
{
return Offset.CompareTo(other.Offset);
}
@@ -21,7 +21,7 @@ namespace Ryujinx.Cpu.LightningJit.State
public int Running;
}
private static NativeCtxStorage _dummyStorage;
private static NativeCtxStorage _dummyStorage = new();
private readonly IJitMemoryBlock _block;
@@ -79,22 +79,22 @@ namespace Ryujinx.Cpu.LightningJit.State
GetStorage().V[index * 2 + 1] = value.Extract<ulong>(1);
}
public uint GetPstate()
public unsafe uint GetPstate()
{
return GetStorage().Flags;
}
public void SetPstate(uint value)
public unsafe void SetPstate(uint value)
{
GetStorage().Flags = value;
}
public uint GetFPState(uint mask = uint.MaxValue)
public unsafe uint GetFPState(uint mask = uint.MaxValue)
{
return GetStorage().FpFlags & mask;
}
public void SetFPState(uint value, uint mask = uint.MaxValue)
public unsafe void SetFPState(uint value, uint mask = uint.MaxValue)
{
GetStorage().FpFlags = (value & mask) | (GetStorage().FpFlags & ~mask);
}