summaryrefslogtreecommitdiffstats
path: root/dwflpp.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-08-28 18:01:51 -0700
committerJosh Stone <jistone@redhat.com>2009-08-28 18:47:34 -0700
commit8d7a7bd9456c6067e874dabf6ee08b0a4e0de7d0 (patch)
tree0aef83c1f1a789d938a4583a84fa0e9c050b0c1c /dwflpp.cxx
parent3a45db133bc306fdbdb2b0c8f3aa7f15f1890d9e (diff)
downloadsystemtap-steved-8d7a7bd9456c6067e874dabf6ee08b0a4e0de7d0.tar.gz
systemtap-steved-8d7a7bd9456c6067e874dabf6ee08b0a4e0de7d0.tar.xz
systemtap-steved-8d7a7bd9456c6067e874dabf6ee08b0a4e0de7d0.zip
Cache inline instance lookups
We used to call dwarf_func_inline_instances to get the locations where inlines are used. This function has to iterate through nearly all DIEs to find instances, which is a lot of redundant work when we're probing multiple inline functions. Now we have our own dwarf iterator to cache all inline instances back to their origin. This only needs to be called once for each CU, and all further inlines are just a map lookup. Some quick benchmarks: stap -l Before After kernel.function("*") 25010ms 2110ms module("*").function("*") 86550ms 16920ms process("stap").function("*") 41330ms 580ms * dwflpp.cxx (dwflpp::cu_inl_function_caching_callback): Removed. (dwflpp::cache_inline_instances): New caching iterator. (dwflpp::iterate_over_inline_instances): Cache each CU once.
Diffstat (limited to 'dwflpp.cxx')
-rw-r--r--dwflpp.cxx61
1 files changed, 50 insertions, 11 deletions
diff --git a/dwflpp.cxx b/dwflpp.cxx
index 7e9894e1..ba8dcec7 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -502,12 +502,52 @@ dwflpp::func_is_inline()
}
-int
-dwflpp::cu_inl_function_caching_callback (Dwarf_Die* func, void *arg)
+void
+dwflpp::cache_inline_instances (Dwarf_Die* die)
{
- vector<Dwarf_Die>* v = static_cast<vector<Dwarf_Die>*>(arg);
- v->push_back (* func);
- return DWARF_CB_OK;
+ // If this is an inline instance, link it back to its origin
+ Dwarf_Die origin;
+ if (dwarf_tag(die) == DW_TAG_inlined_subroutine &&
+ dwarf_attr_die(die, DW_AT_abstract_origin, &origin))
+ {
+ vector<Dwarf_Die>*& v = cu_inl_function_cache[origin.addr];
+ if (!v)
+ v = new vector<Dwarf_Die>;
+ v->push_back(*die);
+ }
+
+ // Recurse through other scopes that may contain inlines
+ Dwarf_Die child, import;
+ if (dwarf_child(die, &child) == 0)
+ do
+ {
+ switch (dwarf_tag (&child))
+ {
+ // tags that could contain inlines
+ case DW_TAG_compile_unit:
+ case DW_TAG_module:
+ case DW_TAG_lexical_block:
+ case DW_TAG_with_stmt:
+ case DW_TAG_catch_block:
+ case DW_TAG_try_block:
+ case DW_TAG_entry_point:
+ case DW_TAG_inlined_subroutine:
+ case DW_TAG_subprogram:
+ cache_inline_instances(&child);
+ break;
+
+ // imported dies should be followed
+ case DW_TAG_imported_unit:
+ if (dwarf_attr_die(&child, DW_AT_import, &import))
+ cache_inline_instances(&import);
+ break;
+
+ // nothing to do for other tags
+ default:
+ break;
+ }
+ }
+ while (dwarf_siblingof(&child, &child) == 0);
}
@@ -518,13 +558,12 @@ dwflpp::iterate_over_inline_instances (int (* callback)(Dwarf_Die * die, void *
assert (function);
assert (func_is_inline ());
+ if (cu_inl_function_cache_done.insert(cu->addr).second)
+ cache_inline_instances(cu);
+
vector<Dwarf_Die>* v = cu_inl_function_cache[function->addr];
- if (v == 0)
- {
- v = new vector<Dwarf_Die>;
- cu_inl_function_cache[function->addr] = v;
- dwarf_func_inline_instances (function, cu_inl_function_caching_callback, v);
- }
+ if (!v)
+ return;
for (vector<Dwarf_Die>::iterator i = v->begin(); i != v->end(); ++i)
{