From f93bd1c664d5dacca79c04681a6ae0e9c4a6aa45 Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Mon, 4 Jul 2005 18:02:37 +0000 Subject: [PATCH] Optimize SHOW_IPS calculation, now it does not require additional ips_count++ operation after every instruction execution --- bochs/main.cc | 13 ++++++++----- bochs/pc_system.cc | 6 +----- bochs/pc_system.h | 14 +------------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/bochs/main.cc b/bochs/main.cc index c149e817e..7678cb276 100644 --- a/bochs/main.cc +++ b/bochs/main.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: main.cc,v 1.289 2005-04-16 19:37:38 sshwarts Exp $ +// $Id: main.cc,v 1.290 2005-07-04 18:02:23 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -1010,7 +1010,7 @@ int bx_atexit(void) return 0; } -void bx_signal_handler( int signum) +void bx_signal_handler(int signum) { // in a multithreaded environment, a signal such as SIGINT can be sent to all // threads. This function is only intended to handle signals in the @@ -1033,13 +1033,15 @@ void bx_signal_handler( int signum) #endif #if BX_SHOW_IPS - extern unsigned long ips_count; + static Bit64u ticks_count = 0; if (signum == SIGALRM) { + // amount of system ticks passed from last time the handler was called + Bit64u ips_count = bx_pc_system.time_ticks() - ticks_count; if (ips_count) { - BX_INFO(("ips = %lu", ips_count)); - ips_count = 0; + BX_INFO(("ips = %lu", (unsigned long) ips_count)); + ticks_count = bx_pc_system.time_ticks(); } #ifndef __MINGW32__ signal(SIGALRM, bx_signal_handler); @@ -1057,5 +1059,6 @@ void bx_signal_handler( int signum) } } #endif + BX_PANIC(("SIGNAL %u caught", signum)); } diff --git a/bochs/pc_system.cc b/bochs/pc_system.cc index 89026bf31..d09091b78 100644 --- a/bochs/pc_system.cc +++ b/bochs/pc_system.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pc_system.cc,v 1.42 2005-06-16 20:35:31 sshwarts Exp $ +// $Id: pc_system.cc,v 1.43 2005-07-04 18:02:37 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -37,10 +37,6 @@ #endif #endif -#if BX_SHOW_IPS -unsigned long ips_count=0; -#endif - #if defined(PROVIDE_M_IPS) double m_ips; // Millions of Instructions Per Second #endif diff --git a/bochs/pc_system.h b/bochs/pc_system.h index b4345e7f8..a92783854 100644 --- a/bochs/pc_system.h +++ b/bochs/pc_system.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: pc_system.h,v 1.32 2005-04-29 21:28:41 sshwarts Exp $ +// $Id: pc_system.h,v 1.33 2005-07-04 18:02:37 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004 MandrakeSoft S.A. @@ -26,16 +26,10 @@ - #define BX_MAX_TIMERS 64 #define BX_NULL_TIMER_HANDLE 10000 -#if BX_SHOW_IPS -extern unsigned long ips_count; -#endif - - typedef void (*bx_timer_handler_t)(void *); @@ -110,17 +104,11 @@ public: return triggeredTimer; } static BX_CPP_INLINE void tick1(void) { -#if BX_SHOW_IPS - ips_count++; -#endif if (--bx_pc_system.currCountdown == 0) { bx_pc_system.countdownEvent(); } } static BX_CPP_INLINE void tickn(Bit64u n) { -#if BX_SHOW_IPS - ips_count += n; -#endif while (n >= Bit64u(bx_pc_system.currCountdown)) { n -= Bit64u(bx_pc_system.currCountdown); bx_pc_system.currCountdown = 0;