diff options
author | Tamas Berghammer <tberghammer@google.com> | 2015-10-27 10:43:27 +0000 |
---|---|---|
committer | Tamas Berghammer <tberghammer@google.com> | 2015-10-27 10:43:27 +0000 |
commit | 9fa114705282d226ff3a3de6c8b270208c57de89 (patch) | |
tree | dab1aad2868bde324b6abba4a1a4a26f89daa79f /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | |
parent | 458e79b814b9998368b2306b09393b74f220f62d (diff) | |
download | bcm5719-llvm-9fa114705282d226ff3a3de6c8b270208c57de89.tar.gz bcm5719-llvm-9fa114705282d226ff3a3de6c8b270208c57de89.zip |
Some minor improvements on the symtab parsing code
* Remove an unneccessary re-computaion on arch spec from the ELF file
* Use a local cache to optimize name based section lookups in symtab
parsing
* Optimize C++ method basename validation with replacing a regex with
hand written code
These modifications reduce the time required to parse the symtab from
large applications by ~25% (tested with LLDB as inferior)
Differential revision: http://reviews.llvm.org/D14088
llvm-svn: 251402
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 0884a1c8ff2..88c1c97c61e 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -11,6 +11,7 @@ #include <cassert> #include <algorithm> +#include <unordered_map> #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataBuffer.h" @@ -1943,6 +1944,13 @@ ObjectFileELF::ParseSymbols (Symtab *symtab, // makes it highly unlikely that this will collide with anything else. bool skip_oatdata_oatexec = m_file.GetFilename() == ConstString("system@framework@boot.oat"); + ArchSpec arch; + GetArchitecture(arch); + + // Local cache to avoid doing a FindSectionByName for each symbol. The "const char*" key must + // came from a ConstString object so they can be compared by pointer + std::unordered_map<const char*, lldb::SectionSP> section_name_to_section; + unsigned i; for (i = 0; i < num_symbols; ++i) { @@ -2048,8 +2056,7 @@ ObjectFileELF::ParseSymbols (Symtab *symtab, int64_t symbol_value_offset = 0; uint32_t additional_flags = 0; - ArchSpec arch; - if (GetArchitecture(arch)) + if (arch.IsValid()) { if (arch.GetMachine() == llvm::Triple::arm) { @@ -2175,11 +2182,13 @@ ObjectFileELF::ParseSymbols (Symtab *symtab, if (module_section_list && module_section_list != section_list) { const ConstString §_name = symbol_section_sp->GetName(); - lldb::SectionSP section_sp (module_section_list->FindSectionByName (sect_name)); - if (section_sp && section_sp->GetFileSize()) - { - symbol_section_sp = section_sp; - } + auto section_it = section_name_to_section.find(sect_name.GetCString()); + if (section_it == section_name_to_section.end()) + section_it = section_name_to_section.emplace( + sect_name.GetCString(), + module_section_list->FindSectionByName (sect_name)).first; + if (section_it->second && section_it->second->GetFileSize()) + symbol_section_sp = section_it->second; } } } |