NesHawk - about a 5-10% speedp by using AggressiveInlining. Performance sensitive methods were analyzed, and I only added it to methods that failed inlining only due to the 32 IL byte limit but still reasonably sized. This attribute only lifts the 32 byte limit, it's important to do this analysis and not just apply this attribute with research.

This commit is contained in:
adelikat 2020-04-21 09:18:05 -05:00
parent 1fd5b80d28
commit 4386509f01
4 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,7 @@
//http://nesdev.parodius.com/6502_cpu.txt
using System;
using System.Runtime.CompilerServices;
using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
@ -2708,6 +2709,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502
rdy_freeze = true;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void ExecuteOneRetry()
{
//don't know whether this system is any faster. hard to get benchmarks someone else try it?
@ -2965,6 +2967,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ExecuteOne()
{
// total cycles now increments every time a cycle is called to accurately count during RDY
@ -2977,7 +2980,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502
if (!rdy_freeze)
mi++;
} //ExecuteOne
}
public bool AtInstructionStart()
{

View File

@ -11,6 +11,7 @@
// TODO - refactor length counter to be separate component
using System;
using System.Runtime.CompilerServices;
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
@ -258,6 +259,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run()
{
if (env_constant == 1)
@ -458,6 +460,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
len_cnt--;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run()
{
if (env_constant == 1)
@ -584,6 +587,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public int Debug_PeriodValue => timer_cnt;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run()
{
// when clocked by timer, seq steps forward
@ -705,6 +709,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.EndSection();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run()
{
if (timer > 0) timer--;
@ -1215,6 +1220,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int pending_length_change;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RunOneFirst()
{

View File

@ -7,6 +7,7 @@
//};
using System;
using System.Runtime.CompilerServices;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.NES
@ -184,11 +185,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
v &= 1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int get_ntread()
{
return 0x2000 | (v << 0xB) | (h << 0xA) | (vt << 5) | ht;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int get_2007access()
{
return ((fv & 3) << 0xC) | (v << 0xB) | (h << 0xA) | (vt << 5) | ht;
@ -200,6 +203,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//are used in the diagram to represent the right-shift position amount to
//apply to the data read from the attribute data (a is always 0). This is why
//you only see bits 0 and 1 used off the read attribute data in the diagram.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int get_atread()
{
return 0x2000 | (v << 0xB) | (h << 0xA) | 0x3C0 | ((vt & 0x1C) << 1) | ((ht & 0x1C) >> 2);

View File

@ -2,6 +2,7 @@
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
using System.Runtime.CompilerServices;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
@ -78,12 +79,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
//address line 3 relates to the pattern table fetch occuring (the PPU always makes them in pairs).
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int get_ptread(int par)
{
int hi = reg_2000.bg_pattern_hi;
return (hi << 0xC) | (par << 0x4) | ppur.fv;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void Read_bgdata(int cycle, int i)
{
switch (cycle)