]> granicus.if.org Git - clang/commitdiff
PTH:
authorTed Kremenek <kremenek@apple.com>
Tue, 23 Dec 2008 02:52:12 +0000 (02:52 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 23 Dec 2008 02:52:12 +0000 (02:52 +0000)
- Encode the token length with 2 bytes instead of 4.
- This reduces the size of the .pth file for Cocoa.h by 12%.
- This speeds up PTH time (-Eonly) on Cocoa.h by 1.6%.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61364 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/CacheTokens.cpp
lib/Lex/PTHLexer.cpp

index d8c92497b6bd3525d7eed9b744b45d043f9942b9..c97b2259d52d5387e58d1933cdf34dab52981b23 100644 (file)
@@ -30,6 +30,10 @@ typedef uint32_t Offset;
 typedef llvm::DenseMap<const FileEntry*,std::pair<Offset,Offset> > PCHMap;
 typedef llvm::DenseMap<const IdentifierInfo*,uint32_t> IDMap;
 
+static void Emit8(llvm::raw_ostream& Out, uint32_t V) {
+  Out << (unsigned char)(V);
+}
+
 static void Emit32(llvm::raw_ostream& Out, uint32_t V) {
   Out << (unsigned char)(V);
   Out << (unsigned char)(V >>  8);
@@ -37,8 +41,10 @@ static void Emit32(llvm::raw_ostream& Out, uint32_t V) {
   Out << (unsigned char)(V >> 24);
 }
 
-static void Emit8(llvm::raw_ostream& Out, uint32_t V) {
+static void Emit16(llvm::raw_ostream& Out, uint32_t V) {
   Out << (unsigned char)(V);
+  Out << (unsigned char)(V >>  8);
+  assert((V >> 16) == 0);
 }
 
 static void EmitBuf(llvm::raw_ostream& Out, const char* I, const char* E) {
@@ -69,7 +75,7 @@ static void EmitToken(llvm::raw_ostream& Out, const Token& T,
   Emit8(Out, T.getFlags());
   Emit32(Out, ResolveID(IM, idcount, T.getIdentifierInfo()));
   Emit32(Out, SMgr.getFullFilePos(T.getLocation()));
-  Emit32(Out, T.getLength());
+  Emit16(Out, T.getLength());
 }
 
 struct IDData {
index 1038e3b70ccba6d6f2c39770961a473da2c93aa9..252e2f87daa98e8a97ae3dae98a578feafabafad 100644 (file)
@@ -26,7 +26,7 @@
 
 using namespace clang;
 
-#define DISK_TOKEN_SIZE (2+3*4)
+#define DISK_TOKEN_SIZE (2+4+4+2)
 
 //===----------------------------------------------------------------------===//
 // Utility methods for reading from the mmap'ed PTH file.
@@ -79,9 +79,7 @@ LexNextToken:
       | (((uint32_t) CurPtrShadow[9]) << 24);
   
   uint32_t Len = ((uint32_t) CurPtrShadow[10])
-      | (((uint32_t) CurPtrShadow[11]) << 8)
-      | (((uint32_t) CurPtrShadow[12]) << 16)
-      | (((uint32_t) CurPtrShadow[13]) << 24);
+      | (((uint32_t) CurPtrShadow[11]) << 8);
   
   CurPtr = (const char*) (CurPtrShadow + DISK_TOKEN_SIZE);