Changeset 138675 in webkit
- Timestamp:
- Jan 2, 2013 4:25:26 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r138669 r138675 1 2013-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 1 40 2013-01-02 Filip Pizlo <fpizlo@apple.com> 2 41 -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r136860 r138675 44 44 } 45 45 46 CodeCache:: CodeBlockKey CodeCache::makeCodeBlockKey(const SourceCode& source, CodeCache::CodeType type, JSParserStrictness strictness)46 CodeCache::SourceCodeKey CodeCache::makeSourceCodeKey(const SourceCode& source, CodeCache::CodeType type, JSParserStrictness strictness) 47 47 { 48 48 return std::make_pair(source.toString(), (type << 1) | strictness); … … 64 64 UnlinkedCodeBlockType* CodeCache::getCodeBlock(JSGlobalData& globalData, ExecutableType* executable, const SourceCode& source, JSParserStrictness strictness, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error) 65 65 { 66 CodeBlockKey key = makeCodeBlockKey(source, CacheTypes<UnlinkedCodeBlockType>::codeType, strictness);66 SourceCodeKey key = makeSourceCodeKey(source, CacheTypes<UnlinkedCodeBlockType>::codeType, strictness); 67 67 bool storeInCache = false; 68 68 if (debuggerMode == DebuggerOff && profilerMode == ProfilerOff) { 69 const Strong<UnlinkedCodeBlock>* result = m_ cachedCodeBlocks.find(key);69 const Strong<UnlinkedCodeBlock>* result = m_sourceCode.find(key); 70 70 if (result) { 71 71 UnlinkedCodeBlockType* unlinkedCode = jsCast<UnlinkedCodeBlockType*>(result->get()); … … 92 92 93 93 if (storeInCache) 94 m_ cachedCodeBlocks.add(key, Strong<UnlinkedCodeBlock>(globalData, unlinkedCode));94 m_sourceCode.add(key, Strong<UnlinkedCodeBlock>(globalData, unlinkedCode)); 95 95 96 96 return unlinkedCode; … … 127 127 if (error.m_type != ParserError::ErrorNone) 128 128 return 0; 129 m_recentlyUsedFunction Code.add(result, Strong<UnlinkedFunctionCodeBlock>(globalData, result));129 m_recentlyUsedFunctions.add(result, Strong<UnlinkedFunctionCodeBlock>(globalData, result)); 130 130 return result; 131 131 } … … 136 136 } 137 137 138 CodeCache:: GlobalFunctionKey CodeCache::makeGlobalFunctionKey(const SourceCode& source, const String& name)138 CodeCache::FunctionKey CodeCache::makeFunctionKey(const SourceCode& source, const String& name) 139 139 { 140 return GlobalFunctionKey(source.toString(), name);140 return FunctionKey(source.toString(), name); 141 141 } 142 142 143 143 UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, ParserError& error) 144 144 { 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); 147 147 if (result) 148 148 return result->get(); … … 168 168 functionExecutable->m_nameValue.set(globalData, functionExecutable, jsString(&globalData, name.string())); 169 169 170 m_ cachedGlobalFunctions.add(key, Strong<UnlinkedFunctionExecutable>(globalData, functionExecutable));170 m_globalFunctions.add(key, Strong<UnlinkedFunctionExecutable>(globalData, functionExecutable)); 171 171 return functionExecutable; 172 172 } … … 174 174 void CodeCache::usedFunctionCode(JSGlobalData& globalData, UnlinkedFunctionCodeBlock* codeBlock) 175 175 { 176 m_recentlyUsedFunction Code.add(codeBlock, Strong<UnlinkedFunctionCodeBlock>(globalData, codeBlock));176 m_recentlyUsedFunctions.add(codeBlock, Strong<UnlinkedFunctionCodeBlock>(globalData, codeBlock)); 177 177 } 178 178 -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r137001 r138675 113 113 void clear() 114 114 { 115 m_ cachedCodeBlocks.clear();116 m_ cachedGlobalFunctions.clear();117 m_recentlyUsedFunction Code.clear();115 m_sourceCode.clear(); 116 m_globalFunctions.clear(); 117 m_recentlyUsedFunctions.clear(); 118 118 } 119 119 120 120 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; 123 123 124 124 private: … … 128 128 129 129 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&); 132 132 133 133 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. 143 136 }; 144 137 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; 148 141 }; 149 142
Note: See TracChangeset
for help on using the changeset viewer.