mirror of https://github.com/inolen/redream.git
add debug pc logging to sh4 dispatch
This commit is contained in:
parent
c4ac2ab941
commit
c4942957f3
|
@ -7,6 +7,16 @@ extern "C" {
|
|||
#include "jit/jit.h"
|
||||
}
|
||||
|
||||
/* log out pc each time dispatch is entered for debugging */
|
||||
#define LOG_DISPATCH_EVERY_N 0
|
||||
|
||||
/* controls if edges are added and managed between static branches. the first
|
||||
time each branch is hit, its destination block will be dynamically looked
|
||||
up. if this is enabled, an edge will be added between the two blocks, and
|
||||
the branch will be patched to directly jmp to the destination block,
|
||||
avoiding the need for redundant lookups */
|
||||
#define LINK_STATIC_BRANCHES !LOG_DISPATCH_EVERY_N
|
||||
|
||||
/* executable sh4 code sits between 0x0c000000 and 0x0d000000. each instr is 2
|
||||
bytes, making for a maximum of 0x800000 blocks */
|
||||
#define CODE_SIZE 0x800000
|
||||
|
@ -23,13 +33,6 @@ static void *sh4_cache[CACHE_SIZE];
|
|||
static int sh4_cache_size = CACHE_SIZE;
|
||||
static uint8_t sh4_dispatch[DISPATCH_SIZE];
|
||||
|
||||
/* controls if edges are added and managed between static branches. the first
|
||||
time each branch is hit, its destination block will be dynamically looked
|
||||
up. if this is enabled, an edge will be added between the two blocks, and
|
||||
the branch will be patched to directly jmp to the destination block,
|
||||
avoiding the need for redundant lookups */
|
||||
#define LINK_STATIC_BRANCHES 1
|
||||
|
||||
void *sh4_dispatch_dynamic;
|
||||
void *sh4_dispatch_static;
|
||||
void *sh4_dispatch_compile;
|
||||
|
@ -54,6 +57,16 @@ static void **sh4_dispatch_code_ptr(uint32_t addr) {
|
|||
return &sh4_cache[(addr & 0x00ffffff) >> 1];
|
||||
}
|
||||
|
||||
#if LOG_DISPATCH_EVERY_N
|
||||
static void sh4_dispatch_log(struct sh4_ctx *ctx) {
|
||||
static uint64_t num;
|
||||
|
||||
if ((num++ % LOG_DISPATCH_EVERY_N) == 0) {
|
||||
LOG_INFO("sh4_log_dispatch 0x%08x", ctx->pc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void sh4_dispatch_restore_edge(void *code, uint32_t dst) {
|
||||
auto &e = code_emitter;
|
||||
size_t original_size = e.getSize();
|
||||
|
@ -109,6 +122,10 @@ void sh4_dispatch_init(void *sh4, void *jit, void *ctx, void *mem) {
|
|||
|
||||
sh4_dispatch_dynamic = e.getCurr<void *>();
|
||||
|
||||
#if LOG_DISPATCH_EVERY_N
|
||||
e.mov(arg0, e.r14);
|
||||
e.call(&sh4_dispatch_log);
|
||||
#endif
|
||||
e.mov(e.rax, (uint64_t)sh4_cache);
|
||||
e.mov(e.ecx, e.dword[e.r14 + offsetof(struct sh4_ctx, pc)]);
|
||||
e.and_(e.ecx, 0x00ffffff);
|
||||
|
|
Loading…
Reference in New Issue