Changeset 143348 in webkit
- Timestamp:
- Feb 19, 2013 9:48:15 AM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r143346 r143348 1 2013-02-18 Geoffrey Garen <ggaren@apple.com> 2 3 Save space on keys in the CodeCache 4 https://bugs.webkit.org/show_bug.cgi?id=110179 5 6 Reviewed by Oliver Hunt. 7 8 Share the SourceProvider's string instead of making our own copy. This 9 chops off 16MB - 32MB from the CodeCache's memory footprint when full. 10 (It's 16MB when the strings are LChar, and 32MB when they're UChar.) 11 12 * runtime/CodeCache.cpp: 13 (JSC::CodeCache::getFunctionExecutableFromGlobalCode): 14 * runtime/CodeCache.h: Removed a defunct enum value. 15 16 (JSC::SourceCodeKey::SourceCodeKey): 17 (JSC::SourceCodeKey::isHashTableDeletedValue): 18 (SourceCodeKey): 19 (JSC::SourceCodeKey::hash): 20 (JSC::SourceCodeKey::length): 21 (JSC::SourceCodeKey::isNull): 22 (JSC::SourceCodeKey::string): 23 (JSC::SourceCodeKey::operator==): Store a SourceCode instead of a String 24 so we can share our string with our SourceProvider. Cache our hash so 25 we don't have to re-decode our string just to re-hash the table. 26 1 27 2013-02-19 Zoltan Herczeg <zherczeg@webkit.org> 2 28 -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r143133 r143348 106 106 UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, ParserError& error) 107 107 { 108 SourceCodeKey key = SourceCodeKey(source, name.string(), SourceCodeKey::Function CallType, JSParseNormal);108 SourceCodeKey key = SourceCodeKey(source, name.string(), SourceCodeKey::FunctionType, JSParseNormal); 109 109 const Strong<JSCell>* result = m_sourceCode.find(key); 110 110 if (result) -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r143141 r143348 56 56 class SourceCodeKey { 57 57 public: 58 enum CodeType { EvalType, ProgramType, Function CallType, FunctionConstructType };58 enum CodeType { EvalType, ProgramType, FunctionType }; 59 59 60 60 SourceCodeKey() 61 : m_flags(0)62 61 { 63 62 } 64 63 65 64 SourceCodeKey(const SourceCode& sourceCode, const String& name, CodeType codeType, JSParserStrictness jsParserStrictness) 66 : m_source String(sourceCode.toString())65 : m_sourceCode(sourceCode) 67 66 , m_name(name) 68 67 , m_flags((codeType << 1) | jsParserStrictness) 68 , m_hash(string().impl()->hash()) 69 69 { 70 70 } 71 71 72 72 SourceCodeKey(WTF::HashTableDeletedValueType) 73 : m_ sourceString(WTF::HashTableDeletedValue)73 : m_name(WTF::HashTableDeletedValue) 74 74 { 75 75 } 76 76 77 bool isHashTableDeletedValue() const { return m_ sourceString.isHashTableDeletedValue(); }77 bool isHashTableDeletedValue() const { return m_name.isHashTableDeletedValue(); } 78 78 79 unsigned hash() const { return m_ sourceString.impl()->hash(); }79 unsigned hash() const { return m_hash; } 80 80 81 size_t length() const { return m_source String.length(); }81 size_t length() const { return m_sourceCode.length(); } 82 82 83 bool isNull() const { return m_sourceString.isNull(); } 83 bool isNull() const { return m_sourceCode.isNull(); } 84 85 // To save memory, we compute our string on demand. It's expected that source 86 // providers cache their strings to make this efficient. 87 String string() const { return m_sourceCode.toString(); } 84 88 85 89 bool operator==(const SourceCodeKey& other) const 86 90 { 87 return m_flags == other.m_flags 91 return m_hash == other.m_hash 92 && length() == other.length() 93 && m_flags == other.m_flags 88 94 && m_name == other.m_name 89 && m_sourceString == other.m_sourceString;95 && string() == other.string(); 90 96 } 91 97 92 98 private: 93 S tring m_sourceString;99 SourceCode m_sourceCode; 94 100 String m_name; 95 101 unsigned m_flags; 102 unsigned m_hash; 96 103 }; 97 104
Note: See TracChangeset
for help on using the changeset viewer.