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
This commit is contained in:
Philippe Waroquiers 2016-03-12 21:38:22 +00:00
parent 64a5086cb1
commit eb2ffd99ee
2 changed files with 12 additions and 6 deletions

View File

@ -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];

View File

@ -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 );
}