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. --- ARMeilleure/Translation/Translator.cs | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'ARMeilleure/Translation/Translator.cs') diff --git a/ARMeilleure/Translation/Translator.cs b/ARMeilleure/Translation/Translator.cs index ac96475f..f64912b3 100644 --- a/ARMeilleure/Translation/Translator.cs +++ b/ARMeilleure/Translation/Translator.cs @@ -11,8 +11,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime; using System.Threading; +using static ARMeilleure.Common.BitMapPool; using static ARMeilleure.IntermediateRepresentation.OperandHelper; using static ARMeilleure.IntermediateRepresentation.OperationHelper; @@ -148,10 +150,12 @@ namespace ARMeilleure.Translation ClearJitCache(); - ResetPools(); + DisposePools(); _jumpTable.Dispose(); _jumpTable = null; + + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; } } @@ -207,7 +211,7 @@ namespace ARMeilleure.Translation Logger.EndPass(PassName.Decoding); - PreparePool(highCq); + PreparePool(highCq ? 1 : 0); Logger.StartPass(PassName.Translation); @@ -240,13 +244,15 @@ namespace ARMeilleure.Translation { func = Compiler.Compile(cfg, argTypes, OperandType.I64, options); - ReturnPool(highCq); + ResetPool(highCq ? 1 : 0); } - else using (PtcInfo ptcInfo = new PtcInfo()) + else { + using PtcInfo ptcInfo = new PtcInfo(); + func = Compiler.Compile(cfg, argTypes, OperandType.I64, options, ptcInfo); - ReturnPool(highCq); + ResetPool(highCq ? 1 : 0); Ptc.WriteInfoCodeRelocUnwindInfo(address, funcSize, highCq, ptcInfo); } @@ -254,22 +260,23 @@ namespace ARMeilleure.Translation return new TranslatedFunction(func, funcSize, highCq); } - internal static void PreparePool(bool highCq) + internal static void PreparePool(int groupId = 0) { - PrepareOperandPool(highCq); - PrepareOperationPool(highCq); + PrepareOperandPool(groupId); + PrepareOperationPool(groupId); } - internal static void ReturnPool(bool highCq) + internal static void ResetPool(int groupId = 0) { - ReturnOperandPool(highCq); - ReturnOperationPool(highCq); + ResetOperationPool(groupId); + ResetOperandPool(groupId); } - internal static void ResetPools() + internal static void DisposePools() { - ResetOperandPools(); - ResetOperationPools(); + DisposeOperandPools(); + DisposeOperationPools(); + DisposeBitMapPools(); } private struct Range -- cgit v1.2.3