Title: [138675] trunk/Source/_javascript_Core
Revision
138675
Author
gga...@apple.com
Date
2013-01-02 16:25:26 -0800 (Wed, 02 Jan 2013)

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

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (138674 => 138675)


--- trunk/Source/_javascript_Core/ChangeLog	2013-01-03 00:21:33 UTC (rev 138674)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-01-03 00:25:26 UTC (rev 138675)
@@ -1,3 +1,42 @@
+2013-01-02  Geoffrey Garen  <gga...@apple.com>
+
+        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):
+
 2013-01-02  Filip Pizlo  <fpi...@apple.com>
 
         DFG inlining machinery should be robust against the inline callee varying while the executable stays the same

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (138674 => 138675)


--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2013-01-03 00:21:33 UTC (rev 138674)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2013-01-03 00:25:26 UTC (rev 138675)
@@ -43,7 +43,7 @@
 {
 }
 
-CodeCache::CodeBlockKey CodeCache::makeCodeBlockKey(const SourceCode& source, CodeCache::CodeType type, JSParserStrictness strictness)
+CodeCache::SourceCodeKey CodeCache::makeSourceCodeKey(const SourceCode& source, CodeCache::CodeType type, JSParserStrictness strictness)
 {
     return std::make_pair(source.toString(), (type << 1) | strictness);
 }
@@ -63,10 +63,10 @@
 template <class UnlinkedCodeBlockType, class ExecutableType>
 UnlinkedCodeBlockType* CodeCache::getCodeBlock(JSGlobalData& globalData, ExecutableType* executable, const SourceCode& source, JSParserStrictness strictness, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error)
 {
-    CodeBlockKey key = makeCodeBlockKey(source, CacheTypes<UnlinkedCodeBlockType>::codeType, strictness);
+    SourceCodeKey key = makeSourceCodeKey(source, CacheTypes<UnlinkedCodeBlockType>::codeType, strictness);
     bool storeInCache = false;
     if (debuggerMode == DebuggerOff && profilerMode == ProfilerOff) {
-        const Strong<UnlinkedCodeBlock>* result = m_cachedCodeBlocks.find(key);
+        const Strong<UnlinkedCodeBlock>* result = m_sourceCode.find(key);
         if (result) {
             UnlinkedCodeBlockType* unlinkedCode = jsCast<UnlinkedCodeBlockType*>(result->get());
             unsigned firstLine = source.firstLine() + unlinkedCode->firstLine();
@@ -91,7 +91,7 @@
         return 0;
 
     if (storeInCache)
-        m_cachedCodeBlocks.add(key, Strong<UnlinkedCodeBlock>(globalData, unlinkedCode));
+        m_sourceCode.add(key, Strong<UnlinkedCodeBlock>(globalData, unlinkedCode));
 
     return unlinkedCode;
 }
@@ -126,7 +126,7 @@
     body->destroyData();
     if (error.m_type != ParserError::ErrorNone)
         return 0;
-    m_recentlyUsedFunctionCode.add(result, Strong<UnlinkedFunctionCodeBlock>(globalData, result));
+    m_recentlyUsedFunctions.add(result, Strong<UnlinkedFunctionCodeBlock>(globalData, result));
     return result;
 }
 
@@ -135,15 +135,15 @@
     return generateFunctionCodeBlock(globalData, executable, source, kind, debuggerMode, profilerMode, error);
 }
 
-CodeCache::GlobalFunctionKey CodeCache::makeGlobalFunctionKey(const SourceCode& source, const String& name)
+CodeCache::FunctionKey CodeCache::makeFunctionKey(const SourceCode& source, const String& name)
 {
-    return GlobalFunctionKey(source.toString(), name);
+    return FunctionKey(source.toString(), name);
 }
 
 UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, ParserError& error)
 {
-    GlobalFunctionKey key = makeGlobalFunctionKey(source, name.string());
-    const Strong<UnlinkedFunctionExecutable>* result = m_cachedGlobalFunctions.find(key);
+    FunctionKey key = makeFunctionKey(source, name.string());
+    const Strong<UnlinkedFunctionExecutable>* result = m_globalFunctions.find(key);
     if (result)
         return result->get();
 
@@ -167,13 +167,13 @@
     UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&globalData, source, body);
     functionExecutable->m_nameValue.set(globalData, functionExecutable, jsString(&globalData, name.string()));
 
-    m_cachedGlobalFunctions.add(key, Strong<UnlinkedFunctionExecutable>(globalData, functionExecutable));
+    m_globalFunctions.add(key, Strong<UnlinkedFunctionExecutable>(globalData, functionExecutable));
     return functionExecutable;
 }
 
 void CodeCache::usedFunctionCode(JSGlobalData& globalData, UnlinkedFunctionCodeBlock* codeBlock)
 {
-    m_recentlyUsedFunctionCode.add(codeBlock, Strong<UnlinkedFunctionCodeBlock>(globalData, codeBlock));
+    m_recentlyUsedFunctions.add(codeBlock, Strong<UnlinkedFunctionCodeBlock>(globalData, codeBlock));
 }
 
 }

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.h (138674 => 138675)


--- trunk/Source/_javascript_Core/runtime/CodeCache.h	2013-01-03 00:21:33 UTC (rev 138674)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.h	2013-01-03 00:25:26 UTC (rev 138675)
@@ -112,14 +112,14 @@
 
     void clear()
     {
-        m_cachedCodeBlocks.clear();
-        m_cachedGlobalFunctions.clear();
-        m_recentlyUsedFunctionCode.clear();
+        m_sourceCode.clear();
+        m_globalFunctions.clear();
+        m_recentlyUsedFunctions.clear();
     }
 
     enum CodeType { EvalType, ProgramType, FunctionCallType, FunctionConstructType };
-    typedef std::pair<String, unsigned> CodeBlockKey;
-    typedef std::pair<String, String> GlobalFunctionKey;
+    typedef std::pair<String, unsigned> SourceCodeKey;
+    typedef std::pair<String, String> FunctionKey;
 
 private:
     CodeCache();
@@ -127,24 +127,17 @@
     UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(JSGlobalData&, UnlinkedFunctionExecutable*, const SourceCode&, CodeSpecializationKind, DebuggerMode, ProfilerMode, ParserError&);
 
     template <class UnlinkedCodeBlockType, class ExecutableType> inline UnlinkedCodeBlockType* getCodeBlock(JSGlobalData&, ExecutableType*, const SourceCode&, JSParserStrictness, DebuggerMode, ProfilerMode, ParserError&);
-    CodeBlockKey makeCodeBlockKey(const SourceCode&, CodeType, JSParserStrictness);
-    GlobalFunctionKey makeGlobalFunctionKey(const SourceCode&, const String&);
+    SourceCodeKey makeSourceCodeKey(const SourceCode&, CodeType, JSParserStrictness);
+    FunctionKey makeFunctionKey(const SourceCode&, const String&);
 
     enum {
-        kMaxRootCodeBlockEntries = 1024,
-        kMaxGlobalFunctionEntries = 1024,
-        // Sampling content on a number of sites indicates that
-        // on average there are 6-7 functions used per root codeblock.
-        // So we'll allow an average of 8 to give some leeway for increasing
-        // page complexity over time. Note that is simply a probabalistic
-        // measure and does not result in a hard limit of cache entries
-        // in each code block.
-        kMaxFunctionCodeBlocks = kMaxRootCodeBlockEntries * 8
+        MaxRootEntries = 1024, // Top-level code such as <script>, eval(), JSEvaluateScript(), etc.
+        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.
     };
 
-    CacheMap<CodeBlockKey, Strong<UnlinkedCodeBlock>, kMaxRootCodeBlockEntries> m_cachedCodeBlocks;
-    CacheMap<GlobalFunctionKey, Strong<UnlinkedFunctionExecutable>, kMaxFunctionCodeBlocks> m_cachedGlobalFunctions;
-    CacheMap<UnlinkedFunctionCodeBlock*, Strong<UnlinkedFunctionCodeBlock>, kMaxFunctionCodeBlocks> m_recentlyUsedFunctionCode;
+    CacheMap<SourceCodeKey, Strong<UnlinkedCodeBlock>, MaxRootEntries> m_sourceCode;
+    CacheMap<FunctionKey, Strong<UnlinkedFunctionExecutable>, MaxRootEntries> m_globalFunctions;
+    CacheMap<UnlinkedFunctionCodeBlock*, Strong<UnlinkedFunctionCodeBlock>, MaxChildFunctionEntries> m_recentlyUsedFunctions;
 };
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to