summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/parser/JSParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/parser/JSParser.cpp')
-rw-r--r--Source/JavaScriptCore/parser/JSParser.cpp48
1 files changed, 8 insertions, 40 deletions
diff --git a/Source/JavaScriptCore/parser/JSParser.cpp b/Source/JavaScriptCore/parser/JSParser.cpp
index cb59f93..993dd66 100644
--- a/Source/JavaScriptCore/parser/JSParser.cpp
+++ b/Source/JavaScriptCore/parser/JSParser.cpp
@@ -34,6 +34,7 @@ using namespace JSC;
#include "NodeInfo.h"
#include "ASTBuilder.h"
#include "SourceProvider.h"
+#include "SourceProviderCacheItem.h"
#include <wtf/HashFunctions.h>
#include <wtf/WTFThreadData.h>
#include <utility>
@@ -96,39 +97,6 @@ private:
bool m_isLoop;
};
- struct CachedFunctionInfo : public SourceProviderCache::Item {
- CachedFunctionInfo(int closeBraceLine, int closeBracePos)
- : closeBraceLine(closeBraceLine)
- , closeBracePos(closeBracePos)
- {
- }
- unsigned approximateByteSize() const
- {
- // The identifiers are uniqued strings so most likely there are few names that actually use any additional memory.
- static const unsigned assummedAverageIdentifierSize = sizeof(RefPtr<StringImpl>) + 2;
- unsigned size = sizeof(*this);
- size += usedVariables.size() * assummedAverageIdentifierSize;
- size += writtenVariables.size() * assummedAverageIdentifierSize;
- return size;
- }
- JSToken closeBraceToken() const
- {
- JSToken token;
- token.m_type = CLOSEBRACE;
- token.m_data.intValue = closeBracePos;
- token.m_info.startOffset = closeBracePos;
- token.m_info.endOffset = closeBracePos + 1;
- token.m_info.line = closeBraceLine;
- return token;
- }
-
- int closeBraceLine;
- int closeBracePos;
- bool usesEval;
- Vector<RefPtr<StringImpl> > usedVariables;
- Vector<RefPtr<StringImpl> > writtenVariables;
- };
-
void next(Lexer::LexType lexType = Lexer::IdentifyReservedWords)
{
m_lastLine = m_token.m_info.line;
@@ -463,7 +431,7 @@ private:
vector.shrinkToFit();
}
- void saveFunctionInfo(CachedFunctionInfo* info)
+ void saveFunctionInfo(SourceProviderCacheItem* info)
{
ASSERT(m_isFunction);
info->usesEval = m_usesEval;
@@ -471,7 +439,7 @@ private:
copyCapturedVariablesToVector(m_usedVariables, info->usedVariables);
}
- void restoreFunctionInfo(const CachedFunctionInfo* info)
+ void restoreFunctionInfo(const SourceProviderCacheItem* info)
{
ASSERT(m_isFunction);
m_usesEval = info->usesEval;
@@ -609,9 +577,9 @@ private:
ScopeStack m_scopeStack;
- const CachedFunctionInfo* findCachedFunctionInfo(int openBracePos)
+ const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos)
{
- return m_functionCache ? static_cast<const CachedFunctionInfo*>(m_functionCache->get(openBracePos)) : 0;
+ return m_functionCache ? m_functionCache->get(openBracePos) : 0;
}
SourceProviderCache* m_functionCache;
@@ -1318,7 +1286,7 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc
openBracePos = m_token.m_data.intValue;
bodyStartLine = tokenLine();
- if (const CachedFunctionInfo* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) {
+ if (const SourceProviderCacheItem* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) {
// If we know about this function already, we can use the cached info and skip the parser to the end of the function.
body = context.createFunctionBody(strictMode());
@@ -1347,10 +1315,10 @@ template <JSParser::FunctionRequirements requirements, bool nameIsInContainingSc
// Cache the tokenizer state and the function scope the first time the function is parsed.
// Any future reparsing can then skip the function.
static const int minimumFunctionLengthToCache = 64;
- OwnPtr<CachedFunctionInfo> newInfo;
+ OwnPtr<SourceProviderCacheItem> newInfo;
int functionLength = closeBracePos - openBracePos;
if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) {
- newInfo = adoptPtr(new CachedFunctionInfo(m_token.m_info.line, closeBracePos));
+ newInfo = adoptPtr(new SourceProviderCacheItem(m_token.m_info.line, closeBracePos));
functionScope->saveFunctionInfo(newInfo.get());
}