/* --- Counters, for informational purposes only. --- */
-/* Number of lookups which miss the fast tt helper. */
-extern UInt VG_(tt_fast_misses);
-
-/* Counts for TT/TC informational messages. */
-
-/* Number and total o/t size of translations overall. */
-extern UInt VG_(overall_in_count);
-extern UInt VG_(overall_in_osize);
-extern UInt VG_(overall_in_tsize);
-/* Number and total o/t size of discards overall. */
-extern UInt VG_(overall_out_count);
-extern UInt VG_(overall_out_osize);
-extern UInt VG_(overall_out_tsize);
-/* The number of discards of TT/TC. */
-extern UInt VG_(number_of_tc_discards);
-/* Counts of chain and unchain operations done. */
-extern UInt VG_(bb_enchain_count);
-extern UInt VG_(bb_dechain_count);
-/* Number of unchained jumps performed. */
-extern UInt VG_(unchained_jumps_done);
+// These counters must be declared here because they're maintained by
+// vg_dispatch.S.
+extern UInt VG_(bb_enchain_count); // Counts of chain operations done
+extern UInt VG_(bb_dechain_count); // Counts of unchain operations done
+extern UInt VG_(unchained_jumps_done); // Number of unchained jumps performed
extern void VG_(print_scheduler_stats) ( void );
/* The fast-cache for tt-lookup. */
extern Addr VG_(tt_fast)[VG_TT_FAST_SIZE];
+extern void VG_(init_tt_tc) ( void );
extern void VG_(add_to_trans_tab) ( Addr orig_addr, Int orig_size,
Addr trans_addr, Int trans_size,
UShort jumps[VG_MAX_JUMPS]);
+extern Addr VG_(search_transtab) ( Addr original_addr );
-extern void VG_(invalidate_translations) ( Addr start, UInt range, Bool unchain_blocks );
+extern void VG_(invalidate_translations) ( Addr start, UInt range,
+ Bool unchain_blocks );
-extern void VG_(init_tt_tc) ( void );
+extern void VG_(sanity_check_tt_tc) ( void );
-extern void VG_(sanity_check_tc_tt) ( void );
-extern Addr VG_(search_transtab) ( Addr original_addr );
+extern void VG_(print_tt_tc_stats) ( void );
+
+extern Int VG_(get_bbs_translated) ( void );
/* ---------------------------------------------------------------------
Exports of vg_syscall.S
/* jmp_buf for fatal signals; VG_(fatal_signal_jmpbuf_ptr) is NULL until
the time is right that it can be used. */
-Int VG_(fatal_sigNo) = -1;
-jmp_buf* VG_(fatal_signal_jmpbuf_ptr) = NULL;
-jmp_buf fatal_signal_jmpbuf;
+ Int VG_(fatal_sigNo) = -1;
+ jmp_buf* VG_(fatal_signal_jmpbuf_ptr) = NULL;
+static jmp_buf fatal_signal_jmpbuf;
/* Counts downwards in VG_(run_innerloop). */
UInt VG_(dispatch_ctr);
/*=== Counters, for profiling purposes only ===*/
/*====================================================================*/
-/* Number of lookups which miss the fast tt helper. */
-UInt VG_(tt_fast_misses) = 0;
-
-
-/* Counts for TT/TC informational messages. */
-
-/* Number and total o/t size of translations overall. */
-UInt VG_(overall_in_count) = 0;
-UInt VG_(overall_in_osize) = 0;
-UInt VG_(overall_in_tsize) = 0;
-/* Number and total o/t size of discards overall. */
-UInt VG_(overall_out_count) = 0;
-UInt VG_(overall_out_osize) = 0;
-UInt VG_(overall_out_tsize) = 0;
-/* The number of discards of TT/TC. */
-UInt VG_(number_of_tc_discards) = 0;
-/* Counts of chain and unchain operations done. */
-UInt VG_(bb_enchain_count) = 0;
-UInt VG_(bb_dechain_count) = 0;
-/* Number of unchained jumps performed. */
-UInt VG_(unchained_jumps_done) = 0;
+// These ones maintained by vg_dispatch.S
+UInt VG_(bb_enchain_count) = 0; // Number of chain operations done
+UInt VG_(bb_dechain_count) = 0; // Number of unchain operations done
+UInt VG_(unchained_jumps_done) = 0; // Number of unchained jumps done
/* Counts pertaining to internal sanity checking. */
static UInt sanity_fast_count = 0;
static UInt sanity_slow_count = 0;
-static __inline__ Int safe_idiv(Int a, Int b)
-{
- return (b == 0 ? 0 : a / b);
-}
-
static void print_all_stats ( void )
{
// Translation stats
+ VG_(print_tt_tc_stats)();
VG_(message)(Vg_DebugMsg,
- " TT/TC: %d tc sectors discarded.",
- VG_(number_of_tc_discards) );
- VG_(message)(Vg_DebugMsg,
- " %d tt_fast misses.", VG_(tt_fast_misses));
- VG_(message)(Vg_DebugMsg,
- " %d chainings, %d unchainings.",
+ "chainings: %d chainings, %d unchainings.",
VG_(bb_enchain_count), VG_(bb_dechain_count) );
- VG_(message)(Vg_DebugMsg,
- "translate: new %d (%d -> %d; ratio %d:10)",
- VG_(overall_in_count),
- VG_(overall_in_osize),
- VG_(overall_in_tsize),
- safe_idiv(10*VG_(overall_in_tsize), VG_(overall_in_osize)));
- VG_(message)(Vg_DebugMsg,
- " discard %d (%d -> %d; ratio %d:10).",
- VG_(overall_out_count),
- VG_(overall_out_osize),
- VG_(overall_out_tsize),
- safe_idiv(10*VG_(overall_out_tsize), VG_(overall_out_osize)));
VG_(message)(Vg_DebugMsg,
" dispatch: %llu jumps (bb entries); of them %u (%lu%%) unchained.",
VG_(bbs_done),
# endif
if ((sanity_fast_count % 250) == 0)
- VG_(sanity_check_tc_tt)();
+ VG_(sanity_check_tt_tc)();
if (VG_(needs).sanity_checks) {
VGP_PUSHCC(VgpSkinExpensiveSanity);
few blocks translated prior to a failure. Set
notrace_until_limit to be the number of translations to be made
before --trace-codegen= style printing takes effect. */
- notrace_until_done = VG_(overall_in_count) >= notrace_until_limit;
+ notrace_until_done = VG_(get_bbs_translated)() >= notrace_until_limit;
seg = VG_(find_segment)(orig_addr);
Char fnname[64] = "";
VG_(get_fnname_if_entry)(orig_addr, fnname, 64);
VG_(printf)(
- "==== BB %d %s(%p) in %dB, out %dB, BBs exec'd %llu ====\n\n",
- VG_(overall_in_count), fnname, orig_addr,
- VG_(overall_in_osize), VG_(overall_in_tsize),
+ "==== BB %d %s(%p) approx BBs exec'd %llu ====\n\n",
+ VG_(get_bbs_translated)(), fnname, orig_addr,
VG_(bbs_done));
}
static Int vg_tc_stats_osize[VG_TC_N_SECTORS];
static Int vg_tc_stats_tsize[VG_TC_N_SECTORS];
+static UInt n_tt_fast_misses = 0; // number of lookups missing fast TT helper
+static UInt n_tc_discards = 0; // number of TT/TC discards
+
+// Number and total original/translated size of translations overall.
+static UInt overall_in_count = 0;
+static UInt overall_in_osize = 0;
+static UInt overall_in_tsize = 0;
+// Number and total original/t size of discards overall.
+static UInt overall_out_count = 0;
+static UInt overall_out_osize = 0;
+static UInt overall_out_tsize = 0;
+
+
/*------------------ TRANSLATION TABLE ------------------*/
}
pp_tt_tc_status ( msg );
- VG_(overall_out_count) += vg_tc_stats_count[s];
- VG_(overall_out_osize) += vg_tc_stats_osize[s];
- VG_(overall_out_tsize) += vg_tc_stats_tsize[s];
+ overall_out_count += vg_tc_stats_count[s];
+ overall_out_osize += vg_tc_stats_osize[s];
+ overall_out_tsize += vg_tc_stats_tsize[s];
vg_tc_used[s] = 0;
vg_tc_stats_count[s] = 0;
vg_tc_stats_osize[s] = 0;
vg_tc_stats_tsize[s] = 0;
- VG_(number_of_tc_discards) ++;
+ n_tc_discards++;
}
}
Int s;
for (s = 0; s < VG_TC_N_SECTORS; s++) {
if (vg_tc[s] != NULL && vg_tc_used[s] == 0) {
- vg_tc_age[s] = VG_(overall_in_count);
+ vg_tc_age[s] = overall_in_count;
VG_(sprintf)(msg, "after commission of sector %d "
"at time %d",
s, vg_tc_age[s]);
pp_tt_tc_status ( msg );
# ifdef DEBUG_TRANSTAB
- VG_(sanity_check_tc_tt)();
+ VG_(sanity_check_tt_tc)();
# endif
return s;
}
vg_tc_current = maybe_commission_sector();
vg_assert(vg_tc_current >= 0 && vg_tc_current < VG_TC_N_SECTORS);
# ifdef DEBUG_TRANSTAB
- VG_(sanity_check_tc_tt)();
+ VG_(sanity_check_tt_tc)();
# endif
return allocate(nBytes);
/* Do a sanity check on TT/TC.
*/
-void VG_(sanity_check_tc_tt) ( void )
+void VG_(sanity_check_tt_tc) ( void )
{
Int i, s;
TTEntry* tte;
}
}
+static __inline__ Int safe_idiv(Int a, Int b)
+{
+ return (b == 0 ? 0 : a / b);
+}
+
+void VG_(print_tt_tc_stats)(void)
+{
+ VG_(message)(Vg_DebugMsg,
+ " TT/TC: %d tc sectors discarded.",
+ n_tc_discards );
+ VG_(message)(Vg_DebugMsg,
+ " %d tt_fast misses.",
+ n_tt_fast_misses);
+ VG_(message)(Vg_DebugMsg,
+ "translate: new %d (%d -> %d; ratio %d:10)",
+ overall_in_count, overall_in_osize, overall_in_tsize,
+ safe_idiv(10*overall_in_tsize, overall_in_osize));
+ VG_(message)(Vg_DebugMsg,
+ " discard %d (%d -> %d; ratio %d:10).",
+ overall_out_count, overall_out_osize, overall_out_tsize,
+ safe_idiv(10*overall_out_tsize, overall_out_osize));
+}
+
+Int VG_(get_bbs_translated) ( void )
+{
+ return overall_in_count;
+}
/* Add this already-filled-in entry to the TT. Assumes that the
relevant code chunk has been placed in TC, along with a dummy back
add_tt_entry(tce);
/* Update stats. */
- VG_(overall_in_count) ++;
- VG_(overall_in_osize) += orig_size;
- VG_(overall_in_tsize) += trans_size;
+ overall_in_count ++;
+ overall_in_osize += orig_size;
+ overall_in_tsize += trans_size;
vg_tc_stats_count[vg_tc_current] ++;
vg_tc_stats_osize[vg_tc_current] += orig_size;
/* Found it. Put the search result into the fast cache now. */
UInt cno = (UInt)original_addr & VG_TT_FAST_MASK;
VG_(tt_fast)[cno] = (Addr)(tte->tcentry);
- VG_(tt_fast_misses)++;
+ n_tt_fast_misses++;
VGP_POPCC(VgpSlowFindT);
return (Addr)&(tte->tcentry->payload[0]);
}
Int i, j;
TCEntry* tce;
# ifdef DEBUG_TRANSTAB
- VG_(sanity_check_tc_tt)();
+ VG_(sanity_check_tt_tc)();
# endif
i_start = start;
i_end = start + range - 1;
}
}
- VG_(overall_out_count) ++;
- VG_(overall_out_osize) += tce->orig_size;
- VG_(overall_out_tsize) += tce->trans_size;
+ overall_out_count ++;
+ overall_out_osize += tce->orig_size;
+ overall_out_tsize += tce->trans_size;
out_count ++;
out_osize += tce->orig_size;
out_tsize += tce->trans_size;
if (out_count > 0) {
vg_invalidate_tt_fast();
- VG_(sanity_check_tc_tt)();
+ VG_(sanity_check_tt_tc)();
# ifdef DEBUG_TRANSTAB
{ Addr aa;
for (aa = i_start; aa <= i_end; aa++)
}
# ifdef DEBUG_TRANSTAB
- VG_(sanity_check_tc_tt)();
+ VG_(sanity_check_tt_tc)();
# endif
}