[cfe-commits] r62542 - in /cfe/trunk: Driver/CacheTokens.cpp lib/Lex/PTHLexer.cpp
Ted Kremenek
kremenek at apple.com
Mon Jan 19 15:13:15 PST 2009
Author: kremenek
Date: Mon Jan 19 17:13:15 2009
New Revision: 62542
URL: http://llvm.org/viewvc/llvm-project?rev=62542&view=rev
Log:
PTH: Emitted tokens now consist of 12 bytes that are loaded used 3 32-bit loads. This reduces user time but increases system time because of the slightly larger PTH file. Although there is no performance win on Cocoa.h and -Eonly, overall this seems like a good step.
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=62542&r1=62541&r2=62542&view=diff
==============================================================================
--- cfe/trunk/Driver/CacheTokens.cpp (original)
+++ cfe/trunk/Driver/CacheTokens.cpp Mon Jan 19 17:13:15 2009
@@ -133,12 +133,13 @@
void PTHWriter::EmitToken(const Token& T) {
uint32_t fpos = PP.getSourceManager().getFullFilePos(T.getLocation());
- Emit8(T.getKind());
- Emit8(T.getFlags());
- Emit24(ResolveID(T.getIdentifierInfo()));
+
+ Emit32(((uint32_t) T.getKind()) |
+ (((uint32_t) T.getFlags()) << 8) |
+ (((uint32_t) T.getLength()) << 16));
+ Emit32(ResolveID(T.getIdentifierInfo()));
Emit32(fpos);
- Emit16(T.getLength());
-
+
// For specific tokens we cache their spelling.
if (T.getIdentifierInfo())
return;
@@ -270,9 +271,10 @@
}
PCHEntry PTHWriter::LexTokens(Lexer& L) {
-
- // Record the location within the token file.
- Offset off = (Offset) Out.tell();
+ // Pad 0's so that we emit tokens to a 4-byte alignment.
+ // This speed up reading them back in.
+ Offset off = (Offset) Out.tell();
+ for (unsigned Pad = off % 4 ; Pad != 0 ; --Pad, ++off) Emit8(0);
// Keep track of matching '#if' ... '#endif'.
typedef std::vector<std::pair<Offset, unsigned> > PPCondTable;
Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=62542&r1=62541&r2=62542&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Mon Jan 19 17:13:15 2009
@@ -25,7 +25,7 @@
#include "llvm/ADT/OwningPtr.h"
using namespace clang;
-#define DISK_TOKEN_SIZE (1+1+3+4+2)
+#define DISK_TOKEN_SIZE (1+1+2+4+4)
//===----------------------------------------------------------------------===//
// Utility methods for reading from the mmap'ed PTH file.
@@ -107,11 +107,14 @@
const unsigned char *CurPtrShadow = CurPtr;
// Read in the data for the token.
- tok::TokenKind TKind = (tok::TokenKind) Read8(CurPtrShadow);
- Token::TokenFlags TFlags = (Token::TokenFlags) Read8(CurPtrShadow);
- uint32_t IdentifierID = Read24(CurPtrShadow);
+ unsigned Word0 = Read32(CurPtrShadow);
+ uint32_t IdentifierID = Read32(CurPtrShadow);
uint32_t FileOffset = Read32(CurPtrShadow);
- uint32_t Len = Read16(CurPtrShadow);
+
+ tok::TokenKind TKind = (tok::TokenKind) (Word0 & 0xFF);
+ Token::TokenFlags TFlags = (Token::TokenFlags) ((Word0 >> 8) & 0xFF);
+ uint32_t Len = Word0 >> 16;
+
CurPtr = CurPtrShadow;
//===--------------------------------------==//
More information about the cfe-commits
mailing list