PPTC & Pool Enhancements. (#1968)

* PPTC & Pool Enhancements.

* Avoid buffer allocations in CodeGenContext.GetCode(). Avoid stream allocations in PTC.PtcInfo.

Refactoring/nits.

* Use XXHash128, for Ptc.Load & Ptc.Save, x10 faster than Md5.

* Why not a nice Span.

* Added a simple PtcFormatter library for deserialization/serialization, which does not require reflection, in use at PtcJumpTable and PtcProfiler; improves maintainability and simplicity/readability of affected code.

* Nits.

* Revert #1987.

* Revert "Revert #1987."

This reverts commit 998be765cf7f7da5ff0c1c08de704c9012b0f49c.
This commit is contained in:
LDj3SNuD 2021-02-22 03:23:48 +01:00 committed by GitHub
parent 1586880114
commit dc0adb533d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 777 additions and 603 deletions

View file

@ -4,16 +4,6 @@ namespace ARMeilleure.IntermediateRepresentation
{
static class OperandHelper
{
private static MemoryOperand MemoryOperand()
{
return ThreadStaticPool<MemoryOperand>.Instance.Allocate();
}
private static Operand Operand()
{
return ThreadStaticPool<Operand>.Instance.Allocate();
}
public static Operand Const(OperandType type, long value)
{
return type == OperandType.I32 ? Operand().With((int)value) : Operand().With(value);
@ -84,22 +74,34 @@ namespace ARMeilleure.IntermediateRepresentation
return MemoryOperand().With(type, baseAddress, index, scale, displacement);
}
public static void PrepareOperandPool(bool highCq)
#region "ThreadStaticPool"
public static void PrepareOperandPool(int groupId = 0)
{
ThreadStaticPool<Operand>.PreparePool(highCq ? 1 : 0);
ThreadStaticPool<MemoryOperand>.PreparePool(highCq ? 1 : 0);
ThreadStaticPool<Operand>.PreparePool(groupId, ChunkSizeLimit.Large);
ThreadStaticPool<MemoryOperand>.PreparePool(groupId, ChunkSizeLimit.Small);
}
public static void ReturnOperandPool(bool highCq)
private static Operand Operand()
{
ThreadStaticPool<Operand>.ReturnPool(highCq ? 1 : 0);
ThreadStaticPool<MemoryOperand>.ReturnPool(highCq ? 1 : 0);
return ThreadStaticPool<Operand>.Instance.Allocate();
}
public static void ResetOperandPools()
private static MemoryOperand MemoryOperand()
{
ThreadStaticPool<Operand>.ResetPools();
ThreadStaticPool<MemoryOperand>.ResetPools();
return ThreadStaticPool<MemoryOperand>.Instance.Allocate();
}
public static void ResetOperandPool(int groupId = 0)
{
ThreadStaticPool<MemoryOperand>.ResetPool(groupId);
ThreadStaticPool<Operand>.ResetPool(groupId);
}
public static void DisposeOperandPools()
{
ThreadStaticPool<Operand>.DisposePools();
ThreadStaticPool<MemoryOperand>.DisposePools();
}
#endregion
}
}