From 3ee31890d35bf4741f283dc76ac004a93acc9897 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Jan 2017 05:14:19 -0500 Subject: [PATCH 1/3] Jit64_Tables: Eliminate usages of the JIT global --- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp | 9 ++++----- Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 580bab2577..fb54ebd006 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -857,7 +857,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc fpr.BindToRegister(reg, true, false); } - Jit64Tables::CompileInstruction(ops[i]); + Jit64Tables::CompileInstruction(*this, ops[i]); if (jo.memcheck && (opinfo->flags & FL_LOADSTORE)) { diff --git a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp index fec19e92ab..7981d7e333 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp @@ -360,21 +360,20 @@ static GekkoOPTemplate table63_2[] = { namespace Jit64Tables { -void CompileInstruction(PPCAnalyst::CodeOp& op) +void CompileInstruction(Jit64& jit, PPCAnalyst::CodeOp& op) { - Jit64* jit64 = (Jit64*)g_jit; - (jit64->*dynaOpTable[op.inst.OPCD])(op.inst); + (jit.*dynaOpTable[op.inst.OPCD])(op.inst); GekkoOPInfo* info = op.opinfo; if (info) { #ifdef OPLOG if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs" { - rsplocations.push_back(g_jit.js.compilerPC); + rsplocations.push_back(jit.js.compilerPC); } #endif info->compileCount++; - info->lastUse = g_jit->js.compilerPC; + info->lastUse = jit.js.compilerPC; } } diff --git a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h index a36d0c5156..8daa24f360 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.h @@ -4,6 +4,8 @@ #pragma once +class Jit64; + namespace PPCAnalyst { struct CodeOp; @@ -11,6 +13,6 @@ struct CodeOp; namespace Jit64Tables { -void CompileInstruction(PPCAnalyst::CodeOp& op); +void CompileInstruction(Jit64& jit, PPCAnalyst::CodeOp& op); void InitTables(); } From b0605c24d36895460106eaad2ce8d9380430b227 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Jan 2017 05:17:45 -0500 Subject: [PATCH 2/3] JitIL_Tables: Eliminate usages of the JIT global --- Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp | 2 +- Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp | 11 +++++------ Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp index 85c8b12cc0..a5fe9ee470 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp @@ -639,7 +639,7 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc ibuild.EmitBreakPointCheck(ibuild.EmitIntConst(ops[i].address)); } - JitILTables::CompileInstruction(ops[i]); + JitILTables::CompileInstruction(*this, ops[i]); if (jo.memcheck && (opinfo->flags & FL_LOADSTORE)) { diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp index b496148a6b..ab69cc5283 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.cpp @@ -378,26 +378,25 @@ static GekkoOPTemplate table63_2[] = { namespace JitILTables { -void CompileInstruction(PPCAnalyst::CodeOp& op) +void CompileInstruction(JitIL& jit, PPCAnalyst::CodeOp& op) { - JitIL* jitil = (JitIL*)g_jit; - (jitil->*dynaOpTable[op.inst.OPCD])(op.inst); + (jit.*dynaOpTable[op.inst.OPCD])(op.inst); GekkoOPInfo* info = op.opinfo; if (info) { #ifdef OPLOG if (!strcmp(info->opname, OP_TO_LOG)) // "mcrfs" { - rsplocations.push_back(g_jit.js.compilerPC); + rsplocations.push_back(jit.js.compilerPC); } #endif info->compileCount++; - info->lastUse = g_jit->js.compilerPC; + info->lastUse = jit.js.compilerPC; } else { PanicAlert("Tried to compile illegal (or unknown) instruction %08x, at %08x", op.inst.hex, - g_jit->js.compilerPC); + jit.js.compilerPC); } } diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h index f207cd0680..89c0b766e4 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL_Tables.h @@ -4,6 +4,8 @@ #pragma once +class JitIL; + namespace PPCAnalyst { struct CodeOp; @@ -11,6 +13,6 @@ struct CodeOp; namespace JitILTables { -void CompileInstruction(PPCAnalyst::CodeOp& op); +void CompileInstruction(JitIL& jit, PPCAnalyst::CodeOp& op); void InitTables(); } From b4e00115c5f03edc745ea78d7aa8ae1bba3d35db Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Jan 2017 05:30:35 -0500 Subject: [PATCH 3/3] JitArm64_Tables: Eliminate usages of the JIT global --- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 2 +- .../Core/PowerPC/JitArm64/JitArm64_Tables.cpp | 15 +++++++++------ .../Core/Core/PowerPC/JitArm64/JitArm64_Tables.h | 10 +++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index a424166574..4d5aed0413 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -604,7 +604,7 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitB js.firstFPInstructionFound = true; } - JitArm64Tables::CompileInstruction(ops[i]); + JitArm64Tables::CompileInstruction(*this, ops[i]); if (!MergeAllowedNextInstructions(1) || js.op[1].opinfo->type != OPTYPE_INTEGER) FlushCarry(); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp index bc742f62b5..85c0072fbd 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp @@ -2,9 +2,13 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/JitArm64/JitArm64_Tables.h" + +#include "Core/PowerPC/Gekko.h" +#include "Core/PowerPC/JitArm64/Jit.h" #include "Core/PowerPC/JitInterface.h" +#include "Core/PowerPC/PPCAnalyst.h" +#include "Core/PowerPC/PPCTables.h" // Should be moved in to the Jit class typedef void (JitArm64::*_Instruction)(UGeckoInstruction instCode); @@ -365,21 +369,20 @@ static GekkoOPTemplate table63_2[] = { namespace JitArm64Tables { -void CompileInstruction(PPCAnalyst::CodeOp& op) +void CompileInstruction(JitArm64& jit, PPCAnalyst::CodeOp& op) { - JitArm64* jitarm = (JitArm64*)g_jit; - (jitarm->*dynaOpTable[op.inst.OPCD])(op.inst); + (jit.*dynaOpTable[op.inst.OPCD])(op.inst); GekkoOPInfo* info = op.opinfo; if (info) { #ifdef OPLOG if (!strcmp(info->opname, OP_TO_LOG)) { ///"mcrfs" - rsplocations.push_back(g_jit.js.compilerPC); + rsplocations.push_back(jit.js.compilerPC); } #endif info->compileCount++; - info->lastUse = g_jit->js.compilerPC; + info->lastUse = jit.js.compilerPC; } } diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h index c92f789a38..e351c01feb 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.h @@ -4,11 +4,15 @@ #pragma once -#include "Core/PowerPC/Gekko.h" -#include "Core/PowerPC/PPCTables.h" +class JitArm64; + +namespace PPCAnalyst +{ +struct CodeOp; +} namespace JitArm64Tables { -void CompileInstruction(PPCAnalyst::CodeOp& op); +void CompileInstruction(JitArm64& jit, PPCAnalyst::CodeOp& op); void InitTables(); }