aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Translation/PTC
diff options
context:
space:
mode:
authorLDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>2021-01-12 19:04:02 +0100
committerGitHub <noreply@github.com>2021-01-12 19:04:02 +0100
commit68f6b79fd3f06ea572d5f0edd5fc8cbaee1ae449 (patch)
treea4cf471c7979f85c3bf894f65129f2cb85931dc3 /ARMeilleure/Translation/PTC
parente57b14042910eac2f876549b4a1e6fd5ba027368 (diff)
Add a simple Pools Limiter. (#1830)
* Added support for offline invalidation, via PPTC, of low cq translations replaced by high cq translations; both on a single run and between runs. Added invalidation of .cache files in the event of reuse on a different user operating system. Added .info and .cache files invalidation in case of a failed stream decompression. Nits. * InternalVersion = 1712; * Nits. * Address comment. * Get rid of BinaryFormatter. Nits. * Move Ptc.LoadTranslations(). Nits. * Nits. * Fixed corner cases (in case backup copies have to be used). Added save logs. * Not core fixes. * Complement to the previous commit. Added load logs. Removed BinaryFormatter leftovers. * Add LoadTranslations log. * Nits. * Removed the search and management of LowCq overlapping functions. * Final increment of .info and .cache flags. * Nit. * Free up memory allocated by Pools during any PPTC translations at boot time. * Nit due to rebase. * Add a simple Pools Limiter. * Nits. * Fix missing JumpTable.RegisterFunction() due to rebase. Clear MemoryStreams as soon as possible, when they are no longer needed. * Code cleaning. * Nit for retrigger Checks. * Update Ptc.cs * Contextual refactoring of Translator. Ignore resetting of pools for DirectCallStubs. * Nit for retrigger Checks.
Diffstat (limited to 'ARMeilleure/Translation/PTC')
-rw-r--r--ARMeilleure/Translation/PTC/Ptc.cs16
1 files changed, 11 insertions, 5 deletions
diff --git a/ARMeilleure/Translation/PTC/Ptc.cs b/ARMeilleure/Translation/PTC/Ptc.cs
index f382cc63..8f250a55 100644
--- a/ARMeilleure/Translation/PTC/Ptc.cs
+++ b/ARMeilleure/Translation/PTC/Ptc.cs
@@ -98,7 +98,6 @@ namespace ARMeilleure.Translation.PTC
ClearMemoryStreams();
PtcJumpTable.Clear();
- PtcProfiler.Stop();
PtcProfiler.Wait();
PtcProfiler.ClearEntries();
@@ -345,6 +344,8 @@ namespace ARMeilleure.Translation.PTC
private static void Save(string fileName)
{
+ int translatedFuncsCount;
+
using (MemoryStream stream = new MemoryStream())
using (MD5 md5 = MD5.Create())
{
@@ -361,6 +362,11 @@ namespace ARMeilleure.Translation.PTC
PtcJumpTable.Serialize(stream, PtcJumpTable);
+ translatedFuncsCount = GetInfosEntriesCount();
+
+ ClearMemoryStreams();
+ PtcJumpTable.Clear();
+
stream.Seek((long)hashSize, SeekOrigin.Begin);
byte[] hash = md5.ComputeHash(stream);
@@ -388,7 +394,7 @@ namespace ARMeilleure.Translation.PTC
long fileSize = new FileInfo(fileName).Length;
- Logger.Info?.Print(LogClass.Ptc, $"Saved Translation Cache (size: {fileSize} bytes, translated functions: {GetInfosEntriesCount()}).");
+ Logger.Info?.Print(LogClass.Ptc, $"Saved Translation Cache (size: {fileSize} bytes, translated functions: {translatedFuncsCount}).");
}
private static void WriteHeader(MemoryStream stream)
@@ -709,10 +715,10 @@ namespace ARMeilleure.Translation.PTC
threads.Clear();
- _loggerEvent.Set();
-
Translator.ResetPools();
+ _loggerEvent.Set();
+
PtcJumpTable.Initialize(jumpTable);
PtcJumpTable.ReadJumpTable(jumpTable);
@@ -736,7 +742,7 @@ namespace ARMeilleure.Translation.PTC
Logger.Info?.Print(LogClass.Ptc, $"{_translateCount} of {profiledFuncsToTranslateCount} functions translated");
}
- internal static void WriteInfoCodeReloc(ulong address, ulong guestSize, bool highCq, PtcInfo ptcInfo)
+ internal static void WriteInfoCodeRelocUnwindInfo(ulong address, ulong guestSize, bool highCq, PtcInfo ptcInfo)
{
lock (_lock)
{