From 7e20a8d2058ecf233158b9d8935711874d550113 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 11 Oct 2003 09:57:52 +0000 Subject: [PATCH] - Add support for FLIGHT_RECORDER with predecode cache - Always enable predecode cache & flight recorder for now --- SheepShaver/src/Unix/sysdeps.h | 3 +-- .../src/kpx_cpu/src/cpu/ppc/ppc-config.hpp | 4 ++++ SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp | 16 ++++++++++++++++ SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.hpp | 15 ++++++++++++--- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/SheepShaver/src/Unix/sysdeps.h b/SheepShaver/src/Unix/sysdeps.h index 224bcf9e..927bfe12 100644 --- a/SheepShaver/src/Unix/sysdeps.h +++ b/SheepShaver/src/Unix/sysdeps.h @@ -79,8 +79,7 @@ #endif // Configure PowerPC emulator #define PPC_NO_LAZY_PC_UPDATE 1 -#define PPC_NO_DECODE_CACHE 1 -//#define PPC_FLIGHT_RECORDER 1 +#define PPC_FLIGHT_RECORDER 1 #else // Mac ROM is write protected #define ROM_IS_WRITE_PROTECTED 1 diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-config.hpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-config.hpp index ecec8aa6..631bf727 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-config.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-config.hpp @@ -189,6 +189,10 @@ #undef PPC_LAZY_PC_UPDATE #endif +#if PPC_FLIGHT_RECORDER +#undef PPC_LAZY_PC_UPDATE +#endif + #if defined(PPC_LAZY_CC_UPDATE) && !defined(PPC_HAVE_SPLIT_CR) #define PPC_HAVE_SPLIT_CR #endif 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 bacffcb5..8c4fbb97 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.cpp @@ -141,6 +141,18 @@ void powerpc_cpu::record_step(uint32 opcode) #endif } +void powerpc_cpu::start_log() +{ + logging = true; + invalidate_cache(); +} + +void powerpc_cpu::stop_log() +{ + logging = false; + invalidate_cache(); +} + void powerpc_cpu::dump_log(const char *filename) { if (filename == NULL) @@ -270,6 +282,10 @@ void powerpc_cpu::init_decode_cache() D(bug("powerpc_cpu: Allocated decode cache: %d KB at %p\n", DECODE_CACHE_SIZE / 1024, decode_cache)); decode_cache_p = decode_cache; decode_cache_end_p = decode_cache + DECODE_CACHE_MAX_ENTRIES; +#if FLIGHT_RECORDER + // Leave enough room to last call to record_step() + decode_cache_end_p -= 2; +#endif block_cache.initialize(); #endif diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.hpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.hpp index f021aa6e..ac51cae3 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-cpu.hpp @@ -204,8 +204,8 @@ public: // Handle flight recorder #if PPC_FLIGHT_RECORDER bool is_logging() { return logging; } - void start_log() { logging = true; } - void stop_log() { logging = false; } + void start_log(); + void stop_log(); void dump_log(const char *filename = NULL); #else bool is_logging() { return false; } @@ -342,8 +342,10 @@ inline void powerpc_cpu::do_execute() #ifdef PPC_EXECUTE_DUMP_STATE fprintf(stderr, "[%08x]-> %08x\n", pc(), opcode); #endif - if (logging) +#if FLIGHT_RECORDER + if (is_logging()) record_step(opcode); +#endif assert(ii->execute != 0); (this->*(ii->execute))(opcode); #ifdef PPC_EXECUTE_DUMP_STATE @@ -365,6 +367,13 @@ inline void powerpc_cpu::do_execute() ii = decode(opcode); di->opcode = opcode; di->execute = ii->execute; +#if FLIGHT_RECORDER + if (is_logging()) { + di++; + di->opcode = opcode; + di->execute = record_step; + } +#endif if (++di >= decode_cache_end_p) { // Invalidate cache and move current code to start invalidate_cache();