]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Small optimisation : use preprocessor for cache stats
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 12 Mar 2016 21:38:22 +0000 (21:38 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 12 Mar 2016 21:38:22 +0000 (21:38 +0000)
as the compiler does not remove the access to the not useful static vars

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15828

coregrind/m_aspacemgr/aspacemgr-linux.c
coregrind/m_debuginfo/debuginfo.c

index 38b7533afd834d300f26e1daa01522203724ba62..edd0541425e692dc968814f555cdd43d30cdc41a 100644 (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];
index 6b4f0c9d60fe3e2978d6a33dc537503db7e05b1c..b9c74a7219097c21596672f1e8f88bb666a0dcf6 100644 (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 );
    }