Disable debug file logging, fix issue with replacement functions, etc

This commit is contained in:
Henrik Rydgard 2016-05-07 21:35:12 +02:00
parent 38b7d89dfb
commit 3c5510e5a3
6 changed files with 107 additions and 21 deletions

View file

@ -77,7 +77,7 @@ void IRJit::Comp_FPULS(MIPSOpcode op) {
}
void IRJit::Comp_FPUComp(MIPSOpcode op) {
CONDITIONAL_DISABLE;
DISABLE;
int opc = op & 0xF;
if (opc >= 8) opc -= 8; // alias

View file

@ -4,6 +4,9 @@
#include "Core/MIPS/MIPSTables.h"
#include "Core/MemMap.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/ReplaceTables.h"
#include "math/math_util.h"
IRMeta meta[] = {
{ IROp::SetConst, "SetConst", "GC_" },
@ -286,6 +289,58 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, const u32 *constPool, int c
case IROp::FpCondToReg:
mips->r[inst->dest] = mips->fpcond;
break;
case IROp::FRound:
mips->r[inst->dest] = (int)floorf(mips->f[inst->src1] + 0.5f);
break;
case IROp::FTrunc:
{
float src = mips->f[inst->src1];
if (src >= 0.0f) {
mips->fs[inst->dest] = (int)floorf(src);
// Overflow, but it was positive.
if (mips->fs[inst->dest] == -2147483648LL) {
mips->fs[inst->dest] = 2147483647LL;
}
} else {
// Overflow happens to be the right value anyway.
mips->fs[inst->dest] = (int)ceilf(src);
}
break;
}
case IROp::FCeil:
mips->r[inst->dest] = (int)ceilf(mips->f[inst->src1]);
break;
case IROp::FFloor:
mips->r[inst->dest] = (int)floorf(mips->f[inst->src1]);
break;
case IROp::FCvtSW:
mips->f[inst->dest] = (float)mips->fs[inst->src1];
break;
case IROp::FCvtWS:
{
float src = mips->f[inst->src1];
if (my_isnanorinf(src))
{
mips->fs[inst->dest] = my_isinf(src) && src < 0.0f ? -2147483648LL : 2147483647LL;
break;
}
switch (mips->fcr31 & 3)
{
case 0: mips->fs[inst->dest] = (int)round_ieee_754(src); break; // RINT_0
case 1: mips->fs[inst->dest] = (int)src; break; // CAST_1
case 2: mips->fs[inst->dest] = (int)ceilf(src); break; // CEIL_2
case 3: mips->fs[inst->dest] = (int)floorf(src); break; // FLOOR_3
}
break; //cvt.w.s
}
case IROp::FMovFromGPR:
memcpy(&mips->f[inst->dest], &mips->r[inst->src1], 4);
break;
case IROp::FMovToGPR:
memcpy(&mips->r[inst->dest], &mips->f[inst->src1], 4);
break;
case IROp::ExitToConst:
return constPool[inst->dest];
@ -341,6 +396,15 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, const u32 *constPool, int c
break;
}
case IROp::CallReplacement:
{
int funcIndex = constPool[inst->src1];
const ReplacementTableEntry *f = GetReplacementFunc(funcIndex);
int cycles = f->replaceFunc();
mips->downcount -= cycles;
break;
}
default:
Crash();
}

View file

@ -152,6 +152,7 @@ enum class IROp : u8 {
Syscall,
SetPC, // hack to make syscall returns work
CallReplacement,
Break,
};

View file

@ -313,7 +313,33 @@ bool IRJit::ReplaceJalTo(u32 dest) {
}
void IRJit::Comp_ReplacementFunc(MIPSOpcode op) {
Crash();
int index = op.encoding & MIPS_EMUHACK_VALUE_MASK;
const ReplacementTableEntry *entry = GetReplacementFunc(index);
if (!entry) {
ERROR_LOG(HLE, "Invalid replacement op %08x", op.encoding);
return;
}
if (entry->flags & REPFLAG_DISABLED) {
MIPSCompileOp(Memory::Read_Instruction(GetCompilerPC(), true), this);
} else if (entry->replaceFunc) {
FlushAll();
RestoreRoundingMode();
ir.Write(IROp::SetPC, 0, ir.AddConstant(GetCompilerPC()));
ir.Write(IROp::CallReplacement, 0, ir.AddConstant(index));
if (entry->flags & (REPFLAG_HOOKENTER | REPFLAG_HOOKEXIT)) {
// Compile the original instruction at this address. We ignore cycles for hooks.
ApplyRoundingMode();
MIPSCompileOp(Memory::Read_Instruction(GetCompilerPC(), true), this);
} else {
ApplyRoundingMode();
js.compiling = false;
}
} else {
ERROR_LOG(HLE, "Replacement function %s has neither jit nor regular impl", entry->name);
}
}
void IRJit::Comp_Generic(MIPSOpcode op) {

View file

@ -974,8 +974,6 @@ void MIPSInterpret(MIPSOpcode op) {
int MIPSInterpret_RunUntil(u64 globalTicks)
{
int blockCount = 150000;
FILE *f = fopen("E:\\blockjit.txt", "w");
MIPSState *curMips = currentMIPS;
while (coreState == CORE_RUNNING)
{
@ -1019,6 +1017,7 @@ int MIPSInterpret_RunUntil(u64 globalTicks)
bool wasInDelaySlot = curMips->inDelaySlot;
/*
if (curMips->pc != lastPC + 4) {
if (blockCount > 0) {
MIPSState *mips_ = curMips;
@ -1028,7 +1027,7 @@ int MIPSInterpret_RunUntil(u64 globalTicks)
}
}
lastPC = curMips->pc;
*/
MIPSInterpret(op);
if (curMips->inDelaySlot)

View file

@ -426,26 +426,22 @@ __forceinline static Opcode Read_Instruction(u32 address, bool resolveReplacemen
if (MIPS_IS_RUNBLOCK(inst.encoding) && MIPSComp::jit) {
JitBlockCache *bc = MIPSComp::jit->GetBlockCache();
int block_num = bc->GetBlockNumberFromEmuHackOp(inst, true);
if (block_num >= 0) {
inst = bc->GetOriginalFirstOp(block_num);
if (resolveReplacements && MIPS_IS_REPLACEMENT(inst)) {
u32 op;
if (GetReplacedOpAt(address, &op)) {
if (MIPS_IS_EMUHACK(op)) {
ERROR_LOG(HLE,"WTF 1");
return Opcode(op);
} else {
return Opcode(op);
}
inst = MIPSComp::jit->GetOriginalOp(inst);
if (resolveReplacements && MIPS_IS_REPLACEMENT(inst)) {
u32 op;
if (GetReplacedOpAt(address, &op)) {
if (MIPS_IS_EMUHACK(op)) {
ERROR_LOG(HLE,"WTF 1");
return Opcode(op);
} else {
ERROR_LOG(HLE, "Replacement, but no replacement op? %08x", inst.encoding);
return Opcode(op);
}
} else {
ERROR_LOG(HLE, "Replacement, but no replacement op? %08x", inst.encoding);
}
return inst;
} else {
return inst;
}
return inst;
} else if (resolveReplacements && MIPS_IS_REPLACEMENT(inst.encoding)) {
u32 op;
if (GetReplacedOpAt(address, &op)) {