summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Mangled.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2014-07-22 17:03:38 +0000
committerKate Stone <katherine.stone@apple.com>2014-07-22 17:03:38 +0000
commite2b218665221ca4d37dabb4204ddb2b3acfb4c4d (patch)
treeb767138bb2dc5f3fc4ddc3c8ba83e3645e174a5c /lldb/source/Core/Mangled.cpp
parentccc7090671cda0f1a6578988659b877b57d91ce5 (diff)
downloadbcm5719-llvm-e2b218665221ca4d37dabb4204ddb2b3acfb4c4d.tar.gz
bcm5719-llvm-e2b218665221ca4d37dabb4204ddb2b3acfb4c4d.zip
Dramatically improves C++ demangling performance by introducing a new implementation that is much faster than the existing demangler. While not yet complete, the new demangler will fail gracefully when it encounters symbols it isn’t prepared to deal with. In these cases LLDB will fall back to using the full demangler to prevent a loss in functionality. On sizable code bases the fast path succeeds 95% of the time, providing a significant net win.
The new implementation is located in source/Core/FastDemangle.cpp. It’s fairly straightforward C code with a few basic C++ extensions. It should compile with little or no change on a variety of platforms, but of course it is still only useful for symbols that comply with the Itanium ABI mangling spec (plus a few Clang extensions.) <rdar://problem/15397553> <rdar://problem/15794867> llvm-svn: 213671
Diffstat (limited to 'lldb/source/Core/Mangled.cpp')
-rw-r--r--lldb/source/Core/Mangled.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 8df9fb8a239..b20013fed45 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -20,6 +20,14 @@
#ifdef LLDB_USE_BUILTIN_DEMANGLER
+// Provide a fast-path demangler implemented in FastDemangle.cpp until it can
+// replace the existing C++ demangler with a complete implementation
+namespace lldb_private
+{
+ extern char * FastDemangle (const char * mangled_name,
+ long mangled_name_length);
+}
+
//----------------------------------------------------------------------
// Inlined copy of:
// http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp
@@ -5129,7 +5137,6 @@ Mangled::SetValue (const ConstString &name)
}
}
-
//----------------------------------------------------------------------
// Generate the demangled name on demand using this accessor. Code in
// this class will need to use this accessor if it wishes to decode
@@ -5151,6 +5158,7 @@ Mangled::GetDemangledName () const
// Don't bother running anything that isn't mangled
const char *mangled_cstr = m_mangled.GetCString();
+ long mangled_length = m_mangled.GetLength();
if (cstring_is_mangled(mangled_cstr))
{
if (!m_mangled.GetMangledCounterpart(m_demangled))
@@ -5158,7 +5166,13 @@ Mangled::GetDemangledName () const
// We didn't already mangle this name, demangle it and if all goes well
// add it to our map.
#ifdef LLDB_USE_BUILTIN_DEMANGLER
- char *demangled_name = __cxa_demangle (mangled_cstr, NULL, NULL, NULL);
+ // Try to use the fast-path demangler first for the
+ // performance win, falling back to the full demangler only
+ // when necessary
+ char *demangled_name = FastDemangle (mangled_cstr,
+ mangled_length);
+ if (!demangled_name)
+ demangled_name = __cxa_demangle (mangled_cstr, NULL, NULL, NULL);
#elif defined(_MSC_VER)
// Cannot demangle on msvc.
char *demangled_name = nullptr;
OpenPOWER on IntegriCloud