0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 23:55:47 +00:00

LightningJit: Add a limit on the number of instructions per function for Arm64 (#6328)

This commit is contained in:
gdkchan 2024-02-17 17:30:54 -03:00 committed by GitHub
parent 103e7cb021
commit 42340fc743
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
{ {
static class Decoder static class Decoder
{ {
private const int MaxInstructionsPerBlock = 1000; private const int MaxInstructionsPerFunction = 10000;
private const uint NzcvFlags = 0xfu << 28; private const uint NzcvFlags = 0xfu << 28;
private const uint CFlag = 0x1u << 29; private const uint CFlag = 0x1u << 29;
@ -22,10 +22,11 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
bool hasHostCall = false; bool hasHostCall = false;
bool hasMemoryInstruction = false; bool hasMemoryInstruction = false;
int totalInsts = 0;
while (true) while (true)
{ {
Block block = Decode(cpuPreset, memoryManager, address, ref useMask, ref hasHostCall, ref hasMemoryInstruction); Block block = Decode(cpuPreset, memoryManager, address, ref totalInsts, ref useMask, ref hasHostCall, ref hasMemoryInstruction);
if (!block.IsTruncated && TryGetBranchTarget(block, out ulong targetAddress)) if (!block.IsTruncated && TryGetBranchTarget(block, out ulong targetAddress))
{ {
@ -230,6 +231,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
CpuPreset cpuPreset, CpuPreset cpuPreset,
IMemoryManager memoryManager, IMemoryManager memoryManager,
ulong address, ulong address,
ref int totalInsts,
ref RegisterMask useMask, ref RegisterMask useMask,
ref bool hasHostCall, ref bool hasHostCall,
ref bool hasMemoryInstruction) ref bool hasMemoryInstruction)
@ -272,7 +274,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
uint tempGprUseMask = gprUseMask | instGprReadMask | instGprWriteMask; uint tempGprUseMask = gprUseMask | instGprReadMask | instGprWriteMask;
if (CalculateAvailableTemps(tempGprUseMask) < CalculateRequiredGprTemps(tempGprUseMask) || insts.Count >= MaxInstructionsPerBlock) if (CalculateAvailableTemps(tempGprUseMask) < CalculateRequiredGprTemps(tempGprUseMask) || totalInsts++ >= MaxInstructionsPerFunction)
{ {
isTruncated = true; isTruncated = true;
address -= 4UL; address -= 4UL;