Changeset 87448 in webkit for trunk/Source/JavaScriptCore/runtime/SmallStrings.cpp
- Timestamp:
- May 26, 2011, 4:39:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/SmallStrings.cpp
r87230 r87448 35 35 namespace JSC { 36 36 37 static inline bool isMarked(JSCell*string)37 static inline void finalize(JSString*& string) 38 38 { 39 return string && Heap::isMarked(string); 39 if (!string || Heap::isMarked(string)) 40 return; 41 string = 0; 40 42 } 41 43 … … 76 78 } 77 79 78 void SmallStrings:: visitChildren(HeapRootVisitor& heapRootMarker)80 void SmallStrings::finalizeSmallStrings() 79 81 { 80 /* 81 Our hypothesis is that small strings are very common. So, we cache them 82 to avoid GC churn. However, in cases where this hypothesis turns out to 83 be false -- including the degenerate case where all JavaScript execution 84 has terminated -- we don't want to waste memory. 85 86 To test our hypothesis, we check if any small string has been marked. If 87 so, it's probably reasonable to mark the rest. If not, we clear the cache. 88 */ 89 90 bool isAnyStringMarked = isMarked(m_emptyString); 91 for (unsigned i = 0; i < singleCharacterStringCount && !isAnyStringMarked; ++i) 92 isAnyStringMarked = isMarked(m_singleCharacterStrings[i]); 93 94 if (!isAnyStringMarked) { 95 clear(); 96 return; 97 } 98 99 if (m_emptyString) 100 heapRootMarker.mark(&m_emptyString); 101 for (unsigned i = 0; i < singleCharacterStringCount; ++i) { 102 if (m_singleCharacterStrings[i]) 103 heapRootMarker.mark(&m_singleCharacterStrings[i]); 104 } 82 finalize(m_emptyString); 83 for (unsigned i = 0; i < singleCharacterStringCount; ++i) 84 finalize(m_singleCharacterStrings[i]); 105 85 } 106 86
Note:
See TracChangeset
for help on using the changeset viewer.