From ca014d07d630b229dfddf0ecf00b27ecf41c2a58 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Tue, 11 Dec 2018 19:39:32 +0100 Subject: [PATCH] Inline exception processing methods. --- DotN64/CPU/VR4300/VR4300.ExceptionProcessing.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/DotN64/CPU/VR4300/VR4300.ExceptionProcessing.cs b/DotN64/CPU/VR4300/VR4300.ExceptionProcessing.cs index 2cf8501..c567bf7 100644 --- a/DotN64/CPU/VR4300/VR4300.ExceptionProcessing.cs +++ b/DotN64/CPU/VR4300/VR4300.ExceptionProcessing.cs @@ -1,4 +1,6 @@ -namespace DotN64.CPU +using System.Runtime.CompilerServices; + +namespace DotN64.CPU { public partial class VR4300 { @@ -15,12 +17,14 @@ #endregion #region Methods + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void HandleReset(VR4300 cpu) { cpu.CP0.Registers[(int)SystemControlUnit.RegisterIndex.ErrorEPC] = cpu.PC; cpu.PC = ResetVector; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void HandleGeneral(VR4300 cpu, SystemControlUnit.CauseRegister.ExceptionCode excCode, byte? ce = null) { cpu.CP0.Cause.ExcCode = excCode; @@ -42,6 +46,7 @@ cpu.PC = (cpu.CP0.Status.DS.BEV ? GeneralVectorBEV : GeneralVector) + GeneralVectorOffset; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ColdReset(VR4300 cpu) { var ds = cpu.CP0.Status.DS; @@ -61,8 +66,10 @@ HandleReset(cpu); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Interrupt(VR4300 cpu) => HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.Int); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ReservedInstruction(VR4300 cpu, Instruction instruction) { HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.RI); @@ -70,8 +77,10 @@ throw new UnimplementedOperationException(instruction); // TODO: Remove this and the parameter once every instruction gets implemented. } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CoprocessorUnusable(VR4300 cpu, byte unit) => HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.CpU, unit); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void FloatingPoint(VR4300 cpu) => HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.FPE); #endregion }