diff options
author | Pavel Labath <labath@google.com> | 2017-05-15 13:02:37 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-05-15 13:02:37 +0000 |
commit | f9d16476573e16856bdb3250c817b0a2c631d2b1 (patch) | |
tree | 7cae9a3d7fb178078ab0e4990ebf991c93679c08 /lldb/source/Symbol/ObjectFile.cpp | |
parent | 3030bf0c816b136c97d8c69ca8b38e394eefd5d2 (diff) | |
download | bcm5719-llvm-f9d16476573e16856bdb3250c817b0a2c631d2b1.tar.gz bcm5719-llvm-f9d16476573e16856bdb3250c817b0a2c631d2b1.zip |
Remove an expensive lock from Timer
The Timer destructor would grab a global mutex in order to update
execution time. Add a class to define a category once, statically; the
class adds itself to an atomic singly linked list, and thus subsequent
updates only need to use an atomic rather than grab a lock and perform a
hashtable lookup.
Differential Revision: https://reviews.llvm.org/D32823
Patch by Scott Smith <scott.smith@purestorage.com>.
llvm-svn: 303058
Diffstat (limited to 'lldb/source/Symbol/ObjectFile.cpp')
-rw-r--r-- | lldb/source/Symbol/ObjectFile.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 9b2318e885d..c970de6fef0 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -37,8 +37,9 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file, ObjectFileSP object_file_sp; if (module_sp) { + static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer( - LLVM_PRETTY_FUNCTION, + func_cat, "ObjectFile::FindPlugin (module = %s, file = %p, file_offset = " "0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")", module_sp->GetFileSpec().GetPath().c_str(), @@ -176,9 +177,11 @@ ObjectFileSP ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, ObjectFileSP object_file_sp; if (module_sp) { - Timer scoped_timer(LLVM_PRETTY_FUNCTION, "ObjectFile::FindPlugin (module = " - "%s, process = %p, header_addr = " - "0x%" PRIx64 ")", + static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); + Timer scoped_timer(func_cat, + "ObjectFile::FindPlugin (module = " + "%s, process = %p, header_addr = " + "0x%" PRIx64 ")", module_sp->GetFileSpec().GetPath().c_str(), static_cast<void *>(process_sp.get()), header_addr); uint32_t idx; |