Changeset 138675 in webkit


Ignore:
Timestamp:
Jan 2, 2013 4:25:26 PM (11 years ago)
Author:
ggaren@apple.com
Message:

Some renaming in the CodeCache
https://bugs.webkit.org/show_bug.cgi?id=105966

Reviewed by Gavin Barraclough.

CodeBlockKey => SourceCodeKey because the key is not a CodeBlock.

m_recentlyUsedFunctionCode => m_recentlyUsedFunctions to match other names.

GlobalFunctionKey => FunctionKey because the key is not unique to globalness.

m_cachedGlobalFunctions => m_globalFunctions because "cached" is redundant
for data members in an object called "CodeCache".

kMaxRootCodeBlockEntries => kMaxRootEntries because there are no non-CodeBlock
entries in a CodeBlock cache.

kMaxFunctionCodeBlocks => kMaxChildFunctionEntries to clarify that this
number models a parent-child relationship.

Also removed the initial "k" from enum constants. That's an interesting
style for calling out constants, but it's not the WebKit style.

Finally, a behavior change: Use MaxRootEntries for the limit on global
functions, and not MaxChildFunctionEntries. Previously, there was an
unused constant that seemed to have been intended for this purpose.

  • runtime/CodeCache.cpp:

(JSC::CodeCache::makeSourceCodeKey):
(JSC::CodeCache::getCodeBlock):
(JSC::CodeCache::generateFunctionCodeBlock):
(JSC::CodeCache::makeFunctionKey):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):
(JSC::CodeCache::usedFunctionCode):

  • runtime/CodeCache.h:

(JSC::CodeCache::clear):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r138669 r138675  
     12013-01-02  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Some renaming in the CodeCache
     4        https://bugs.webkit.org/show_bug.cgi?id=105966
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        CodeBlockKey => SourceCodeKey because the key is not a CodeBlock.
     9
     10        m_recentlyUsedFunctionCode => m_recentlyUsedFunctions to match other names.
     11
     12        GlobalFunctionKey => FunctionKey because the key is not unique to globalness.
     13
     14        m_cachedGlobalFunctions => m_globalFunctions because "cached" is redundant
     15        for data members in an object called "CodeCache".
     16
     17        kMaxRootCodeBlockEntries => kMaxRootEntries because there are no non-CodeBlock
     18        entries in a CodeBlock cache.
     19
     20        kMaxFunctionCodeBlocks => kMaxChildFunctionEntries to clarify that this
     21        number models a parent-child relationship.
     22
     23        Also removed the initial "k" from enum constants. That's an interesting
     24        style for calling out constants, but it's not the WebKit style.
     25
     26        Finally, a behavior change: Use MaxRootEntries for the limit on global
     27        functions, and not MaxChildFunctionEntries. Previously, there was an
     28        unused constant that seemed to have been intended for this purpose.
     29
     30        * runtime/CodeCache.cpp:
     31        (JSC::CodeCache::makeSourceCodeKey):
     32        (JSC::CodeCache::getCodeBlock):
     33        (JSC::CodeCache::generateFunctionCodeBlock):
     34        (JSC::CodeCache::makeFunctionKey):
     35        (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
     36        (JSC::CodeCache::usedFunctionCode):
     37        * runtime/CodeCache.h:
     38        (JSC::CodeCache::clear):
     39
    1402013-01-02  Filip Pizlo  <fpizlo@apple.com>
    241
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r136860 r138675  
    4444}
    4545
    46 CodeCache::CodeBlockKey CodeCache::makeCodeBlockKey(const SourceCode& source, CodeCache::CodeType type, JSParserStrictness strictness)
     46CodeCache::SourceCodeKey CodeCache::makeSourceCodeKey(const SourceCode& source, CodeCache::CodeType type, JSParserStrictness strictness)
    4747{
    4848    return std::make_pair(source.toString(), (type << 1) | strictness);
     
    6464UnlinkedCodeBlockType* CodeCache::getCodeBlock(JSGlobalData& globalData, ExecutableType* executable, const SourceCode& source, JSParserStrictness strictness, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)
    6565{
    66     CodeBlockKey key = makeCodeBlockKey(source, CacheTypes<UnlinkedCodeBlockType>::codeType, strictness);
     66    SourceCodeKey key = makeSourceCodeKey(source, CacheTypes<UnlinkedCodeBlockType>::codeType, strictness);
    6767    bool storeInCache = false;
    6868    if (debuggerMode == DebuggerOff && profilerMode == ProfilerOff) {
    69         const Strong<UnlinkedCodeBlock>* result = m_cachedCodeBlocks.find(key);
     69        const Strong<UnlinkedCodeBlock>* result = m_sourceCode.find(key);
    7070        if (result) {
    7171            UnlinkedCodeBlockType* unlinkedCode = jsCast<UnlinkedCodeBlockType*>(result->get());
     
    9292
    9393    if (storeInCache)
    94         m_cachedCodeBlocks.add(key, Strong<UnlinkedCodeBlock>(globalData, unlinkedCode));
     94        m_sourceCode.add(key, Strong<UnlinkedCodeBlock>(globalData, unlinkedCode));
    9595
    9696    return unlinkedCode;
     
    127127    if (error.m_type != ParserError::ErrorNone)
    128128        return 0;
    129     m_recentlyUsedFunctionCode.add(result, Strong<UnlinkedFunctionCodeBlock>(globalData, result));
     129    m_recentlyUsedFunctions.add(result, Strong<UnlinkedFunctionCodeBlock>(globalData, result));
    130130    return result;
    131131}
     
    136136}
    137137
    138 CodeCache::GlobalFunctionKey CodeCache::makeGlobalFunctionKey(const SourceCode& source, const String& name)
     138CodeCache::FunctionKey CodeCache::makeFunctionKey(const SourceCode& source, const String& name)
    139139{
    140     return GlobalFunctionKey(source.toString(), name);
     140    return FunctionKey(source.toString(), name);
    141141}
    142142
    143143UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, ParserError& error)
    144144{
    145     GlobalFunctionKey key = makeGlobalFunctionKey(source, name.string());
    146     const Strong<UnlinkedFunctionExecutable>* result = m_cachedGlobalFunctions.find(key);
     145    FunctionKey key = makeFunctionKey(source, name.string());
     146    const Strong<UnlinkedFunctionExecutable>* result = m_globalFunctions.find(key);
    147147    if (result)
    148148        return result->get();
     
    168168    functionExecutable->m_nameValue.set(globalData, functionExecutable, jsString(&globalData, name.string()));
    169169
    170     m_cachedGlobalFunctions.add(key, Strong<UnlinkedFunctionExecutable>(globalData, functionExecutable));
     170    m_globalFunctions.add(key, Strong<UnlinkedFunctionExecutable>(globalData, functionExecutable));
    171171    return functionExecutable;
    172172}
     
    174174void CodeCache::usedFunctionCode(JSGlobalData& globalData, UnlinkedFunctionCodeBlock* codeBlock)
    175175{
    176     m_recentlyUsedFunctionCode.add(codeBlock, Strong<UnlinkedFunctionCodeBlock>(globalData, codeBlock));
     176    m_recentlyUsedFunctions.add(codeBlock, Strong<UnlinkedFunctionCodeBlock>(globalData, codeBlock));
    177177}
    178178
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r137001 r138675  
    113113    void clear()
    114114    {
    115         m_cachedCodeBlocks.clear();
    116         m_cachedGlobalFunctions.clear();
    117         m_recentlyUsedFunctionCode.clear();
     115        m_sourceCode.clear();
     116        m_globalFunctions.clear();
     117        m_recentlyUsedFunctions.clear();
    118118    }
    119119
    120120    enum CodeType { EvalType, ProgramType, FunctionCallType, FunctionConstructType };
    121     typedef std::pair<String, unsigned> CodeBlockKey;
    122     typedef std::pair<String, String> GlobalFunctionKey;
     121    typedef std::pair<String, unsigned> SourceCodeKey;
     122    typedef std::pair<String, String> FunctionKey;
    123123
    124124private:
     
    128128
    129129    template <class UnlinkedCodeBlockType, class ExecutableType> inline UnlinkedCodeBlockType* getCodeBlock(JSGlobalData&, ExecutableType*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&);
    130     CodeBlockKey makeCodeBlockKey(const SourceCode&, CodeType, JSParserStrictness);
    131     GlobalFunctionKey makeGlobalFunctionKey(const SourceCode&, const String&);
     130    SourceCodeKey makeSourceCodeKey(const SourceCode&, CodeType, JSParserStrictness);
     131    FunctionKey makeFunctionKey(const SourceCode&, const String&);
    132132
    133133    enum {
    134         kMaxRootCodeBlockEntries = 1024,
    135         kMaxGlobalFunctionEntries = 1024,
    136         // Sampling content on a number of sites indicates that
    137         // on average there are 6-7 functions used per root codeblock.
    138         // So we'll allow an average of 8 to give some leeway for increasing
    139         // page complexity over time. Note that is simply a probabalistic
    140         // measure and does not result in a hard limit of cache entries
    141         // in each code block.
    142         kMaxFunctionCodeBlocks = kMaxRootCodeBlockEntries * 8
     134        MaxRootEntries = 1024, // Top-level code such as <script>, eval(), JSEvaluateScript(), etc.
     135        MaxChildFunctionEntries = MaxRootEntries * 8 // Sampling shows that each root holds about 6 functions. 8 is enough to usually cache all the child functions for each top-level entry.
    143136    };
    144137
    145     CacheMap<CodeBlockKey, Strong<UnlinkedCodeBlock>, kMaxRootCodeBlockEntries> m_cachedCodeBlocks;
    146     CacheMap<GlobalFunctionKey, Strong<UnlinkedFunctionExecutable>, kMaxFunctionCodeBlocks> m_cachedGlobalFunctions;
    147     CacheMap<UnlinkedFunctionCodeBlock*, Strong<UnlinkedFunctionCodeBlock>, kMaxFunctionCodeBlocks> m_recentlyUsedFunctionCode;
     138    CacheMap<SourceCodeKey, Strong<UnlinkedCodeBlock>, MaxRootEntries> m_sourceCode;
     139    CacheMap<FunctionKey, Strong<UnlinkedFunctionExecutable>, MaxRootEntries> m_globalFunctions;
     140    CacheMap<UnlinkedFunctionCodeBlock*, Strong<UnlinkedFunctionCodeBlock>, MaxChildFunctionEntries> m_recentlyUsedFunctions;
    148141};
    149142
Note: See TracChangeset for help on using the changeset viewer.