System: Refactor main loop
Reduces JIT exits. Improves runahead performance.
This commit is contained in:
@ -12,13 +12,13 @@ void RaiseException(Exception excode);
|
||||
void RaiseException(u32 CAUSE_bits, u32 EPC);
|
||||
void RaiseBreakException(u32 CAUSE_bits, u32 EPC, u32 instruction_bits);
|
||||
|
||||
ALWAYS_INLINE bool HasPendingInterrupt()
|
||||
ALWAYS_INLINE static bool HasPendingInterrupt()
|
||||
{
|
||||
return g_state.cop0_regs.sr.IEc &&
|
||||
(((g_state.cop0_regs.cause.bits & g_state.cop0_regs.sr.bits) & (UINT32_C(0xFF) << 8)) != 0);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void CheckForPendingInterrupt()
|
||||
ALWAYS_INLINE static void CheckForPendingInterrupt()
|
||||
{
|
||||
if (HasPendingInterrupt())
|
||||
g_state.downcount = 0;
|
||||
@ -28,36 +28,36 @@ void DispatchInterrupt();
|
||||
void UpdateDebugDispatcherFlag();
|
||||
|
||||
// icache stuff
|
||||
ALWAYS_INLINE bool IsCachedAddress(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static bool IsCachedAddress(VirtualMemoryAddress address)
|
||||
{
|
||||
// KUSEG, KSEG0
|
||||
return (address >> 29) <= 4;
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheLine(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static u32 GetICacheLine(VirtualMemoryAddress address)
|
||||
{
|
||||
return ((address >> 4) & 0xFFu);
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheLineOffset(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static u32 GetICacheLineOffset(VirtualMemoryAddress address)
|
||||
{
|
||||
return (address & (ICACHE_LINE_SIZE - 1));
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheTagForAddress(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static u32 GetICacheTagForAddress(VirtualMemoryAddress address)
|
||||
{
|
||||
return (address & ICACHE_TAG_ADDRESS_MASK);
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheFillTagForAddress(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static u32 GetICacheFillTagForAddress(VirtualMemoryAddress address)
|
||||
{
|
||||
static const u32 invalid_bits[4] = {0, 1, 3, 7};
|
||||
return GetICacheTagForAddress(address) | invalid_bits[(address >> 2) & 0x03u];
|
||||
}
|
||||
ALWAYS_INLINE u32 GetICacheTagMaskForAddress(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static u32 GetICacheTagMaskForAddress(VirtualMemoryAddress address)
|
||||
{
|
||||
static const u32 mask[4] = {ICACHE_TAG_ADDRESS_MASK | 1, ICACHE_TAG_ADDRESS_MASK | 2, ICACHE_TAG_ADDRESS_MASK | 4,
|
||||
ICACHE_TAG_ADDRESS_MASK | 8};
|
||||
return mask[(address >> 2) & 0x03u];
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool CompareICacheTag(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static bool CompareICacheTag(VirtualMemoryAddress address)
|
||||
{
|
||||
const u32 line = GetICacheLine(address);
|
||||
return ((g_state.icache_tags[line] & GetICacheTagMaskForAddress(address)) == GetICacheTagForAddress(address));
|
||||
@ -68,7 +68,7 @@ TickCount GetICacheFillTicks(VirtualMemoryAddress address);
|
||||
u32 FillICache(VirtualMemoryAddress address);
|
||||
void CheckAndUpdateICacheTags(u32 line_count, TickCount uncached_ticks);
|
||||
|
||||
ALWAYS_INLINE Segment GetSegmentForAddress(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static Segment GetSegmentForAddress(VirtualMemoryAddress address)
|
||||
{
|
||||
switch ((address >> 29))
|
||||
{
|
||||
@ -91,12 +91,12 @@ ALWAYS_INLINE Segment GetSegmentForAddress(VirtualMemoryAddress address)
|
||||
}
|
||||
}
|
||||
|
||||
ALWAYS_INLINE PhysicalMemoryAddress VirtualAddressToPhysical(VirtualMemoryAddress address)
|
||||
ALWAYS_INLINE static constexpr PhysicalMemoryAddress VirtualAddressToPhysical(VirtualMemoryAddress address)
|
||||
{
|
||||
return (address & PHYSICAL_MEMORY_ADDRESS_MASK);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE VirtualMemoryAddress PhysicalAddressToVirtual(PhysicalMemoryAddress address, Segment segment)
|
||||
ALWAYS_INLINE static VirtualMemoryAddress PhysicalAddressToVirtual(PhysicalMemoryAddress address, Segment segment)
|
||||
{
|
||||
static constexpr std::array<VirtualMemoryAddress, 4> bases = {{0x00000000, 0x80000000, 0xA0000000, 0xE0000000}};
|
||||
return bases[static_cast<u32>(segment)] | address;
|
||||
@ -115,12 +115,12 @@ bool WriteMemoryWord(VirtualMemoryAddress addr, u32 value);
|
||||
void* GetDirectReadMemoryPointer(VirtualMemoryAddress address, MemoryAccessSize size, TickCount* read_ticks);
|
||||
void* GetDirectWriteMemoryPointer(VirtualMemoryAddress address, MemoryAccessSize size);
|
||||
|
||||
ALWAYS_INLINE void AddGTETicks(TickCount ticks)
|
||||
ALWAYS_INLINE static void AddGTETicks(TickCount ticks)
|
||||
{
|
||||
g_state.gte_completion_tick = g_state.pending_ticks + ticks + 1;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void StallUntilGTEComplete()
|
||||
ALWAYS_INLINE static void StallUntilGTEComplete()
|
||||
{
|
||||
g_state.pending_ticks =
|
||||
(g_state.gte_completion_tick > g_state.pending_ticks) ? g_state.gte_completion_tick : g_state.pending_ticks;
|
||||
|
||||
Reference in New Issue
Block a user