1 // Copyright 2008 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #include "Core/PowerPC/JitCommon/JitBase.h"
6 
7 #include "Common/CommonTypes.h"
8 #include "Core/ConfigManager.h"
9 #include "Core/HW/CPU.h"
10 #include "Core/PowerPC/PPCAnalyst.h"
11 #include "Core/PowerPC/PowerPC.h"
12 
Dispatch(JitBase & jit)13 const u8* JitBase::Dispatch(JitBase& jit)
14 {
15   return jit.GetBlockCache()->Dispatch();
16 }
17 
JitTrampoline(JitBase & jit,u32 em_address)18 void JitTrampoline(JitBase& jit, u32 em_address)
19 {
20   jit.Jit(em_address);
21 }
22 
JitBase()23 JitBase::JitBase() : m_code_buffer(code_buffer_size)
24 {
25 }
26 
27 JitBase::~JitBase() = default;
28 
CanMergeNextInstructions(int count) const29 bool JitBase::CanMergeNextInstructions(int count) const
30 {
31   if (CPU::IsStepping() || js.instructionsLeft < count)
32     return false;
33   // Be careful: a breakpoint kills flags in between instructions
34   for (int i = 1; i <= count; i++)
35   {
36     if (SConfig::GetInstance().bEnableDebugging &&
37         PowerPC::breakpoints.IsAddressBreakPoint(js.op[i].address))
38       return false;
39     if (js.op[i].isBranchTarget)
40       return false;
41   }
42   return true;
43 }
44 
UpdateMemoryOptions()45 void JitBase::UpdateMemoryOptions()
46 {
47   bool any_watchpoints = PowerPC::memchecks.HasAny();
48   jo.fastmem = SConfig::GetInstance().bFastmem && jo.fastmem_arena && (MSR.DR || !any_watchpoints);
49   jo.memcheck = SConfig::GetInstance().bMMU || any_watchpoints;
50 }
51