aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Translation/Translator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ARMeilleure/Translation/Translator.cs')
-rw-r--r--ARMeilleure/Translation/Translator.cs46
1 files changed, 36 insertions, 10 deletions
diff --git a/ARMeilleure/Translation/Translator.cs b/ARMeilleure/Translation/Translator.cs
index 2edbe401..77ccdaea 100644
--- a/ARMeilleure/Translation/Translator.cs
+++ b/ARMeilleure/Translation/Translator.cs
@@ -44,6 +44,8 @@ namespace ARMeilleure.Translation
private readonly IJitMemoryAllocator _allocator;
private readonly ConcurrentQueue<KeyValuePair<ulong, TranslatedFunction>> _oldFuncs;
+ private readonly Ptc _ptc;
+
internal TranslatorCache<TranslatedFunction> Functions { get; }
internal AddressTable<ulong> FunctionTable { get; }
internal EntryTable<uint> CountTable { get; }
@@ -63,6 +65,8 @@ namespace ARMeilleure.Translation
_oldFuncs = new ConcurrentQueue<KeyValuePair<ulong, TranslatedFunction>>();
+ _ptc = new Ptc();
+
Queue = new TranslatorQueue();
JitCache.Initialize(allocator);
@@ -80,22 +84,37 @@ namespace ARMeilleure.Translation
}
}
+ public IPtcLoadState LoadDiskCache(string titleIdText, string displayVersion, bool enabled)
+ {
+ _ptc.Initialize(titleIdText, displayVersion, enabled, Memory.Type);
+ return _ptc;
+ }
+
+ public void PrepareCodeRange(ulong address, ulong size)
+ {
+ if (_ptc.Profiler.StaticCodeSize == 0)
+ {
+ _ptc.Profiler.StaticCodeStart = address;
+ _ptc.Profiler.StaticCodeSize = size;
+ }
+ }
+
public void Execute(State.ExecutionContext context, ulong address)
{
if (Interlocked.Increment(ref _threadCount) == 1)
{
IsReadyForTranslation.WaitOne();
- if (Ptc.State == PtcState.Enabled)
+ if (_ptc.State == PtcState.Enabled)
{
Debug.Assert(Functions.Count == 0);
- Ptc.LoadTranslations(this);
- Ptc.MakeAndSaveTranslations(this);
+ _ptc.LoadTranslations(this);
+ _ptc.MakeAndSaveTranslations(this);
}
- PtcProfiler.Start();
+ _ptc.Profiler.Start();
- Ptc.Disable();
+ _ptc.Disable();
// Simple heuristic, should be user configurable in future. (1 for 4 core/ht or less, 2 for 6 core + ht
// etc). All threads are normal priority except from the last, which just fills as much of the last core
@@ -148,6 +167,12 @@ namespace ARMeilleure.Translation
Stubs.Dispose();
FunctionTable.Dispose();
CountTable.Dispose();
+
+ _ptc.Close();
+ _ptc.Profiler.Stop();
+
+ _ptc.Dispose();
+ _ptc.Profiler.Dispose();
}
}
@@ -189,9 +214,9 @@ namespace ARMeilleure.Translation
func = oldFunc;
}
- if (PtcProfiler.Enabled)
+ if (_ptc.Profiler.Enabled)
{
- PtcProfiler.AddEntry(address, mode, highCq: false);
+ _ptc.Profiler.AddEntry(address, mode, highCq: false);
}
RegisterFunction(address, func);
@@ -217,6 +242,7 @@ namespace ARMeilleure.Translation
Stubs,
address,
highCq,
+ _ptc.State != PtcState.Disabled,
mode: Aarch32Mode.User);
Logger.StartPass(PassName.Decoding);
@@ -262,7 +288,7 @@ namespace ARMeilleure.Translation
{
Hash128 hash = Ptc.ComputeHash(Memory, address, funcSize);
- Ptc.WriteCompiledFunction(address, funcSize, hash, highCq, compiledFunc);
+ _ptc.WriteCompiledFunction(address, funcSize, hash, highCq, compiledFunc);
}
GuestFunction func = compiledFunc.Map<GuestFunction>();
@@ -284,9 +310,9 @@ namespace ARMeilleure.Translation
return func;
});
- if (PtcProfiler.Enabled)
+ if (_ptc.Profiler.Enabled)
{
- PtcProfiler.UpdateEntry(request.Address, request.Mode, highCq: true);
+ _ptc.Profiler.UpdateEntry(request.Address, request.Mode, highCq: true);
}
RegisterFunction(request.Address, func);