Make EntryTable<T> expandable

* EntryTable is now expandable instead of being a fixed slab.
* Remove EntryTable<T>.TryAllocate
* Remove Counter<T>.TryCreate

Address LDj3SNuD's feedback
This commit is contained in:
FICTURE7 2021-04-16 18:20:05 +04:00
parent 5b4543e62c
commit 9c0dbb9c07
4 changed files with 155 additions and 95 deletions

View file

@ -57,7 +57,7 @@ namespace ARMeilleure.Translation
_backgroundTranslatorEvent = new AutoResetEvent(false);
_backgroundTranslatorLock = new ReaderWriterLock();
CountTable = new EntryTable<uint>(CountTableCapacity);
CountTable = new EntryTable<uint>();
JitCache.Initialize(allocator);
@ -174,6 +174,8 @@ namespace ARMeilleure.Translation
_jumpTable.Dispose();
_jumpTable = null;
CountTable.Dispose();
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
}
}
@ -393,14 +395,11 @@ namespace ARMeilleure.Translation
return context.GetControlFlowGraph();
}
internal static void EmitRejitCheck(ArmEmitterContext context, out Counter<uint> counter)
internal static Counter<uint> EmitRejitCheck(ArmEmitterContext context, out Counter<uint> counter)
{
const int MinsCallForRejit = 100;
if (!Counter<uint>.TryCreate(context.CountTable, out counter))
{
return;
}
counter = new Counter<uint>(context.CountTable);
Operand lblEnd = Label();
@ -413,6 +412,8 @@ namespace ARMeilleure.Translation
context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.EnqueueForRejit)), Const(context.EntryAddress));
context.MarkLabel(lblEnd);
return counter;
}
internal static void EmitSynchronization(EmitterContext context)