Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (136859 => 136860)
--- trunk/Source/_javascript_Core/ChangeLog 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-12-06 19:26:20 UTC (rev 136860)
@@ -1,3 +1,18 @@
+2012-12-05 Oliver Hunt <[email protected]>
+
+ 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 <[email protected]>
[CMake] Unify coding style for CMake files
Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (136859 => 136860)
--- trunk/Source/_javascript_Core/parser/ASTBuilder.h 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h 2012-12-06 19:26:20 UTC (rev 136860)
@@ -267,11 +267,6 @@
{
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)
{
Modified: trunk/Source/_javascript_Core/parser/Nodes.cpp (136859 => 136860)
--- trunk/Source/_javascript_Core/parser/Nodes.cpp 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/parser/Nodes.cpp 2012-12-06 19:26:20 UTC (rev 136860)
@@ -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>
Modified: trunk/Source/_javascript_Core/parser/Nodes.h (136859 => 136860)
--- trunk/Source/_javascript_Core/parser/Nodes.h 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/parser/Nodes.h 2012-12-06 19:26:20 UTC (rev 136860)
@@ -46,7 +46,6 @@
class RegisterID;
class JSScope;
class ScopeNode;
- class SourceProviderCacheItem;
typedef unsigned CodeFeatures;
@@ -1425,9 +1424,6 @@
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 @@
Identifier m_inferredName;
FunctionNameIsInScopeToggle m_functionNameIsInScopeToggle;
RefPtr<FunctionParameters> m_parameters;
- int m_functionStart;
};
class FuncExprNode : public ExpressionNode {
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (136859 => 136860)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2012-12-06 19:26:20 UTC (rev 136860)
@@ -842,7 +842,6 @@
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 @@
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);
Modified: trunk/Source/_javascript_Core/parser/Parser.h (136859 => 136860)
--- trunk/Source/_javascript_Core/parser/Parser.h 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/parser/Parser.h 2012-12-06 19:26:20 UTC (rev 136860)
@@ -509,7 +509,7 @@
ScopeStack m_scopeStack;
- const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos)
+ const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos)
{
return m_functionCache ? m_functionCache->get(openBracePos) : 0;
}
Modified: trunk/Source/_javascript_Core/parser/SyntaxChecker.h (136859 => 136860)
--- trunk/Source/_javascript_Core/parser/SyntaxChecker.h 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/parser/SyntaxChecker.h 2012-12-06 19:26:20 UTC (rev 136860)
@@ -151,7 +151,6 @@
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; }
Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (136859 => 136860)
--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2012-12-06 19:26:20 UTC (rev 136860)
@@ -132,23 +132,7 @@
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)
Modified: trunk/Source/_javascript_Core/runtime/CodeCache.h (136859 => 136860)
--- trunk/Source/_javascript_Core/runtime/CodeCache.h 2012-12-06 19:21:14 UTC (rev 136859)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.h 2012-12-06 19:26:20 UTC (rev 136860)
@@ -113,7 +113,6 @@
void clear()
{
m_cachedCodeBlocks.clear();
- m_cachedFunctionExecutables.clear();
m_cachedGlobalFunctions.clear();
m_recentlyUsedFunctionCode.clear();
}
@@ -138,7 +137,6 @@
};
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;
};