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 998be765cf.
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

@ -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<GuestFunction>(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<GuestFunction>(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