misc: chore: Use collection expressions in ARMeilleure

This commit is contained in:
Evan Husted 2025-01-26 15:31:44 -06:00
parent c7db948fb3
commit 9cb3b40ffc
43 changed files with 251 additions and 256 deletions

View file

@ -55,7 +55,7 @@ namespace ARMeilleure.Translation
public Aarch32Mode Mode { get; }
private int _ifThenBlockStateIndex = 0;
private Condition[] _ifThenBlockState = Array.Empty<Condition>();
private Condition[] _ifThenBlockState = [];
public bool IsInIfThenBlock => _ifThenBlockStateIndex < _ifThenBlockState.Length;
public Condition CurrentIfThenBlockCond => _ifThenBlockState[_ifThenBlockStateIndex];

View file

@ -23,7 +23,7 @@ namespace ARMeilleure.Translation.Cache
}
}
private readonly List<MemoryBlock> _blocks = new();
private readonly List<MemoryBlock> _blocks = [];
public CacheMemoryAllocator(int capacity)
{

View file

@ -25,7 +25,7 @@ namespace ARMeilleure.Translation.Cache
private static CacheMemoryAllocator _cacheAllocator;
private static readonly List<CacheEntry> _cacheEntries = new();
private static readonly List<CacheEntry> _cacheEntries = [];
private static readonly Lock _lock = new();
private static bool _initialized;

View file

@ -6,8 +6,8 @@ namespace ARMeilleure.Translation.Cache
{
class JitCacheInvalidation
{
private static readonly int[] _invalidationCode = new int[]
{
private static readonly int[] _invalidationCode =
[
unchecked((int)0xd53b0022), // mrs x2, ctr_el0
unchecked((int)0xd3504c44), // ubfx x4, x2, #16, #4
unchecked((int)0x52800083), // mov w3, #0x4
@ -35,8 +35,8 @@ namespace ARMeilleure.Translation.Cache
unchecked((int)0x54ffffa8), // b.hi 54 <ic_clear_loop>
unchecked((int)0xd5033b9f), // dsb ish
unchecked((int)0xd5033fdf), // isb
unchecked((int)0xd65f03c0), // ret
};
unchecked((int)0xd65f03c0) // ret
];
private delegate void InvalidateCache(ulong start, ulong end);

View file

@ -47,7 +47,7 @@ namespace ARMeilleure.Translation
{
RemoveUnreachableBlocks(Blocks);
HashSet<BasicBlock> visited = new();
HashSet<BasicBlock> visited = [];
Stack<BasicBlock> blockStack = new();
Array.Resize(ref _postOrderBlocks, Blocks.Count);
@ -88,7 +88,7 @@ namespace ARMeilleure.Translation
private void RemoveUnreachableBlocks(IntrusiveList<BasicBlock> blocks)
{
HashSet<BasicBlock> visited = new();
HashSet<BasicBlock> visited = [];
Queue<BasicBlock> workQueue = new();
visited.Add(Entry);

View file

@ -108,7 +108,7 @@ namespace ARMeilleure.Translation
/// <returns>A list of all values sorted by Key Order</returns>
public List<TV> AsList()
{
List<TV> list = new();
List<TV> list = [];
AddToList(_root, list);

View file

@ -154,7 +154,7 @@ namespace ARMeilleure.Translation.PTC
private void InitializeCarriers()
{
_infosStream = MemoryStreamManager.Shared.GetStream();
_codesList = new List<byte[]>();
_codesList = [];
_relocsStream = MemoryStreamManager.Shared.GetStream();
_unwindInfosStream = MemoryStreamManager.Shared.GetStream();
}
@ -765,7 +765,7 @@ namespace ARMeilleure.Translation.PTC
private void StubCode(int index)
{
_codesList[index] = Array.Empty<byte>();
_codesList[index] = [];
}
private void StubReloc(int relocEntriesCount)

View file

@ -50,7 +50,7 @@ namespace ARMeilleure.Translation.PTC
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static List<T> DeserializeList<T>(Stream stream) where T : struct
{
List<T> list = new();
List<T> list = [];
int count = DeserializeStructure<int>(stream);

View file

@ -26,9 +26,10 @@ namespace ARMeilleure.Translation.PTC
private const uint InternalVersion = 5518; //! Not to be incremented manually for each change to the ARMeilleure project.
private static readonly uint[] _migrateInternalVersions = {
1866,
};
private static readonly uint[] _migrateInternalVersions =
[
1866
];
private const int SaveInterval = 30; // Seconds.

View file

@ -260,7 +260,7 @@ namespace ARMeilleure.Translation
Logger.EndPass(PassName.RegisterUsage);
OperandType retType = OperandType.I64;
OperandType[] argTypes = new OperandType[] { OperandType.I64 };
OperandType[] argTypes = [OperandType.I64];
CompilerOptions options = highCq ? CompilerOptions.HighCq : CompilerOptions.None;
@ -478,7 +478,7 @@ namespace ARMeilleure.Translation
public void InvalidateJitCacheRegion(ulong address, ulong size)
{
ulong[] overlapAddresses = Array.Empty<ulong>();
ulong[] overlapAddresses = [];
int overlapsCount = Functions.GetOverlaps(address, size, ref overlapAddresses);

View file

@ -36,7 +36,7 @@ namespace ARMeilleure.Translation
Sync = new object();
_requests = new Stack<RejitRequest>();
_requestAddresses = new HashSet<ulong>();
_requestAddresses = [];
}
/// <summary>

View file

@ -187,7 +187,7 @@ namespace ARMeilleure.Translation
ControlFlowGraph cfg = context.GetControlFlowGraph();
OperandType retType = OperandType.I64;
OperandType[] argTypes = new[] { OperandType.I64 };
OperandType[] argTypes = [OperandType.I64];
GuestFunction func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<GuestFunction>();
@ -212,7 +212,7 @@ namespace ARMeilleure.Translation
ControlFlowGraph cfg = context.GetControlFlowGraph();
OperandType retType = OperandType.I64;
OperandType[] argTypes = new[] { OperandType.I64 };
OperandType[] argTypes = [OperandType.I64];
GuestFunction func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<GuestFunction>();
@ -281,7 +281,7 @@ namespace ARMeilleure.Translation
ControlFlowGraph cfg = context.GetControlFlowGraph();
OperandType retType = OperandType.None;
OperandType[] argTypes = new[] { OperandType.I64, OperandType.I64 };
OperandType[] argTypes = [OperandType.I64, OperandType.I64];
return Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<DispatcherFunction>();
}
@ -305,7 +305,7 @@ namespace ARMeilleure.Translation
ControlFlowGraph cfg = context.GetControlFlowGraph();
OperandType retType = OperandType.I64;
OperandType[] argTypes = new[] { OperandType.I64, OperandType.I64 };
OperandType[] argTypes = [OperandType.I64, OperandType.I64];
return Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<WrapperFunction>();
}

View file

@ -139,7 +139,7 @@ namespace ARMeilleure.Translation
ControlFlowGraph cfg = context.GetControlFlowGraph();
OperandType[] argTypes = new OperandType[] { OperandType.I64 };
OperandType[] argTypes = [OperandType.I64];
return Compiler.Compile(cfg, argTypes, OperandType.I32, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<FpFlagsPInvokeTest>();
}