Changeset 136860 in webkit


Ignore:
Timestamp:
Dec 6, 2012 11:26:20 AM (11 years ago)
Author:
oliver@apple.com
Message:

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):

Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r136790 r136860  
     12012-12-05  Oliver Hunt  <oliver@apple.com>
     2
     3        Remove harmful string->function cache
     4        https://bugs.webkit.org/show_bug.cgi?id=104193
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Remove the string->function code cache that turned out to actually
     9        be quite harmful.
     10
     11        * runtime/CodeCache.cpp:
     12        (JSC::CodeCache::getFunctionCodeBlock):
     13        * runtime/CodeCache.h:
     14        (JSC::CodeCache::clear):
     15
    1162012-12-05  Halton Huo  <halton.huo@intel.com>
    217
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r136261 r136860  
    268268        return FunctionBodyNode::create(m_globalData, location, inStrictContext);
    269269    }
    270 
    271     void setFunctionStart(FunctionBodyNode* body, int functionStart)
    272     {
    273         body->setFunctionStart(functionStart);
    274     }
    275270   
    276271    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)
  • trunk/Source/JavaScriptCore/parser/Nodes.cpp

    r136261 r136860  
    4242#include "RegExpObject.h"
    4343#include "SamplingTool.h"
    44 #include "SourceProviderCacheItem.h"
    4544#include <wtf/Assertions.h>
    4645#include <wtf/RefCountedLeakCounter.h>
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r136261 r136860  
    4747    class JSScope;
    4848    class ScopeNode;
    49     class SourceProviderCacheItem;
    5049
    5150    typedef unsigned CodeFeatures;
     
    14261425        FunctionNameIsInScopeToggle functionNameIsInScopeToggle() { return m_functionNameIsInScopeToggle; }
    14271426
    1428         void setFunctionStart(int functionStart) { m_functionStart = functionStart; }
    1429         int functionStart() const { return m_functionStart; }
    1430 
    14311427        static const bool scopeIsFunction = true;
    14321428
     
    14391435        FunctionNameIsInScopeToggle m_functionNameIsInScopeToggle;
    14401436        RefPtr<FunctionParameters> m_parameters;
    1441         int m_functionStart;
    14421437    };
    14431438
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r136261 r136860  
    843843       
    844844        closeBracePos = cachedInfo->closeBracePos;
    845         context.setFunctionStart(body, functionStart);
    846845        m_token = cachedInfo->closeBraceToken();
    847846        m_lexer->setOffset(m_token.m_location.endOffset);
     
    871870        functionScope->saveFunctionInfo(newInfo.get());
    872871    }
    873     context.setFunctionStart(body, functionStart);
    874 
     872   
    875873    failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo));
    876874    matchOrFail(CLOSEBRACE);
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r136261 r136860  
    510510    ScopeStack m_scopeStack;
    511511   
    512     const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos)
     512    const SourceProviderCacheItem* findCachedFunctionInfo(int openBracePos) 
    513513    {
    514514        return m_functionCache ? m_functionCache->get(openBracePos) : 0;
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r136261 r136860  
    152152    ExpressionType createFunctionExpr(const JSTokenLocation&, const Identifier*, int, int, int, int, int, int) { return FunctionExpr; }
    153153    int createFunctionBody(const JSTokenLocation&, bool) { return 1; }
    154     void setFunctionStart(int, int) { }
    155154    int createArguments() { return 1; }
    156155    int createArguments(int) { return 1; }
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r136261 r136860  
    133133UnlinkedFunctionCodeBlock* CodeCache::getFunctionCodeBlock(JSGlobalData& globalData, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)
    134134{
    135     if (debuggerMode == DebuggerOn || profilerMode == ProfilerOn)
    136         return generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error);
    137 
    138     SourceCode functionSource(source.provider(), executable->functionStartOffset(), source.endOffset(), source.firstLine());
    139     CodeBlockKey key = makeCodeBlockKey(functionSource, kind == CodeForCall ? FunctionCallType : FunctionConstructType, executable->isInStrictContext() ? JSParseStrict : JSParseNormal);
    140     if (const Strong<UnlinkedFunctionCodeBlock>* cacheEntry = m_cachedFunctionExecutables.find(key)) {
    141         if (cacheEntry) {
    142             UnlinkedFunctionCodeBlock* unlinkedCode = cacheEntry->get();
    143             unsigned firstLine = source.firstLine() + unlinkedCode->firstLine();
    144             executable->recordParse(unlinkedCode->codeFeatures(), unlinkedCode->hasCapturedVariables(), firstLine, firstLine + unlinkedCode->lineCount());
    145             m_recentlyUsedFunctionCode.add(unlinkedCode, *cacheEntry);
    146             return unlinkedCode;
    147         }
    148     }
    149     UnlinkedFunctionCodeBlock* result = generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error);
    150     m_cachedFunctionExecutables.add(key, Strong<UnlinkedFunctionCodeBlock>(globalData, result));
    151     return result;
     135    return generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error);
    152136}
    153137
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r136773 r136860  
    114114    {
    115115        m_cachedCodeBlocks.clear();
    116         m_cachedFunctionExecutables.clear();
    117116        m_cachedGlobalFunctions.clear();
    118117        m_recentlyUsedFunctionCode.clear();
     
    139138
    140139    CacheMap<CodeBlockKey, Strong<UnlinkedCodeBlock>, kMaxCodeBlockEntries> m_cachedCodeBlocks;
    141     CacheMap<CodeBlockKey, Strong<UnlinkedFunctionCodeBlock>, kMaxFunctionCodeBlocks> m_cachedFunctionExecutables;
    142140    CacheMap<GlobalFunctionKey, Strong<UnlinkedFunctionExecutable>, kMaxFunctionCodeBlocks> m_cachedGlobalFunctions;
    143141    CacheMap<UnlinkedFunctionCodeBlock*, Strong<UnlinkedFunctionCodeBlock>, kMaxFunctionCodeBlocks> m_recentlyUsedFunctionCode;
Note: See TracChangeset for help on using the changeset viewer.