From b20a76f580e564768275a19be7e5cfa2397bc020 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 17 Feb 2007 09:01:31 +0000 Subject: [PATCH] merge PPC_PROFILE_REGS_USE fixes from KPX branch --- SheepShaver/src/Unix/sysdeps.h | 1 + .../src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp | 20 +++++++++---------- .../src/kpx_cpu/src/cpu/ppc/ppc-jit.cpp | 9 ++++++++- .../src/kpx_cpu/src/test/test-powerpc.cpp | 3 +++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/SheepShaver/src/Unix/sysdeps.h b/SheepShaver/src/Unix/sysdeps.h index 23d3bcce..db5a3640 100644 --- a/SheepShaver/src/Unix/sysdeps.h +++ b/SheepShaver/src/Unix/sysdeps.h @@ -109,6 +109,7 @@ #define PPC_FLIGHT_RECORDER 1 #define PPC_PROFILE_COMPILE_TIME 0 #define PPC_PROFILE_GENERIC_CALLS 1 +#define PPC_PROFILE_REGS_USE 0 #define KPX_MAX_CPUS 1 #if ENABLE_DYNGEN #define PPC_ENABLE_JIT 1 diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp index 376cc66d..73bd079e 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp @@ -250,6 +250,14 @@ void powerpc_cpu::initialize() printf("PowerPC CPU emulator by Gwenole Beauchesne\n"); #endif +#if PPC_PROFILE_REGS_USE + reginfo = new register_info[32]; + for (int i = 0; i < 32; i++) { + reginfo[i].id = i; + reginfo[i].count = 0; + } +#endif + init_flight_recorder(); init_decoder(); init_registers(); @@ -292,14 +300,6 @@ void powerpc_cpu::initialize() compile_time = 0; emul_start_time = clock(); #endif - -#if PPC_PROFILE_REGS_USE - reginfo = new register_info[32]; - for (int i = 0; i < 32; i++) { - reginfo[i].id = i; - reginfo[i].count = 0; - } -#endif } #if PPC_ENABLE_JIT @@ -427,12 +427,12 @@ powerpc_cpu::~powerpc_cpu() uint64 cum_reg_count = 0; for (int i = 0; i < 32; i++) { cum_reg_count += reginfo[i].count; - printf("r%-2d : %16lld %2.1f%% [%3.1f%%]\n", + printf("r%-2d : %16llu %2.1f%% [%3.1f%%]\n", reginfo[i].id, reginfo[i].count, 100.0*double(reginfo[i].count)/double(tot_reg_count), 100.0*double(cum_reg_count)/double(tot_reg_count)); } - delete reginfo; + delete[] reginfo; #endif kill_decode_cache(); diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-jit.cpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-jit.cpp index 12b19ae6..affdc49a 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-jit.cpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-jit.cpp @@ -328,7 +328,14 @@ bool powerpc_jit::gen_vector_generic_store_word(int mnemo, int vS, int rA, int r return true; } -#define xPPC_FIELD(M) ((uintptr)&((powerpc_cpu *)0)->M) +#if PPC_PROFILE_REGS_USE +// XXX update reginfo[] counts for xPPC_GPR() accesses +static uint8 dummy_ppc_context[sizeof(powerpc_cpu)]; +#define xPPC_CONTEXT ((powerpc_cpu *)dummy_ppc_context) +#else +#define xPPC_CONTEXT ((powerpc_cpu *)0) +#endif +#define xPPC_FIELD(M) (((uintptr)&xPPC_CONTEXT->M) - (uintptr)xPPC_CONTEXT) #define xPPC_GPR(N) xPPC_FIELD(gpr(N)) #define xPPC_VR(N) xPPC_FIELD(vr(N)) #define xPPC_CR xPPC_FIELD(cr()) diff --git a/SheepShaver/src/kpx_cpu/src/test/test-powerpc.cpp b/SheepShaver/src/kpx_cpu/src/test/test-powerpc.cpp index 8f5cdaef..3bd3963e 100644 --- a/SheepShaver/src/kpx_cpu/src/test/test-powerpc.cpp +++ b/SheepShaver/src/kpx_cpu/src/test/test-powerpc.cpp @@ -235,6 +235,9 @@ struct powerpc_cpu_base }; powerpc_cpu_base::powerpc_cpu_base() +#ifndef SHEEPSHAVER + : powerpc_cpu(NULL) +#endif { init_decoder(); }