Commit 30b760ca authored by oliver@apple.com's avatar oliver@apple.com

Remove harmful string->function cache

https://bugs.webkit.org/show_bug.cgi?id=104193

Reviewed by Alexey Proskuryakov.

Remove the string->function code cache that turned out to actually
be quite harmful.

* runtime/CodeCache.cpp:
(JSC::CodeCache::getFunctionCodeBlock):
* runtime/CodeCache.h:
(JSC::CodeCache::clear):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 92c6f0c5
2012-12-05 Oliver Hunt <oliver@apple.com>
Remove harmful string->function cache
https://bugs.webkit.org/show_bug.cgi?id=104193
Reviewed by Alexey Proskuryakov.
Remove the string->function code cache that turned out to actually
be quite harmful.
* runtime/CodeCache.cpp:
(JSC::CodeCache::getFunctionCodeBlock):
* runtime/CodeCache.h:
(JSC::CodeCache::clear):
2012-12-05 Halton Huo <halton.huo@intel.com>
[CMake] Unify coding style for CMake files
......
......@@ -267,11 +267,6 @@ public:
{
return FunctionBodyNode::create(m_globalData, location, inStrictContext);
}
void setFunctionStart(FunctionBodyNode* body, int functionStart)
{
body->setFunctionStart(functionStart);
}
template <bool> PropertyNode* createGetterOrSetterProperty(const JSTokenLocation& location, PropertyNode::Type type, const Identifier* name, ParameterNode* params, FunctionBodyNode* body, int openBracePos, int closeBracePos, int bodyStartLine, int bodyEndLine)
{
......
......@@ -41,7 +41,6 @@
#include "PropertyNameArray.h"
#include "RegExpObject.h"
#include "SamplingTool.h"
#include "SourceProviderCacheItem.h"
#include <wtf/Assertions.h>
#include <wtf/RefCountedLeakCounter.h>
#include <wtf/Threading.h>
......
......@@ -46,7 +46,6 @@ namespace JSC {
class RegisterID;
class JSScope;
class ScopeNode;
class SourceProviderCacheItem;
typedef unsigned CodeFeatures;
......@@ -1425,9 +1424,6 @@ namespace JSC {
bool functionNameIsInScope() { return m_functionNameIsInScopeToggle == FunctionNameIsInScope; }
FunctionNameIsInScopeToggle functionNameIsInScopeToggle() { return m_functionNameIsInScopeToggle; }
void setFunctionStart(int functionStart) { m_functionStart = functionStart; }
int functionStart() const { return m_functionStart; }
static const bool scopeIsFunction = true;
private:
......@@ -1438,7 +1434,6 @@ namespace JSC {
Identifier m_inferredName;
FunctionNameIsInScopeToggle m_functionNameIsInScopeToggle;
RefPtr<FunctionParameters> m_parameters;
int m_functionStart;
};
class FuncExprNode : public ExpressionNode {
......
......@@ -842,7 +842,6 @@ template <FunctionRequirements requirements, bool nameIsInContainingScope, class
failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo));
closeBracePos = cachedInfo->closeBracePos;
context.setFunctionStart(body, functionStart);
m_token = cachedInfo->closeBraceToken();
m_lexer->setOffset(m_token.m_location.endOffset);
m_lexer->setLineNumber(m_token.m_location.line);
......@@ -870,8 +869,7 @@ template <FunctionRequirements requirements, bool nameIsInContainingScope, class
newInfo = adoptPtr(new SourceProviderCacheItem(functionStart, m_token.m_location.line, closeBracePos));
functionScope->saveFunctionInfo(newInfo.get());
}
context.setFunctionStart(body, functionStart);
failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo));
matchOrFail(CLOSEBRACE);
......
......@@ -509,7 +509,7 @@ private:
ScopeStack m_scopeStack;
const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos)
const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos)
{
return m_functionCache ? m_functionCache->get(openBracePos) : 0;
}
......
......@@ -151,7 +151,6 @@ public:
ExpressionType createAssignResolve(const JSTokenLocation&, const Identifier&, ExpressionType, int, int, int) { return AssignmentExpr; }
ExpressionType createFunctionExpr(const JSTokenLocation&, const Identifier*, int, int, int, int, int, int) { return FunctionExpr; }
int createFunctionBody(const JSTokenLocation&, bool) { return 1; }
void setFunctionStart(int, int) { }
int createArguments() { return 1; }
int createArguments(int) { return 1; }
int createArgumentsList(const JSTokenLocation&, int) { return 1; }
......
......@@ -132,23 +132,7 @@ UnlinkedFunctionCodeBlock* CodeCache::generateFunctionCodeBlock(JSGlobalData& gl
UnlinkedFunctionCodeBlock* CodeCache::getFunctionCodeBlock(JSGlobalData& globalData, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)
{
if (debuggerMode == DebuggerOn || profilerMode == ProfilerOn)
return generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error);
SourceCode functionSource(source.provider(), executable->functionStartOffset(), source.endOffset(), source.firstLine());
CodeBlockKey key = makeCodeBlockKey(functionSource, kind == CodeForCall ? FunctionCallType : FunctionConstructType, executable->isInStrictContext() ? JSParseStrict : JSParseNormal);
if (const Strong<UnlinkedFunctionCodeBlock>* cacheEntry = m_cachedFunctionExecutables.find(key)) {
if (cacheEntry) {
UnlinkedFunctionCodeBlock* unlinkedCode = cacheEntry->get();
unsigned firstLine = source.firstLine() + unlinkedCode->firstLine();
executable->recordParse(unlinkedCode->codeFeatures(), unlinkedCode->hasCapturedVariables(), firstLine, firstLine + unlinkedCode->lineCount());
m_recentlyUsedFunctionCode.add(unlinkedCode, *cacheEntry);
return unlinkedCode;
}
}
UnlinkedFunctionCodeBlock* result = generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error);
m_cachedFunctionExecutables.add(key, Strong<UnlinkedFunctionCodeBlock>(globalData, result));
return result;
return generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error);
}
CodeCache::GlobalFunctionKey CodeCache::makeGlobalFunctionKey(const SourceCode& source, const String& name)
......
......@@ -113,7 +113,6 @@ public:
void clear()
{
m_cachedCodeBlocks.clear();
m_cachedFunctionExecutables.clear();
m_cachedGlobalFunctions.clear();
m_recentlyUsedFunctionCode.clear();
}
......@@ -138,7 +137,6 @@ private:
};
CacheMap<CodeBlockKey, Strong<UnlinkedCodeBlock>, kMaxCodeBlockEntries> m_cachedCodeBlocks;
CacheMap<CodeBlockKey, Strong<UnlinkedFunctionCodeBlock>, kMaxFunctionCodeBlocks> m_cachedFunctionExecutables;
CacheMap<GlobalFunctionKey, Strong<UnlinkedFunctionExecutable>, kMaxFunctionCodeBlocks> m_cachedGlobalFunctions;
CacheMap<UnlinkedFunctionCodeBlock*, Strong<UnlinkedFunctionCodeBlock>, kMaxFunctionCodeBlocks> m_recentlyUsedFunctionCode;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment