mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-02 06:44:45 +00:00
Support for modified jit-enabled VerySleepy.
This allows profiling the jit. Should have zero perf impact when not in use, since it's entirely triggered by VerySleepy.
This commit is contained in:
parent
c42ee6d12e
commit
5d2ff64252
@ -840,7 +840,7 @@ public:
|
||||
region_size = 0;
|
||||
}
|
||||
|
||||
bool IsInSpace(u8 *ptr)
|
||||
bool IsInSpace(const u8 *ptr) const
|
||||
{
|
||||
return ptr >= region && ptr < region + region_size;
|
||||
}
|
||||
@ -870,7 +870,7 @@ public:
|
||||
return region;
|
||||
}
|
||||
|
||||
size_t GetOffset(u8 *ptr) {
|
||||
size_t GetOffset(const u8 *ptr) const {
|
||||
return ptr - region;
|
||||
}
|
||||
};
|
||||
|
@ -463,7 +463,7 @@ namespace PpcGen
|
||||
region_size = 0;
|
||||
}
|
||||
|
||||
bool IsInSpace(u8 *ptr)
|
||||
bool IsInSpace(const u8 *ptr) const
|
||||
{
|
||||
return ptr >= region && ptr < region + region_size;
|
||||
}
|
||||
@ -493,7 +493,7 @@ namespace PpcGen
|
||||
return region;
|
||||
}
|
||||
|
||||
size_t GetOffset(u8 *ptr) {
|
||||
size_t GetOffset(const u8 *ptr) const {
|
||||
return ptr - region;
|
||||
}
|
||||
};
|
||||
|
@ -756,7 +756,7 @@ public:
|
||||
region_size = 0;
|
||||
}
|
||||
|
||||
bool IsInSpace(u8 *ptr)
|
||||
bool IsInSpace(const u8 *ptr) const
|
||||
{
|
||||
return ptr >= region && ptr < region + region_size;
|
||||
}
|
||||
@ -782,7 +782,7 @@ public:
|
||||
return region;
|
||||
}
|
||||
|
||||
size_t GetOffset(u8 *ptr) {
|
||||
size_t GetOffset(const u8 *ptr) const {
|
||||
return ptr - region;
|
||||
}
|
||||
};
|
||||
|
@ -65,6 +65,10 @@ public:
|
||||
void Compile(u32 em_address); // Compiles a block at current MIPS PC
|
||||
const u8 *DoJit(u32 em_address, JitBlock *b);
|
||||
|
||||
bool IsInDispatch(const u8 *p) {
|
||||
return IsInSpace(p);
|
||||
}
|
||||
|
||||
void CompileDelaySlot(int flags);
|
||||
void CompileAt(u32 addr);
|
||||
void EatInstruction(MIPSOpcode op);
|
||||
|
@ -254,6 +254,21 @@ void JitBlockCache::GetBlockNumbersFromAddress(u32 em_address, std::vector<int>
|
||||
block_numbers->push_back(i);
|
||||
}
|
||||
|
||||
u32 JitBlockCache::GetAddressFromBlockPtr(const u8 *ptr) const {
|
||||
if (!codeBlock_->IsInSpace(ptr))
|
||||
return (u32)-1;
|
||||
|
||||
for (int i = 0; i < num_blocks; ++i) {
|
||||
const auto &b = blocks[i];
|
||||
if (!b.invalid && ptr >= b.normalEntry && ptr < b.normalEntry + b.codeSize) {
|
||||
return b.originalAddress;
|
||||
}
|
||||
}
|
||||
|
||||
// It's in jit somewhere, but we must've deleted it.
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIPSOpcode JitBlockCache::GetOriginalFirstOp(int block_num)
|
||||
{
|
||||
if (block_num >= num_blocks || block_num < 0)
|
||||
|
@ -109,6 +109,8 @@ public:
|
||||
void GetBlockNumbersFromAddress(u32 em_address, std::vector<int> *block_numbers);
|
||||
int GetBlockNumberFromEmuHackOp(MIPSOpcode inst) const;
|
||||
|
||||
u32 GetAddressFromBlockPtr(const u8 *ptr) const;
|
||||
|
||||
MIPSOpcode GetOriginalFirstOp(int block_num);
|
||||
|
||||
// DOES NOT WORK CORRECTLY WITH JIT INLINING
|
||||
|
@ -294,6 +294,10 @@ namespace MIPSComp
|
||||
void Compile(u32 em_address); // Compiles a block at current MIPS PC
|
||||
const u8 *DoJit(u32 em_address, JitBlock *b);
|
||||
|
||||
bool IsInDispatch(const u8 *p) {
|
||||
return IsInSpace(p);
|
||||
}
|
||||
|
||||
PpcJitOptions jo;
|
||||
PpcJitState js;
|
||||
|
||||
|
@ -72,6 +72,10 @@ public:
|
||||
void Compile(u32 em_address); // Compiles a block at current MIPS PC
|
||||
const u8 *DoJit(u32 em_address, JitBlock *b);
|
||||
|
||||
bool IsInDispatch(const u8 *p) {
|
||||
return asm_.IsInSpace(p);
|
||||
}
|
||||
|
||||
void CompileAt(u32 addr);
|
||||
void Comp_RunBlock(MIPSOpcode op);
|
||||
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "Core/SaveState.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/MIPS/JitCommon/JitCommon.h"
|
||||
#include "Core/MIPS/JitCommon/JitBlockCache.h"
|
||||
#include "Windows/EmuThread.h"
|
||||
|
||||
#include "resource.h"
|
||||
@ -75,6 +77,24 @@
|
||||
|
||||
#define ENABLE_TOUCH 0
|
||||
|
||||
int verysleepy__useSendMessage = 1;
|
||||
|
||||
const UINT WM_VERYSLEEPY_MSG = WM_APP + 0x3117;
|
||||
// Respond TRUE to a message with this param value to indicate support.
|
||||
const WPARAM VERYSLEEPY_WPARAM_SUPPORTED = 0;
|
||||
// Respond TRUE to a message wit this param value after filling in the addr name.
|
||||
const WPARAM VERYSLEEPY_WPARAM_GETADDRINFO = 1;
|
||||
|
||||
struct VerySleepy_AddrInfo
|
||||
{
|
||||
// Always zero for now.
|
||||
int flags;
|
||||
// This is the pointer (always passed as 64 bits.)
|
||||
unsigned long long addr;
|
||||
// Write the name here.
|
||||
wchar_t name[256];
|
||||
};
|
||||
|
||||
extern std::map<int, int> windowsTransTable;
|
||||
static RECT g_normalRC = {0};
|
||||
static std::wstring windowTitle;
|
||||
@ -1523,6 +1543,43 @@ namespace MainWindow
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_VERYSLEEPY_MSG:
|
||||
switch (wParam) {
|
||||
case VERYSLEEPY_WPARAM_SUPPORTED:
|
||||
return TRUE;
|
||||
|
||||
case VERYSLEEPY_WPARAM_GETADDRINFO:
|
||||
{
|
||||
VerySleepy_AddrInfo *info = (VerySleepy_AddrInfo *)lParam;
|
||||
const u8 *ptr = (const u8 *)info->addr;
|
||||
if (MIPSComp::jit) {
|
||||
JitBlockCache *blocks = MIPSComp::jit->GetBlockCache();
|
||||
u32 jitAddr = blocks->GetAddressFromBlockPtr(ptr);
|
||||
|
||||
// Returns 0 when it's valid, but unknown.
|
||||
if (jitAddr == 0) {
|
||||
wcscpy_s(info->name, L"Jit::UnknownOrDeletedBlock");
|
||||
return TRUE;
|
||||
}
|
||||
if (jitAddr != (u32)-1) {
|
||||
swprintf_s(info->name, L"Jit::%08x", jitAddr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Perhaps it's in jit the dispatch runloop.
|
||||
if (MIPSComp::jit->IsInDispatch(ptr)) {
|
||||
wcscpy_s(info->name, L"Jit::RunLoopUntil");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
if (!EmuThread_Ready())
|
||||
|
Loading…
x
Reference in New Issue
Block a user