From: Philippe Waroquiers Date: Sat, 12 Mar 2016 21:38:22 +0000 (+0000) Subject: Small optimisation : use preprocessor for cache stats X-Git-Tag: svn/VALGRIND_3_12_0~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb2ffd99ee38068f49aacae97bcb8ac685ef69ba;p=thirdparty%2Fvalgrind.git Small optimisation : use preprocessor for cache stats as the compiler does not remove the access to the not useful static vars git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15828 --- diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c index 38b7533afd..edd0541425 100644 --- a/coregrind/m_aspacemgr/aspacemgr-linux.c +++ b/coregrind/m_aspacemgr/aspacemgr-linux.c @@ -1082,8 +1082,13 @@ inline static Int find_nsegment_idx ( Addr a ) static Int cache_segidx[N_CACHE]; static Bool cache_inited = False; +# ifdef N_Q_M_STATS static UWord n_q = 0; static UWord n_m = 0; + n_q++; + if (0 == (n_q & 0xFFFF)) + VG_(debugLog)(0,"xxx","find_nsegment_idx: %lu %lu\n", n_q, n_m); +# endif UWord ix; @@ -1099,10 +1104,6 @@ inline static Int find_nsegment_idx ( Addr a ) ix = (a >> 12) % N_CACHE; - n_q++; - if (0 && 0 == (n_q & 0xFFFF)) - VG_(debugLog)(0,"xxx","find_nsegment_idx: %lu %lu\n", n_q, n_m); - if ((a >> 12) == cache_pageno[ix] && cache_segidx[ix] >= 0 && cache_segidx[ix] < nsegments_used @@ -1113,7 +1114,9 @@ inline static Int find_nsegment_idx ( Addr a ) return cache_segidx[ix]; } /* miss */ +# ifdef N_Q_M_STATS n_m++; +# endif cache_segidx[ix] = find_nsegment_idx_WRK(a); cache_pageno[ix] = a >> 12; return cache_segidx[ix]; diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 6b4f0c9d60..b9c74a7219 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -2664,17 +2664,20 @@ static inline CFSI_m_CacheEnt* cfsi_m_cache__find ( Addr ip ) { UWord hash = ip % N_CFSI_M_CACHE; CFSI_m_CacheEnt* ce = &cfsi_m_cache[hash]; +# ifdef N_Q_M_STATS static UWord n_q = 0, n_m = 0; - n_q++; - if (0 && 0 == (n_q & 0x1FFFFF)) + if (0 == (n_q & 0x1FFFFF)) VG_(printf)("QQQ %lu %lu\n", n_q, n_m); +# endif if (LIKELY(ce->ip == ip) && LIKELY(ce->di != NULL)) { /* found an entry in the cache .. */ } else { /* not found in cache. Search and update. */ +# ifdef N_Q_M_STATS n_m++; +# endif ce->ip = ip; find_DiCfSI( &ce->di, &ce->cfsi_m, ip ); }