Call ProxyBlock in ArmJit too. Plus various cleanup and one more string function.

This commit is contained in:
Henrik Rydgård committed 2013-12-19 11:45:39 +01:00
1 parent 5585b85ccc
commit 3957b5fb42
5 files changed
+31 -30

No files matched your search

+17 -18
View File
@@ -63,9 +63,7 @@ static int Replace_memcpy() {
if (bytes != 0) {
u8 *dst = Memory::GetPointerUnchecked(destPtr);
u8 *src = Memory::GetPointerUnchecked(srcPtr);
if (dst && src) {
memmove(dst, src, bytes);
}
memmove(dst, src, bytes);
}
RETURN(destPtr);
return 10 + bytes / 4; // approximation
@@ -78,9 +76,7 @@ static int Replace_memmove() {
if (bytes != 0) {
u8 *dst = Memory::GetPointerUnchecked(destPtr);
u8 *src = Memory::GetPointerUnchecked(srcPtr);
if (dst && src) {
memmove(dst, src, bytes);
}
memmove(dst, src, bytes);
}
RETURN(destPtr);
return 10 + bytes / 4; // approximation
@@ -91,9 +87,7 @@ static int Replace_memset() {
u8 *dst = Memory::GetPointerUnchecked(destPtr);
u8 value = PARAM(1);
u32 bytes = PARAM(2);
if (dst) {
memset(dst, value, bytes);
}
memset(dst, value, bytes);
RETURN(destPtr);
return 10 + bytes / 4; // approximation
}
@@ -110,9 +104,17 @@ static int Replace_strcpy() {
u32 destPtr = PARAM(0);
char *dst = (char *)Memory::GetPointerUnchecked(destPtr);
const char *src = (const char *)Memory::GetPointerUnchecked(PARAM(1));
if (dst && src) {
strcpy(dst, src);
}
strcpy(dst, src);
RETURN(destPtr);
return 10; // approximation
}
static int Replace_strncpy() {
u32 destPtr = PARAM(0);
char *dst = (char *)Memory::GetPointerUnchecked(destPtr);
const char *src = (const char *)Memory::GetPointerUnchecked(PARAM(1));
u32 bytes = PARAM(2);
strncpy(dst, src, bytes);
RETURN(destPtr);
return 10; // approximation
}
@@ -120,9 +122,7 @@ static int Replace_strcpy() {
static int Replace_strcmp() {
const char *a = (const char *)Memory::GetPointerUnchecked(PARAM(0));
const char *b = (const char *)Memory::GetPointerUnchecked(PARAM(1));
if (a && b) {
RETURN(strcmp(a, b));
}
RETURN(strcmp(a, b));
return 10; // approximation
}
@@ -130,9 +130,7 @@ static int Replace_strncmp() {
const char *a = (const char *)Memory::GetPointerUnchecked(PARAM(0));
const char *b = (const char *)Memory::GetPointerUnchecked(PARAM(1));
u32 bytes = PARAM(2);
if (a && b) {
RETURN(strncmp(a, b, bytes));
}
RETURN(strncmp(a, b, bytes));
return 10 + bytes / 4; // approximation
}
@@ -161,6 +159,7 @@ static const ReplacementTableEntry entries[] = {
{ "memset", &Replace_memset, 0, 0},
{ "strlen", &Replace_strlen, 0, 0},
{ "strcpy", &Replace_strcpy, 0, 0},
{ "strncpy", &Replace_strncpy, 0, 0},
{ "strcmp", &Replace_strcmp, 0, 0},
{ "strncmp", &Replace_strncmp, 0, 0},
{ "fabsf", 0, &MIPSComp::Jit::Replace_fabsf, REPFLAG_ALLOWINLINE},
+5 -2
View File
@@ -171,7 +171,7 @@ void Jit::CompileDelaySlot(int flags)
// delay slot, we're screwed.
if (flags & DELAYSLOT_SAFE)
MRS(R8); // Save flags register. R8 is preserved through function calls and is not allocated.
js.inDelaySlot = true;
MIPSOpcode op = Memory::Read_Instruction(js.compilerPC + 4);
MIPSCompileOp(op);
@@ -211,7 +211,6 @@ void Jit::Compile(u32 em_address) {
void Jit::RunLoopUntil(u64 globalticks)
{
// TODO: copy globalticks somewhere
((void (*)())enterCode)();
}
@@ -368,6 +367,10 @@ bool Jit::ReplaceJalTo(u32 dest) {
int cycles = (this->*repl)();
js.downcountAmount += cycles;
// No writing exits, keep going!
// Add a trigger so that if the inlined code changes, we invalidate this block.
// TODO: Correctly determine the size of this block.
blocks.ProxyBlock(js.blockStart, dest, 4, GetCodePtr());
return true;
} else {
return false;
+3 -1
View File
@@ -156,7 +156,9 @@ int JitBlockCache::AllocateBlock(u32 em_address)
return num_blocks - 1;
}
int JitBlockCache::CreateProxyBlock(u32 rootAddress, u32 startAddress, u32 size, const u8 *codePtr) {
int JitBlockCache::ProxyBlock(u32 rootAddress, u32 startAddress, u32 size, const u8 *codePtr) {
// TODO: If there's an existing block at the startAddress, add rootAddress as a proxy root of that block.
JitBlock &b = blocks[num_blocks];
b.invalid = false;
b.originalAddress = startAddress;
+2 -2
View File
@@ -59,7 +59,7 @@ const int MAX_JIT_BLOCK_EXITS = 8;
// Fine to mess with them at block compile time though.
struct JitBlock {
bool ContainsAddress(u32 em_address);
const u8 *checkedEntry;
const u8 *normalEntry;
@@ -91,7 +91,7 @@ public:
int AllocateBlock(u32 em_address);
// When a proxy block is invalidated, the block located at the rootAddress
// is invalidated too.
int CreateProxyBlock(u32 rootAddress, u32 startAddress, u32 size, const u8 *codePtr);
int ProxyBlock(u32 rootAddress, u32 startAddress, u32 size, const u8 *codePtr);
void FinalizeBlock(int block_num, bool block_link);
void Clear();
+4 -7
View File
@@ -59,9 +59,8 @@ const bool USE_JIT_MISSMAP = false;
static std::map<std::string, u32> notJitOps;
template<typename A, typename B>
std::pair<B,A> flip_pair(const std::pair<A,B> &p)
{
return std::pair<B, A>(p.second, p.first);
std::pair<B,A> flip_pair(const std::pair<A,B> &p) {
return std::pair<B, A>(p.second, p.first);
}
u32 JitBreakpoint()
@@ -286,9 +285,7 @@ void Jit::Compile(u32 em_address)
void Jit::RunLoopUntil(u64 globalticks)
{
// TODO: copy globalticks somewhere
((void (*)())asm_.enterCode)();
// NOTICE_LOG(JIT, "Exited jitted code at %i, corestate=%i, dc=%i", CoreTiming::GetTicks() / 1000, (int)coreState, CoreTiming::downcount);
}
const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
@@ -429,7 +426,7 @@ bool Jit::ReplaceJalTo(u32 dest) {
// Add a trigger so that if the inlined code changes, we invalidate this block.
// TODO: Correctly determine the size of this block.
blocks.CreateProxyBlock(js.blockStart, dest, 4, GetCodePtr());
blocks.ProxyBlock(js.blockStart, dest, 4, GetCodePtr());
return true;
} else {
return false;
@@ -444,7 +441,7 @@ void Jit::Comp_ReplacementFunc(MIPSOpcode op)
// Inlined function calls (caught in jal) are handled differently.
int index = op.encoding & MIPS_EMUHACK_VALUE_MASK;
const ReplacementTableEntry *entry = GetReplacementFunc(index);
if (!entry) {
ERROR_LOG(HLE, "Invalid replacement op %08x", op.encoding);