JIT optimizations and refactoring (#675)
* CPU/Recompiler: Use rel32 call where possible for no-args * JitCodeBuffer: Support using preallocated buffer * CPU/Recompiler/AArch64: Use bl instead of blr for short branches * CPU/CodeCache: Allocate recompiler buffer in program space This means we don't need 64-bit moves for every call out of the recompiler. * GTE: Don't store as u16 and load as u32 * CPU/Recompiler: Add methods to emit global load/stores * GTE: Convert class to namespace * CPU/Recompiler: Call GTE functions directly * Settings: Turn into a global variable * GPU: Replace local pointers with global * InterruptController: Turn into a global pointer * System: Replace local pointers with global * Timers: Turn into a global instance * DMA: Turn into a global instance * SPU: Turn into a global instance * CDROM: Turn into a global instance * MDEC: Turn into a global instance * Pad: Turn into a global instance * SIO: Turn into a global instance * CDROM: Move audio FIFO to the heap * CPU/Recompiler: Drop ASMFunctions No longer needed since we have code in the same 4GB window. * CPUCodeCache: Turn class into namespace * Bus: Local pointer -> global pointers * CPU: Turn class into namespace * Bus: Turn into namespace * GTE: Store registers in CPU state struct Allows relative addressing on ARM. * CPU/Recompiler: Align code storage to page size * CPU/Recompiler: Fix relative branches on A64 * HostInterface: Local references to global * System: Turn into a namespace, move events out * Add guard pages * Android: Fix build
This commit is contained in:
committed by
GitHub
parent
1f9fc6ab74
commit
b6f871d2b9
@ -1,67 +1,51 @@
|
||||
#pragma once
|
||||
#include "cpu_code_cache.h"
|
||||
#include "cpu_types.h"
|
||||
|
||||
class JitCodeBuffer;
|
||||
|
||||
namespace CPU {
|
||||
|
||||
struct CodeBlockInstruction;
|
||||
|
||||
class Core;
|
||||
namespace Recompiler::Thunks {
|
||||
|
||||
namespace Recompiler {
|
||||
|
||||
class Thunks
|
||||
union RaiseExceptionInfo
|
||||
{
|
||||
public:
|
||||
union RaiseExceptionInfo
|
||||
u32 bits;
|
||||
|
||||
struct
|
||||
{
|
||||
u32 bits;
|
||||
|
||||
struct
|
||||
{
|
||||
u8 excode;
|
||||
bool BD;
|
||||
u8 CE;
|
||||
u8 unused;
|
||||
};
|
||||
u8 excode;
|
||||
bool BD;
|
||||
u8 CE;
|
||||
u8 unused;
|
||||
};
|
||||
|
||||
static u32 MakeRaiseExceptionInfo(Exception excode, const CodeBlockInstruction& cbi);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Trampolines for calling back from the JIT
|
||||
// Needed because we can't cast member functions to void*...
|
||||
// TODO: Abuse carry flag or something else for exception
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static u64 ReadMemoryByte(Core* cpu, u32 pc, u32 address);
|
||||
static u64 ReadMemoryHalfWord(Core* cpu, u32 pc, u32 address);
|
||||
static u64 ReadMemoryWord(Core* cpu, u32 pc, u32 address);
|
||||
static bool WriteMemoryByte(Core* cpu, u32 pc, u32 address, u8 value);
|
||||
static bool WriteMemoryHalfWord(Core* cpu, u32 pc, u32 address, u16 value);
|
||||
static bool WriteMemoryWord(Core* cpu, u32 pc, u32 address, u32 value);
|
||||
static bool InterpretInstruction(Core* cpu);
|
||||
static void UpdateLoadDelay(Core* cpu);
|
||||
static void RaiseException(Core* cpu, u32 epc, u32 ri_bits);
|
||||
static void RaiseAddressException(Core* cpu, u32 address, bool store, bool branch);
|
||||
static void ExecuteGTEInstruction(Core* cpu, u32 instruction_bits);
|
||||
static u32 ReadGTERegister(Core* cpu, u32 reg);
|
||||
static void WriteGTERegister(Core* cpu, u32 reg, u32 value);
|
||||
};
|
||||
|
||||
class ASMFunctions
|
||||
ALWAYS_INLINE u32 MakeRaiseExceptionInfo(Exception excode, const CodeBlockInstruction& cbi)
|
||||
{
|
||||
public:
|
||||
bool (*read_memory_byte)(u32 address, u8* value);
|
||||
bool (*read_memory_word)(u32 address, u16* value);
|
||||
bool (*read_memory_dword)(u32 address, u32* value);
|
||||
void (*write_memory_byte)(u32 address, u8 value);
|
||||
void (*write_memory_word)(u32 address, u16 value);
|
||||
void (*write_memory_dword)(u32 address, u32 value);
|
||||
RaiseExceptionInfo ri = {};
|
||||
ri.excode = static_cast<u8>(excode);
|
||||
ri.BD = cbi.is_branch_delay_slot;
|
||||
ri.CE = cbi.instruction.cop.cop_n;
|
||||
return ri.bits;
|
||||
}
|
||||
|
||||
void Generate(JitCodeBuffer* code_buffer);
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Trampolines for calling back from the JIT
|
||||
// Needed because we can't cast member functions to void*...
|
||||
// TODO: Abuse carry flag or something else for exception
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool InterpretInstruction();
|
||||
void RaiseException(u32 epc, u32 ri_bits);
|
||||
void RaiseAddressException(u32 address, bool store, bool branch);
|
||||
|
||||
} // namespace Recompiler
|
||||
// Memory access functions for the JIT - MSB is set on exception.
|
||||
u64 ReadMemoryByte(u32 pc, u32 address);
|
||||
u64 ReadMemoryHalfWord(u32 pc, u32 address);
|
||||
u64 ReadMemoryWord(u32 pc, u32 address);
|
||||
bool WriteMemoryByte(u32 pc, u32 address, u8 value);
|
||||
bool WriteMemoryHalfWord(u32 pc, u32 address, u16 value);
|
||||
bool WriteMemoryWord(u32 pc, u32 address, u32 value);
|
||||
|
||||
} // namespace Recompiler::Thunks
|
||||
|
||||
} // namespace CPU
|
||||
Reference in New Issue
Block a user