mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-11-26 19:52:31 +01:00
8226997bc7
* Start of JIT garbage collection improvements - thread static pool for Operand, MemoryOperand, Operation - Operands and Operations are always to be constructed via their static helper classes, so they can be pooled. - removing LinkedList from Node for sources/destinations (replaced with List<>s for now, but probably could do arrays since size is bounded) - removing params constructors from Node - LinkedList<> to List<> with Clear() for Operand assignments/uses - ThreadStaticPool is very simple and basically just exists for the purpose of our specific translation allocation problem. Right now it will stay at the worst case allocation count for that thread (so far) - the pool can never shrink. - Still some cases of Operand[] that haven't been removed yet. Will need to evaluate them (eg. is there a reasonable max number of params for Calls?) * ConcurrentStack instead of ConcurrentQueue for Rejit * Optimize some parts of LSRA - BitMap now operates on 64-bit int rather than 32-bit - BitMap is now pooled in a ThreadStatic pool (within lrsa) - BitMap now is now its own iterator. Marginally speeds up iterating through the bits. - A few cases where enumerators were generated have been converted to forms that generate less garbage. - New data structure for sorting _usePositions in LiveIntervals. Much faster split, NextUseAfter, initial insertion. Random insertion is slightly slower. - That last one is WIP since you need to insert the values backwards. It would be ideal if it just flipped it for you, uncomplicating things on the caller side. * Use a static pool of thread static pools. (yes.) Prevents each execution thread creating its own lowCq pool and making me cry. * Move constant value to top, change naming convention. * Fix iteration of memory operands. * Increase max thread count. * Address Feedback
75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System.Numerics;
|
|
|
|
namespace ARMeilleure.Common
|
|
{
|
|
static class BitUtils
|
|
{
|
|
private static readonly sbyte[] HbsNibbleLut;
|
|
|
|
static BitUtils()
|
|
{
|
|
HbsNibbleLut = new sbyte[] { -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 };
|
|
}
|
|
|
|
public static int CountBits(int value)
|
|
{
|
|
int count = 0;
|
|
|
|
while (value != 0)
|
|
{
|
|
value &= ~(value & -value);
|
|
|
|
count++;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
public static long FillWithOnes(int bits)
|
|
{
|
|
return bits == 64 ? -1L : (1L << bits) - 1;
|
|
}
|
|
|
|
public static int HighestBitSet(int value)
|
|
{
|
|
return 31 - BitOperations.LeadingZeroCount((uint)value);
|
|
}
|
|
|
|
public static int HighestBitSetNibble(int value)
|
|
{
|
|
return HbsNibbleLut[value];
|
|
}
|
|
|
|
public static long Replicate(long bits, int size)
|
|
{
|
|
long output = 0;
|
|
|
|
for (int bit = 0; bit < 64; bit += size)
|
|
{
|
|
output |= bits << bit;
|
|
}
|
|
|
|
return output;
|
|
}
|
|
|
|
public static int RotateRight(int bits, int shift, int size)
|
|
{
|
|
return (int)RotateRight((uint)bits, shift, size);
|
|
}
|
|
|
|
public static uint RotateRight(uint bits, int shift, int size)
|
|
{
|
|
return (bits >> shift) | (bits << (size - shift));
|
|
}
|
|
|
|
public static long RotateRight(long bits, int shift, int size)
|
|
{
|
|
return (long)RotateRight((ulong)bits, shift, size);
|
|
}
|
|
|
|
public static ulong RotateRight(ulong bits, int shift, int size)
|
|
{
|
|
return (bits >> shift) | (bits << (size - shift));
|
|
}
|
|
}
|
|
}
|