[cfe-commits] r61377 - in /cfe/trunk: Driver/CacheTokens.cpp lib/Lex/PTHLexer.cpp

Ted Kremenek kremenek at apple.com
Tue Dec 23 10:41:36 PST 2008


Author: kremenek
Date: Tue Dec 23 12:41:34 2008
New Revision: 61377

URL: http://llvm.org/viewvc/llvm-project?rev=61377&view=rev
Log:
PTH: Use 3 bytes instead of 4 bytes to encode the persistent ID for a token.
- This reduces the PTH size for Cocoa.h by 7%.
- The increases PTH -Eonly speed for Cocoa.h by 0.8%.


Modified:
    cfe/trunk/Driver/CacheTokens.cpp
    cfe/trunk/lib/Lex/PTHLexer.cpp

Modified: cfe/trunk/Driver/CacheTokens.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/CacheTokens.cpp?rev=61377&r1=61376&r2=61377&view=diff

==============================================================================
--- cfe/trunk/Driver/CacheTokens.cpp (original)
+++ cfe/trunk/Driver/CacheTokens.cpp Tue Dec 23 12:41:34 2008
@@ -47,6 +47,13 @@
   assert((V >> 16) == 0);
 }
 
+static void Emit24(llvm::raw_ostream& Out, uint32_t V) {
+  Out << (unsigned char)(V);
+  Out << (unsigned char)(V >>  8);
+  Out << (unsigned char)(V >> 16);
+  assert((V >> 24) == 0);
+}
+
 static void EmitBuf(llvm::raw_ostream& Out, const char* I, const char* E) {
   for ( ; I != E ; ++I) Out << *I;
 }
@@ -73,7 +80,7 @@
   
   Emit8(Out, T.getKind());
   Emit8(Out, T.getFlags());
-  Emit32(Out, ResolveID(IM, idcount, T.getIdentifierInfo()));
+  Emit24(Out, ResolveID(IM, idcount, T.getIdentifierInfo()));
   Emit32(Out, SMgr.getFullFilePos(T.getLocation()));
   Emit16(Out, T.getLength());
 }

Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=61377&r1=61376&r2=61377&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Tue Dec 23 12:41:34 2008
@@ -26,7 +26,7 @@
 
 using namespace clang;
 
-#define DISK_TOKEN_SIZE (2+4+4+2)
+#define DISK_TOKEN_SIZE (1+1+3+4+2)
 
 //===----------------------------------------------------------------------===//
 // Utility methods for reading from the mmap'ed PTH file.
@@ -69,16 +69,15 @@
     
   uint32_t perID = ((uint32_t) CurPtrShadow[2])
       | (((uint32_t) CurPtrShadow[3]) << 8)
-      | (((uint32_t) CurPtrShadow[4]) << 16)
-      | (((uint32_t) CurPtrShadow[5]) << 24);
+      | (((uint32_t) CurPtrShadow[4]) << 16);
   
-  uint32_t FileOffset = ((uint32_t) CurPtrShadow[6])
-      | (((uint32_t) CurPtrShadow[7]) << 8)
-      | (((uint32_t) CurPtrShadow[8]) << 16)
-      | (((uint32_t) CurPtrShadow[9]) << 24);
+  uint32_t FileOffset = ((uint32_t) CurPtrShadow[5])
+      | (((uint32_t) CurPtrShadow[6]) << 8)
+      | (((uint32_t) CurPtrShadow[7]) << 16)
+      | (((uint32_t) CurPtrShadow[8]) << 24);
   
-  uint32_t Len = ((uint32_t) CurPtrShadow[10])
-      | (((uint32_t) CurPtrShadow[11]) << 8);
+  uint32_t Len = ((uint32_t) CurPtrShadow[9])
+      | (((uint32_t) CurPtrShadow[10]) << 8);
   
   CurPtr = (const char*) (CurPtrShadow + DISK_TOKEN_SIZE);
   





More information about the cfe-commits mailing list