From dc0adb533dc15a007e9ca2dc0533ef6a61f13393 Mon Sep 17 00:00:00 2001 From: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> Date: Mon, 22 Feb 2021 03:23:48 +0100 Subject: 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. --- .../IntermediateRepresentation/OperandHelper.cs | 40 ++++++++++++---------- .../IntermediateRepresentation/OperationHelper.cs | 24 +++++++------ 2 files changed, 34 insertions(+), 30 deletions(-) (limited to 'ARMeilleure/IntermediateRepresentation') diff --git a/ARMeilleure/IntermediateRepresentation/OperandHelper.cs b/ARMeilleure/IntermediateRepresentation/OperandHelper.cs index f7381d86..26d66478 100644 --- a/ARMeilleure/IntermediateRepresentation/OperandHelper.cs +++ b/ARMeilleure/IntermediateRepresentation/OperandHelper.cs @@ -4,16 +4,6 @@ namespace ARMeilleure.IntermediateRepresentation { static class OperandHelper { - private static MemoryOperand MemoryOperand() - { - return ThreadStaticPool.Instance.Allocate(); - } - - private static Operand Operand() - { - return ThreadStaticPool.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.PreparePool(highCq ? 1 : 0); - ThreadStaticPool.PreparePool(highCq ? 1 : 0); + ThreadStaticPool.PreparePool(groupId, ChunkSizeLimit.Large); + ThreadStaticPool.PreparePool(groupId, ChunkSizeLimit.Small); + } + + private static Operand Operand() + { + return ThreadStaticPool.Instance.Allocate(); + } + + private static MemoryOperand MemoryOperand() + { + return ThreadStaticPool.Instance.Allocate(); } - public static void ReturnOperandPool(bool highCq) + public static void ResetOperandPool(int groupId = 0) { - ThreadStaticPool.ReturnPool(highCq ? 1 : 0); - ThreadStaticPool.ReturnPool(highCq ? 1 : 0); + ThreadStaticPool.ResetPool(groupId); + ThreadStaticPool.ResetPool(groupId); } - public static void ResetOperandPools() + public static void DisposeOperandPools() { - ThreadStaticPool.ResetPools(); - ThreadStaticPool.ResetPools(); + ThreadStaticPool.DisposePools(); + ThreadStaticPool.DisposePools(); } + #endregion } } diff --git a/ARMeilleure/IntermediateRepresentation/OperationHelper.cs b/ARMeilleure/IntermediateRepresentation/OperationHelper.cs index 538bdac4..0e560ee0 100644 --- a/ARMeilleure/IntermediateRepresentation/OperationHelper.cs +++ b/ARMeilleure/IntermediateRepresentation/OperationHelper.cs @@ -4,11 +4,6 @@ namespace ARMeilleure.IntermediateRepresentation { static class OperationHelper { - public static Operation Operation() - { - return ThreadStaticPool.Instance.Allocate(); - } - public static Operation Operation(Instruction instruction, Operand destination) { return Operation().With(instruction, destination); @@ -46,19 +41,26 @@ namespace ARMeilleure.IntermediateRepresentation return Operation().With(instruction, destinations, sources); } - public static void PrepareOperationPool(bool highCq) + #region "ThreadStaticPool" + public static void PrepareOperationPool(int groupId = 0) { - ThreadStaticPool.PreparePool(highCq ? 1 : 0); + ThreadStaticPool.PreparePool(groupId, ChunkSizeLimit.Medium); + } + + private static Operation Operation() + { + return ThreadStaticPool.Instance.Allocate(); } - public static void ReturnOperationPool(bool highCq) + public static void ResetOperationPool(int groupId = 0) { - ThreadStaticPool.ReturnPool(highCq ? 1 : 0); + ThreadStaticPool.ResetPool(groupId); } - public static void ResetOperationPools() + public static void DisposeOperationPools() { - ThreadStaticPool.ResetPools(); + ThreadStaticPool.DisposePools(); } + #endregion } } -- cgit v1.2.3