Changeset 76611 in webkit for trunk/Source/JavaScriptCore/parser/JSParser.cpp
- Timestamp:
- Jan 25, 2011, 10:44:11 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/JSParser.cpp
r76376 r76611 35 35 #include "ASTBuilder.h" 36 36 #include "SourceProvider.h" 37 #include "SourceProviderCacheItem.h" 37 38 #include <wtf/HashFunctions.h> 38 39 #include <wtf/WTFThreadData.h> … … 97 98 }; 98 99 99 struct CachedFunctionInfo : public SourceProviderCache::Item {100 CachedFunctionInfo(int closeBraceLine, int closeBracePos)101 : closeBraceLine(closeBraceLine)102 , closeBracePos(closeBracePos)103 {104 }105 unsigned approximateByteSize() const106 {107 // The identifiers are uniqued strings so most likely there are few names that actually use any additional memory.108 static const unsigned assummedAverageIdentifierSize = sizeof(RefPtr<StringImpl>) + 2;109 unsigned size = sizeof(*this);110 size += usedVariables.size() * assummedAverageIdentifierSize;111 size += writtenVariables.size() * assummedAverageIdentifierSize;112 return size;113 }114 JSToken closeBraceToken() const115 {116 JSToken token;117 token.m_type = CLOSEBRACE;118 token.m_data.intValue = closeBracePos;119 token.m_info.startOffset = closeBracePos;120 token.m_info.endOffset = closeBracePos + 1;121 token.m_info.line = closeBraceLine;122 return token;123 }124 125 int closeBraceLine;126 int closeBracePos;127 bool usesEval;128 Vector<RefPtr<StringImpl> > usedVariables;129 Vector<RefPtr<StringImpl> > writtenVariables;130 };131 132 100 void next(Lexer::LexType lexType = Lexer::IdentifyReservedWords) 133 101 { … … 464 432 } 465 433 466 void saveFunctionInfo( CachedFunctionInfo* info)434 void saveFunctionInfo(SourceProviderCacheItem* info) 467 435 { 468 436 ASSERT(m_isFunction); … … 472 440 } 473 441 474 void restoreFunctionInfo(const CachedFunctionInfo* info)442 void restoreFunctionInfo(const SourceProviderCacheItem* info) 475 443 { 476 444 ASSERT(m_isFunction); … … 610 578 ScopeStack m_scopeStack; 611 579 612 const CachedFunctionInfo* findCachedFunctionInfo(int openBracePos)580 const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos) 613 581 { 614 return m_functionCache ? static_cast<const CachedFunctionInfo*>(m_functionCache->get(openBracePos)) : 0;582 return m_functionCache ? m_functionCache->get(openBracePos) : 0; 615 583 } 616 584 … … 1319 1287 bodyStartLine = tokenLine(); 1320 1288 1321 if (const CachedFunctionInfo* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) {1289 if (const SourceProviderCacheItem* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) { 1322 1290 // If we know about this function already, we can use the cached info and skip the parser to the end of the function. 1323 1291 body = context.createFunctionBody(strictMode()); … … 1348 1316 // Any future reparsing can then skip the function. 1349 1317 static const int minimumFunctionLengthToCache = 64; 1350 OwnPtr< CachedFunctionInfo> newInfo;1318 OwnPtr<SourceProviderCacheItem> newInfo; 1351 1319 int functionLength = closeBracePos - openBracePos; 1352 1320 if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) { 1353 newInfo = adoptPtr(new CachedFunctionInfo(m_token.m_info.line, closeBracePos));1321 newInfo = adoptPtr(new SourceProviderCacheItem(m_token.m_info.line, closeBracePos)); 1354 1322 functionScope->saveFunctionInfo(newInfo.get()); 1355 1323 }
Note:
See TracChangeset
for help on using the changeset viewer.