Memory Changes part 2

* Slightly refactors RangeLists from the last Memory Changes MR, which fixes issue 61.

* Convert as many const size array iterators to span iterators as possible. When iterating over a const size array, every iteration created a Span, now only the first iteration does in most places.

* Now using object pooling for a few object types that were rapidly deleted and recreated.

* Converted a few flag checks to binary operations to save memory allocations.
This commit is contained in:
LotP
2025-08-26 15:30:12 -05:00
committed by KeatonTheBot
parent 01cb33f658
commit 171624e7f0
89 changed files with 2121 additions and 1157 deletions
@@ -581,7 +581,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
KThread selectedSuggestedCore = context.Schedulers[suggestedCore]._state.SelectedThread;
if (selectedSuggestedCore == suggested || (selectedSuggestedCore != null && selectedSuggestedCore.DynamicPriority < 2))
if (selectedSuggestedCore == suggested || selectedSuggestedCore is { DynamicPriority: < 2 })
{
continue;
}
@@ -1,3 +1,4 @@
using ARMeilleure.State;
using Ryujinx.Common.Logging;
using Ryujinx.Cpu;
using Ryujinx.HLE.Debugger;
@@ -684,17 +685,20 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
const int MaxFpuRegistersAArch32 = 16;
ThreadContext context = new();
Span<ulong> registersSpan = context.Registers.AsSpan();
Span<V128> fpuRegistersSpan = context.FpuRegisters.AsSpan();
if (Owner.Flags.HasFlag(ProcessCreationFlags.Is64Bit))
{
for (int i = 0; i < context.Registers.Length; i++)
for (int i = 0; i < registersSpan.Length; i++)
{
context.Registers[i] = Context.GetX(i);
registersSpan[i] = Context.GetX(i);
}
for (int i = 0; i < context.FpuRegisters.Length; i++)
for (int i = 0; i < fpuRegistersSpan.Length; i++)
{
context.FpuRegisters[i] = Context.GetV(i);
fpuRegistersSpan[i] = Context.GetV(i);
}
context.Fp = Context.GetX(29);
@@ -708,12 +712,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{
for (int i = 0; i < MaxRegistersAArch32; i++)
{
context.Registers[i] = (uint)Context.GetX(i);
registersSpan[i] = (uint)Context.GetX(i);
}
for (int i = 0; i < MaxFpuRegistersAArch32; i++)
{
context.FpuRegisters[i] = Context.GetV(i);
fpuRegistersSpan[i] = Context.GetV(i);
}
context.Pc = (uint)Context.Pc;