aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/IdentifierTable.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-15 18:47:46 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-15 18:47:46 +0000
commit72b1b15ee88aac0a63e2c1dc53fe22f5ab297b20 (patch)
tree525dfef2340cc9e228a1be10104d902ef7d9eaee /lib/Basic/IdentifierTable.cpp
parentf185319f25efd6094870f287030270fad26085ba (diff)
IdentifierInfo:
- IdentifierInfo can now (optionally) have its string data not be co-located with itself. This is for use with PTH. This aspect is a little gross, as getName() and getLength() now make assumptions about a possible alternate representation of IdentifierInfo. Perhaps we should make IdentifierInfo have virtual methods? IdentifierTable: - Added class "IdentifierInfoLookup" that can be used by IdentifierTable to perform "string -> IdentifierInfo" lookups using an auxilliary data structure. This is used by PTH. - Perform tests show that IdentifierTable::get() does not slow down because of the extra check for the IdentiferInfoLookup object (the regular StringMap lookup does enough work to mitigate the impact of an extra null pointer check). - The upshot is that now that some IdentifierInfo objects might be owned by the IdentiferInfoLookup object. This should be reviewed. PTH: - Modified PTHManager::GetIdentifierInfo to *not* insert entries in IdentifierTable's string map, and instead create IdentifierInfo objects on the fly when mapping from persistent IDs to IdentifierInfos. This saves a ton of work with string copies, hashing, and StringMap lookup and resizing. This change was motivated because when processing source files in the PTH cache we don't need to do any string -> IdentifierInfo lookups. - PTHManager now subclasses IdentifierInfoLookup, allowing clients of IdentifierTable to transparently use IdentifierInfo objects managed by the PTH file. PTHManager resolves "string -> IdentifierInfo" queries by doing a binary search over a sorted table of identifier strings in the PTH file (the exact algorithm we use can be changed as needed). These changes lead to the following performance changes when using PTH on Cocoa.h: - fsyntax-only: 10% performance improvement - Eonly: 30% performance improvement git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62273 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/IdentifierTable.cpp')
-rw-r--r--lib/Basic/IdentifierTable.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp
index 048abf8b2e..1243e3eb8a 100644
--- a/lib/Basic/IdentifierTable.cpp
+++ b/lib/Basic/IdentifierTable.cpp
@@ -25,7 +25,7 @@ using namespace clang;
// IdentifierInfo Implementation
//===----------------------------------------------------------------------===//
-IdentifierInfo::IdentifierInfo() {
+IdentifierInfo::IdentifierInfo(bool usesIndirectString) {
TokenID = tok::identifier;
ObjCOrBuiltinID = 0;
HasMacro = false;
@@ -33,15 +33,19 @@ IdentifierInfo::IdentifierInfo() {
IsPoisoned = false;
IsCPPOperatorKeyword = false;
FETokenInfo = 0;
+ IndirectString = usesIndirectString;
}
//===----------------------------------------------------------------------===//
// IdentifierTable Implementation
//===----------------------------------------------------------------------===//
-IdentifierTable::IdentifierTable(const LangOptions &LangOpts)
- // Start with space for 8K identifiers.
- : HashTable(8192) {
+IdentifierInfoLookup::~IdentifierInfoLookup() {}
+
+IdentifierTable::IdentifierTable(const LangOptions &LangOpts,
+ IdentifierInfoLookup* externalLookup)
+ : HashTable(8192), // Start with space for 8K identifiers.
+ ExternalLookup(externalLookup) {
// Populate the identifier table with info about keywords for the current
// language.
@@ -50,7 +54,7 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts)
// This cstor is intended to be used only for serialization.
IdentifierTable::IdentifierTable()
- : HashTable(8192) { }
+ : HashTable(8192), ExternalLookup(0) { }
//===----------------------------------------------------------------------===//
// Language Keyword Implementation