Skip to content

Commit

Permalink
Core: Clean up brace/body placements for JitIL
Browse files Browse the repository at this point in the history
  • Loading branch information
lioncash committed Aug 20, 2014
1 parent 03bacce commit 5edc151
Show file tree
Hide file tree
Showing 12 changed files with 1,838 additions and 810 deletions.
1,098 changes: 778 additions & 320 deletions Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp

Large diffs are not rendered by default.

42 changes: 32 additions & 10 deletions Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ namespace JitILProfiler
u64 codeHash;
u64 totalElapsed;
u64 numberOfCalls;
Block() : index(0), codeHash(0), totalElapsed(0), numberOfCalls(0) { }

Block() : index(0), codeHash(0), totalElapsed(0), numberOfCalls(0)
{
}
};

static std::vector<Block> blocks;
static u32 blockIndex;
static u64 beginTime;
Expand All @@ -188,13 +192,15 @@ namespace JitILProfiler
block.codeHash = codeHash;
return block;
}

// These functions need to be static because they are called with
// ABI_CallFunction().
static void Begin(u32 index)
{
blockIndex = index;
beginTime = __rdtsc();
}

static void End()
{
const u64 endTime = __rdtsc();
Expand All @@ -203,6 +209,7 @@ namespace JitILProfiler
block.totalElapsed += duration;
++block.numberOfCalls;
}

struct JitILProfilerFinalizer
{
virtual ~JitILProfilerFinalizer()
Expand All @@ -221,11 +228,13 @@ namespace JitILProfiler
}
}
};

static std::unique_ptr<JitILProfilerFinalizer> finalizer;
static void Init()
{
finalizer = std::make_unique<JitILProfilerFinalizer>();
}

static void Shutdown()
{
finalizer.reset();
Expand All @@ -246,10 +255,14 @@ void JitIL::Init()
else
{
if (!Core::g_CoreStartupParameter.bJITBlockLinking)
{
jo.enableBlocklink = false;
}
else
{
// Speed boost, but not 100% safe
jo.enableBlocklink = !Core::g_CoreStartupParameter.bMMU;
}
}

jo.fpAccurateFcmp = false;
Expand All @@ -268,7 +281,8 @@ void JitIL::Init()
code_block.m_gpa = &js.gpa;
code_block.m_fpa = &js.fpa;

if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling)
{
JitILProfiler::Init();
}
}
Expand All @@ -282,7 +296,8 @@ void JitIL::ClearCache()

void JitIL::Shutdown()
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling)
{
JitILProfiler::Shutdown();
}

Expand Down Expand Up @@ -352,11 +367,14 @@ static void ImHere()
PowerPC::ppcState.gpr[5], PowerPC::ppcState.gpr[6]);
f.Flush();
}
if (been_here.find(PC) != been_here.end()) {

if (been_here.find(PC) != been_here.end())
{
been_here.find(PC)->second++;
if ((been_here.find(PC)->second) & 1023)
return;
}

DEBUG_LOG(DYNA_REC, "I'm here - PC = %08x , LR = %08x", PC, LR);
been_here[PC] = 1;
}
Expand All @@ -376,7 +394,8 @@ void JitIL::Cleanup()
void JitIL::WriteExit(u32 destination)
{
Cleanup();
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling)
{
ABI_CallFunction((void *)JitILProfiler::End);
}
SUB(32, M(&PowerPC::ppcState.downcount), Imm32(js.downcountAmount));
Expand Down Expand Up @@ -408,7 +427,8 @@ void JitIL::WriteExitDestInOpArg(const Gen::OpArg& arg)
{
MOV(32, M(&PC), arg);
Cleanup();
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling)
{
ABI_CallFunction((void *)JitILProfiler::End);
}
SUB(32, M(&PowerPC::ppcState.downcount), Imm32(js.downcountAmount));
Expand All @@ -420,7 +440,8 @@ void JitIL::WriteRfiExitDestInOpArg(const Gen::OpArg& arg)
MOV(32, M(&PC), arg);
MOV(32, M(&NPC), arg);
Cleanup();
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling)
{
ABI_CallFunction((void *)JitILProfiler::End);
}
ABI_CallFunction(reinterpret_cast<void *>(&PowerPC::CheckExceptions));
Expand All @@ -431,7 +452,8 @@ void JitIL::WriteRfiExitDestInOpArg(const Gen::OpArg& arg)
void JitIL::WriteExceptionExit()
{
Cleanup();
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling) {
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling)
{
ABI_CallFunction((void *)JitILProfiler::End);
}
MOV(32, R(EAX), M(&PC));
Expand Down Expand Up @@ -554,7 +576,7 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc

u64 codeHash = -1;
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILTimeProfiling ||
SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILOutputIR)
SConfig::GetInstance().m_LocalCoreStartupParameter.bJITILOutputIR)
{
// For profiling and IR Writer
for (u32 i = 0; i < code_block.m_num_instructions; i++)
Expand All @@ -577,7 +599,7 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc

js.downcountAmount = 0;
if (!Core::g_CoreStartupParameter.bEnableDebugging)
js.downcountAmount += PatchEngine::GetSpeedhackCycles(code_block.m_address);
js.downcountAmount += PatchEngine::GetSpeedhackCycles(code_block.m_address);

// Translate instructions
for (u32 i = 0; i < code_block.m_num_instructions; i++)
Expand Down
11 changes: 7 additions & 4 deletions Source/Core/Core/PowerPC/Jit64IL/JitIL.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,22 @@ class JitIL : public JitILBase, public EmuCodeBlock
bool IsInCodeSpace(u8 *ptr) override { return IsInSpace(ptr); }

void ClearCache() override;
const u8 *GetDispatcher() {
const u8 *GetDispatcher()
{
return asm_routines.dispatcher; // asm_routines.dispatcher
}
const CommonAsmRoutines *GetAsmRoutines() override {

const CommonAsmRoutines *GetAsmRoutines() override
{
return &asm_routines;
}

const char *GetName() override {
const char *GetName() override
{
return "JIT64IL";
}

// Run!

void Run() override;
void SingleStep() override;

Expand Down
10 changes: 7 additions & 3 deletions Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,19 @@ void CompileInstruction(PPCAnalyst::CodeOp & op)
JitIL *jitil = (JitIL *)jit;
(jitil->*dynaOpTable[op.inst.OPCD])(op.inst);
GekkoOPInfo *info = op.opinfo;
if (info) {
if (info)
{
#ifdef OPLOG
if (!strcmp(info->opname, OP_TO_LOG)){ ///"mcrfs"
if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs"
{
rsplocations.push_back(jit.js.compilerPC);
}
#endif
info->compileCount++;
info->lastUse = jit->js.compilerPC;
} else {
}
else
{
PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", op.inst.hex, jit->js.compilerPC);
}
}
Expand Down

0 comments on commit 5edc151

Please sign in to comment.