Apply suggestions from code review
Address gdkchan's feedback Co-authored-by: gdkchan <gab.dark.100@gmail.com>
This commit is contained in:
parent
68bff558db
commit
f443167da8
4 changed files with 33 additions and 16 deletions
|
@ -16,7 +16,7 @@ namespace ARMeilleure.Common
|
|||
/// Initializes a new instance of the <see cref="Counter{T}"/> class from the specified
|
||||
/// <see cref="EntryTable{T}"/> instance and index.
|
||||
/// </summary>
|
||||
/// <param name="countTable"><see cref="EntryTable{byte}"/> instance</param>
|
||||
/// <param name="countTable"><see cref="EntryTable{T}"/> instance</param>
|
||||
/// <param name="index">Index in the <see cref="EntryTable{T}"/></param>
|
||||
private Counter(EntryTable<T> countTable, int index)
|
||||
{
|
||||
|
@ -41,9 +41,9 @@ namespace ARMeilleure.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to create a <see cref="Counter"/> instance from the specified <see cref="EntryTable{byte}"/> instance.
|
||||
/// Tries to create a <see cref="Counter"/> instance from the specified <see cref="EntryTable{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="countTable"><see cref="EntryTable{TEntry}"/> from which to create the <see cref="Counter"/></param>
|
||||
/// <param name="countTable"><see cref="EntryTable{T}"/> from which to create the <see cref="Counter"/></param>
|
||||
/// <param name="counter"><see cref="Counter"/> instance if success; otherwise <see langword="null"/></param>
|
||||
/// <returns><see langword="true"/> if success; otherwise <see langword="false"/></returns>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="countTable"/> is <see langword="null"/></exception>
|
||||
|
@ -90,4 +90,4 @@ namespace ARMeilleure.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace ARMeilleure.Common
|
|||
private readonly BitMap _allocated;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EntryTable{TValue}"/> class with the specified capacity.
|
||||
/// Initializes a new instance of the <see cref="EntryTable{TEntry}"/> class with the specified capacity.
|
||||
/// </summary>
|
||||
/// <param name="capacity">Capacity of the table</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0</exception>
|
||||
|
@ -31,7 +31,7 @@ namespace ARMeilleure.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to allocate an entry in the <see cref="EntryTable{TValue}"/>. Returns <see langword="true"/> if
|
||||
/// Tries to allocate an entry in the <see cref="EntryTable{TEntry}"/>. Returns <see langword="true"/> if
|
||||
/// success; otherwise returns <see langword="false"/>.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of entry allocated in the table</param>
|
||||
|
|
|
@ -540,8 +540,11 @@ namespace ARMeilleure.Translation.PTC
|
|||
}
|
||||
}
|
||||
|
||||
internal static void LoadTranslations(ConcurrentDictionary<ulong, TranslatedFunction> funcs, IMemoryManager memory,
|
||||
JumpTable jumpTable, EntryTable<uint> countTable)
|
||||
internal static void LoadTranslations(
|
||||
ConcurrentDictionary<ulong, TranslatedFunction> funcs,
|
||||
IMemoryManager memory,
|
||||
JumpTable jumpTable,
|
||||
EntryTable<uint> countTable)
|
||||
{
|
||||
if (AreCarriersEmpty())
|
||||
{
|
||||
|
@ -680,8 +683,13 @@ namespace ARMeilleure.Translation.PTC
|
|||
return relocEntries;
|
||||
}
|
||||
|
||||
private static bool PatchCode(Span<byte> code, RelocEntry[] relocEntries, IntPtr pageTablePointer,
|
||||
JumpTable jumpTable, EntryTable<uint> countTable, out Counter<uint> callCounter)
|
||||
private static bool PatchCode(
|
||||
Span<byte> code,
|
||||
RelocEntry[] relocEntries,
|
||||
IntPtr pageTablePointer,
|
||||
JumpTable jumpTable,
|
||||
EntryTable<uint> countTable,
|
||||
out Counter<uint> callCounter)
|
||||
{
|
||||
callCounter = null;
|
||||
|
||||
|
@ -747,8 +755,12 @@ namespace ARMeilleure.Translation.PTC
|
|||
return new UnwindInfo(pushEntries, prologueSize);
|
||||
}
|
||||
|
||||
private static TranslatedFunction FastTranslate(byte[] code, Counter<uint> callCounter, ulong guestSize,
|
||||
UnwindInfo unwindInfo, bool highCq)
|
||||
private static TranslatedFunction FastTranslate(
|
||||
byte[] code,
|
||||
Counter<uint> callCounter,
|
||||
ulong guestSize,
|
||||
UnwindInfo unwindInfo,
|
||||
bool highCq)
|
||||
{
|
||||
CompiledFunction cFunc = new CompiledFunction(code, unwindInfo);
|
||||
|
||||
|
@ -797,8 +809,11 @@ namespace ARMeilleure.Translation.PTC
|
|||
}
|
||||
}
|
||||
|
||||
internal static void MakeAndSaveTranslations(ConcurrentDictionary<ulong, TranslatedFunction> funcs, IMemoryManager memory,
|
||||
JumpTable jumpTable, EntryTable<uint> countTable)
|
||||
internal static void MakeAndSaveTranslations(
|
||||
ConcurrentDictionary<ulong, TranslatedFunction> funcs,
|
||||
IMemoryManager memory,
|
||||
JumpTable jumpTable,
|
||||
EntryTable<uint> countTable)
|
||||
{
|
||||
var profiledFuncsToTranslate = PtcProfiler.GetProfiledFuncsToTranslate(funcs);
|
||||
|
||||
|
@ -1085,4 +1100,4 @@ namespace ARMeilleure.Translation.PTC
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace ARMeilleure.Translation
|
|||
{
|
||||
public class Translator
|
||||
{
|
||||
private const int CountTableCapacity = 4 * 1024 * 1024;
|
||||
|
||||
private long _nextUpdate;
|
||||
private long _requestAdded;
|
||||
private long _requestRemoved;
|
||||
|
@ -61,7 +63,7 @@ namespace ARMeilleure.Translation
|
|||
_backgroundTranslatorEvent = new AutoResetEvent(false);
|
||||
_backgroundTranslatorLock = new ReaderWriterLock();
|
||||
|
||||
CountTable = new EntryTable<uint>(capacity: 4 * 1024 * 1024);
|
||||
CountTable = new EntryTable<uint>(CountTableCapacity);
|
||||
|
||||
JitCache.Initialize(allocator);
|
||||
|
||||
|
|
Loading…
Reference in a new issue