mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-24 11:48:39 +08:00
rework TLS allocations, more HLE's, increase import loop history
This commit is contained in:
@@ -231,9 +231,6 @@ public sealed partial class DirectExecutionBackend
|
||||
ProbeReturnRip(num7, num);
|
||||
Console.Error.Flush();
|
||||
}
|
||||
ProbeReturnRip(0x0000000800EA020Eul, 999001);
|
||||
ProbeReturnRip(0x0000000800EA0213ul, 999002);
|
||||
ProbeReturnRip(0x0000000800EA040Aul, 999003);
|
||||
try
|
||||
{
|
||||
OrbisGen2Result orbisGen2Result;
|
||||
@@ -426,7 +423,20 @@ public sealed partial class DirectExecutionBackend
|
||||
return false;
|
||||
}
|
||||
int num2 = CountDistinctImportLoopValuesFromTail(_importLoopReturnRips, sampleCount, 3);
|
||||
return num2 <= 2;
|
||||
if (num2 > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num3 = Math.Min(_importLoopSignatureCount, Math.Max(sampleCount * 8, ImportLoopWideDiversityWindow));
|
||||
if (num3 <= sampleCount)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (CountDistinctImportLoopValuesFromTail(_importLoopNidHashes, num3, 3) > 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return CountDistinctImportLoopValuesFromTail(_importLoopReturnRips, num3, 3) <= 2;
|
||||
}
|
||||
|
||||
private int CountDistinctImportLoopValuesFromTail(ulong[] source, int sampleCount, int stopAfter)
|
||||
|
||||
@@ -13,6 +13,10 @@ namespace SharpEmu.Core.Cpu.Native;
|
||||
|
||||
public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, IDisposable
|
||||
{
|
||||
private const int ImportLoopHistoryLength = 2048;
|
||||
|
||||
private const int ImportLoopWideDiversityWindow = 768;
|
||||
|
||||
private readonly struct ImportStubEntry
|
||||
{
|
||||
public ulong Address { get; }
|
||||
@@ -89,7 +93,7 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
||||
|
||||
private const uint PAGE_EXECUTE_READ = 32u;
|
||||
|
||||
private const int TlsHandlerRegionSize = 4096;
|
||||
private const int TlsHandlerRegionSize = 16384;
|
||||
|
||||
private const ulong TlsModuleAllocStart = 140726751354880uL;
|
||||
|
||||
@@ -179,11 +183,11 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
||||
|
||||
private ulong _entryReturnSentinelRip;
|
||||
|
||||
private readonly ulong[] _importLoopSignatures = new ulong[192];
|
||||
private readonly ulong[] _importLoopSignatures = new ulong[ImportLoopHistoryLength];
|
||||
|
||||
private readonly ulong[] _importLoopNidHashes = new ulong[192];
|
||||
private readonly ulong[] _importLoopNidHashes = new ulong[ImportLoopHistoryLength];
|
||||
|
||||
private readonly ulong[] _importLoopReturnRips = new ulong[192];
|
||||
private readonly ulong[] _importLoopReturnRips = new ulong[ImportLoopHistoryLength];
|
||||
|
||||
private int _importLoopSignatureCount;
|
||||
|
||||
@@ -601,14 +605,6 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I
|
||||
{
|
||||
return exportName switch
|
||||
{
|
||||
"_init_env" or
|
||||
"atexit" or
|
||||
"strlen" or
|
||||
"strnlen" or
|
||||
"strcmp" or
|
||||
"strncmp" or
|
||||
"strcpy" or
|
||||
"strncpy" or
|
||||
"memcpy" or
|
||||
"memmove" or
|
||||
"memset" or
|
||||
|
||||
Reference in New Issue
Block a user