Changeset 87448 in webkit
- Timestamp:
- May 26, 2011 4:39:22 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r87445 r87448 1 2011-05-26 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Removed some interdependency between Heap and SmallStrings by simplifying 6 the SmallStrings lifetime model 7 https://bugs.webkit.org/show_bug.cgi?id=61579 8 9 SunSpider reports no change. 10 11 Using Weak<T> could accomplish this too, but we're not sure it will give 12 us the performance we need. This is a first step, and it accomplishes 13 most of the value of using Weak<T>. 14 15 * heap/Heap.cpp: 16 (JSC::Heap::destroy): 17 (JSC::Heap::markRoots): 18 (JSC::Heap::reset): Finalize small strings just like other weak handles. 19 20 * runtime/SmallStrings.cpp: 21 (JSC::finalize): 22 (JSC::SmallStrings::finalizeSmallStrings): 23 * runtime/SmallStrings.h: Make all small strings trivially weak, instead 24 of having an "all for one, one for all" memory model. 25 1 26 2011-05-26 Oliver Hunt <oliver@apple.com> 2 27 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r87434 r87448 107 107 m_markedSpace.clearMarks(); 108 108 m_handleHeap.finalizeWeakHandles(); 109 m_globalData->smallStrings.finalizeSmallStrings(); 109 110 m_markedSpace.destroy(); 110 111 … … 260 261 visitor.drain(); 261 262 262 // Mark the small strings cache as late as possible, since it will clear263 // itself if nothing else has marked it.264 // FIXME: Change the small strings cache to use Weak<T>.265 m_globalData->smallStrings.visitChildren(heapRootMarker);266 visitor.drain();267 268 263 // Weak handles must be marked last, because their owners use the set of 269 264 // opaque roots to determine reachability. … … 409 404 markRoots(); 410 405 m_handleHeap.finalizeWeakHandles(); 406 m_globalData->smallStrings.finalizeSmallStrings(); 411 407 412 408 JAVASCRIPTCORE_GC_MARKED(); -
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 -
trunk/Source/JavaScriptCore/runtime/SmallStrings.h
r86209 r87448 64 64 StringImpl* singleCharacterStringRep(unsigned char character); 65 65 66 void visitChildren(HeapRootVisitor&);66 void finalizeSmallStrings(); 67 67 void clear(); 68 68
Note: See TracChangeset
for help on using the changeset viewer.