From db46b36eb4ebbe59dc434c7cb1f2237336bb3d70 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 24 Jul 2015 09:47:11 +0200 Subject: [PATCH] [mc] Comment the binary search in ObjectInformation::find_function() --- src/mc/mc_object_info.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mc/mc_object_info.cpp b/src/mc/mc_object_info.cpp index 46c4630101..e4bdb0da2b 100644 --- a/src/mc/mc_object_info.cpp +++ b/src/mc/mc_object_info.cpp @@ -128,10 +128,18 @@ simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const int j = this->functions_index.size() - 1; while (j >= i) { int k = i + ((j - i) / 2); + + /* In most of the search, we do not dereference the base[k].function. + * This way the memory accesses are located in the base[k] array. */ if (ip < base[k].low_pc) j = k - 1; else if (k < j && ip >= base[k + 1].low_pc) i = k + 1; + + /* At this point, the search is over. + * Either we have found the correct function or we do not know + * any function corresponding to this instruction address. + * Only at the point do we derefernce the function pointer. */ else if (ip < base[k].function->high_pc) return base[k].function; else -- 2.20.1