diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 4ea8eb95019b0028a7d5f095e1cf59fc767213fa..e1e829bef5bfdd4205728ea2b634e117b463f73e 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,18 @@ +2012-12-05 Oliver Hunt + + 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 [CMake] Unify coding style for CMake files diff --git a/Source/JavaScriptCore/parser/ASTBuilder.h b/Source/JavaScriptCore/parser/ASTBuilder.h index 27b7c2c5d6841e206f71f0043180c5bcdeade20b..6e7334f97ac01a5796bed07e828e2f4cf1977062 100644 --- a/Source/JavaScriptCore/parser/ASTBuilder.h +++ b/Source/JavaScriptCore/parser/ASTBuilder.h @@ -267,11 +267,6 @@ public: { return FunctionBodyNode::create(m_globalData, location, inStrictContext); } - - void setFunctionStart(FunctionBodyNode* body, int functionStart) - { - body->setFunctionStart(functionStart); - } template PropertyNode* createGetterOrSetterProperty(const JSTokenLocation& location, PropertyNode::Type type, const Identifier* name, ParameterNode* params, FunctionBodyNode* body, int openBracePos, int closeBracePos, int bodyStartLine, int bodyEndLine) { diff --git a/Source/JavaScriptCore/parser/Nodes.cpp b/Source/JavaScriptCore/parser/Nodes.cpp index 0b122ed1e84db5d6385eb57e789921f0ea443167..03ee8ee1249494c2d17d382c01e10aae58ed03f4 100644 --- a/Source/JavaScriptCore/parser/Nodes.cpp +++ b/Source/JavaScriptCore/parser/Nodes.cpp @@ -41,7 +41,6 @@ #include "PropertyNameArray.h" #include "RegExpObject.h" #include "SamplingTool.h" -#include "SourceProviderCacheItem.h" #include #include #include diff --git a/Source/JavaScriptCore/parser/Nodes.h b/Source/JavaScriptCore/parser/Nodes.h index 96d8824804997d4f6877bbae62add7f44cce5f88..509d36d1ae36c27ffaebd840d9b439cf36363ce6 100644 --- a/Source/JavaScriptCore/parser/Nodes.h +++ b/Source/JavaScriptCore/parser/Nodes.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 m_parameters; - int m_functionStart; }; class FuncExprNode : public ExpressionNode { diff --git a/Source/JavaScriptCore/parser/Parser.cpp b/Source/JavaScriptCore/parser/Parser.cpp index 72b4900c6f1e8dda0659b919b83f5ac703252fe4..cf3cb4e4ff5c1c3c935273bc5062055a31112eac 100644 --- a/Source/JavaScriptCore/parser/Parser.cpp +++ b/Source/JavaScriptCore/parser/Parser.cpp @@ -842,7 +842,6 @@ template 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 saveFunctionInfo(newInfo.get()); } - context.setFunctionStart(body, functionStart); - + failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo)); matchOrFail(CLOSEBRACE); diff --git a/Source/JavaScriptCore/parser/Parser.h b/Source/JavaScriptCore/parser/Parser.h index 646c6a720ff0dcc698de6aa9815ebe6f216af4ed..615d09eb75d83a79b1baa095db8a2982bec654fb 100644 --- a/Source/JavaScriptCore/parser/Parser.h +++ b/Source/JavaScriptCore/parser/Parser.h @@ -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; } diff --git a/Source/JavaScriptCore/parser/SyntaxChecker.h b/Source/JavaScriptCore/parser/SyntaxChecker.h index 03caf5f646de3f72547f6760d13b3be92b43d3d5..0e6889752251c580d7d14daf809870679b9404bb 100644 --- a/Source/JavaScriptCore/parser/SyntaxChecker.h +++ b/Source/JavaScriptCore/parser/SyntaxChecker.h @@ -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; } diff --git a/Source/JavaScriptCore/runtime/CodeCache.cpp b/Source/JavaScriptCore/runtime/CodeCache.cpp index 109ec1cfd563ed4557c19d9a49b5f94bcadc5857..d3d3e3c04c8027fea4d3798fd5b9cc8c77e6395b 100644 --- a/Source/JavaScriptCore/runtime/CodeCache.cpp +++ b/Source/JavaScriptCore/runtime/CodeCache.cpp @@ -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* 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(globalData, result)); - return result; + return generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error); } CodeCache::GlobalFunctionKey CodeCache::makeGlobalFunctionKey(const SourceCode& source, const String& name) diff --git a/Source/JavaScriptCore/runtime/CodeCache.h b/Source/JavaScriptCore/runtime/CodeCache.h index a1f3855b1a2b395ac085a78f187bf49786ba64f5..1a77da828296583803e810f7621f87d4c17fca23 100644 --- a/Source/JavaScriptCore/runtime/CodeCache.h +++ b/Source/JavaScriptCore/runtime/CodeCache.h @@ -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, kMaxCodeBlockEntries> m_cachedCodeBlocks; - CacheMap, kMaxFunctionCodeBlocks> m_cachedFunctionExecutables; CacheMap, kMaxFunctionCodeBlocks> m_cachedGlobalFunctions; CacheMap, kMaxFunctionCodeBlocks> m_recentlyUsedFunctionCode; };