From 54558065ee8428cfdc42135f151739fbc787d034 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 25 Aug 2009 16:58:20 -0700 Subject: Index mod_cu_function_cache_t by cu->addr Rather than constructing a "module:cu" string all the time, we can just index the cache by the cu die's addr field. The addr will never change as long as the Dwarf object is still alive. This has a quite noticeable performance impact for scripts that iterate over lots of cus (like for syscall.*). * dwflpp.h (stap_map): Allow void* keys too. (mod_cu_function_cache_t): Index by the void* cu->addr. * dwflpp.cxx (dwflpp::iterate_over_functions): Index cu_function_cache by addr, and build the verbose strings manually when needed. (dwflpp::declaration_resolve): Index global_alias_cache by addr. --- dwflpp.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'dwflpp.h') diff --git a/dwflpp.h b/dwflpp.h index d31d2219..1d6fe0c8 100644 --- a/dwflpp.h +++ b/dwflpp.h @@ -45,19 +45,25 @@ enum info_status { info_unknown, info_present, info_absent }; #ifdef HAVE_TR1_UNORDERED_MAP #include -template struct stap_map { - typedef std::tr1::unordered_map type; +template struct stap_map { + typedef std::tr1::unordered_map type; }; #else #include -template struct stap_map { - typedef __gnu_cxx::hash_map type; - size_t operator() (const std::string& s) const +template struct stap_map { + typedef __gnu_cxx::hash_map type; + size_t operator() (std::string const& s) const { __gnu_cxx::hash h; return h(s.c_str()); } + size_t operator() (void* const& p) const + { __gnu_cxx::hash h; return h(reinterpret_cast(p)); } }; #endif -typedef stap_map::type cu_function_cache_t; // function -> die -typedef stap_map::type mod_cu_function_cache_t; // module:cu -> function -> die + +// function -> die +typedef stap_map::type cu_function_cache_t; + +// cu die -> (function -> die) +typedef stap_map::type mod_cu_function_cache_t; typedef std::vector func_info_map_t; typedef std::vector inline_instance_map_t; -- cgit