Performance improvements from 4 to 8% obtained on amd64 on the perf tests by:
1. using UNLIKELY inside tracing macros
2. avoid calling CLG_(switch_thread)(tid) on the hot patch setup_bbcc
unless tid differs from CLG_(current_tid).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12939
*/
tid = VG_(get_running_tid)();
#if 1
- CLG_(switch_thread)(tid);
+ /* CLG_(switch_thread) is a no-op when tid is equal to CLG_(current_tid).
+ * As this is on the hot path, we only call CLG_(switch_thread)(tid)
+ * if tid differs from the CLG_(current_tid).
+ */
+ if (UNLIKELY(tid != CLG_(current_tid)))
+ CLG_(switch_thread)(tid);
#else
CLG_ASSERT(VG_(get_running_tid)() == CLG_(current_tid));
#endif
#if CLG_ENABLE_DEBUG
#define CLG_DEBUGIF(x) \
- if ( (CLG_(clo).verbose >x) && \
- (CLG_(stat).bb_executions >= CLG_(clo).verbose_start))
+ if (UNLIKELY( (CLG_(clo).verbose >x) && \
+ (CLG_(stat).bb_executions >= CLG_(clo).verbose_start)))
#define CLG_DEBUG(x,format,args...) \
CLG_DEBUGIF(x) { \
}
#define CLG_ASSERT(cond) \
- if (!(cond)) { \
+ if (UNLIKELY(!(cond))) { \
CLG_(print_context)(); \
CLG_(print_bbno)(); \
tl_assert(cond); \