Changeset 81262 in webkit
- Timestamp:
- Mar 16, 2011 11:35:49 AM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r81261 r81262 1 2011-03-16 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Some conservative root gathering cleanup 6 https://bugs.webkit.org/show_bug.cgi?id=56447 7 8 SunSpider says 0.5% - 1.8% faster. 9 10 * interpreter/RegisterFile.cpp: 11 (JSC::RegisterFile::gatherConservativeRoots): 12 * interpreter/RegisterFile.h: New helper function for doing the 13 conservative gathering of the register file. It's still conservative, 14 since the register file may contain uninitialized values, but it's 15 moving-safe, because it only visits values tagged as pointers, so there's 16 no risk of mistaking an integer for a pointer and accidentally changing it. 17 18 * runtime/ConservativeSet.cpp: 19 (JSC::ConservativeRoots::add): 20 * runtime/ConservativeSet.h: Added a single-value add function, used above. 21 22 * runtime/Heap.cpp: 23 (JSC::Heap::markRoots): Separated machine stack conservative roots from 24 register file conservative roots because machine stack roots must be 25 pinned, but register file roots need not be pinned. 26 27 Adopted new interface for passing the current stack extent to the machine 28 stack root gathering routine. This allows us to exclude marking-related 29 data structures on the stack, and thus avoid double-marking the set of 30 machine roots. 31 32 * runtime/MachineStackMarker.cpp: 33 (JSC::MachineThreads::gatherFromCurrentThread): 34 (JSC::MachineThreads::gatherConservativeRoots): 35 * runtime/MachineStackMarker.h: Added new interface, described above. 36 37 * runtime/MarkedBlock.h: 38 (JSC::MarkedBlock::firstAtom): 39 * wtf/StdLibExtras.h: 40 (WTF::roundUpToMultipleOf): Moved roundUpToMultipleOf so it could be used 41 by MachineStacks. 42 1 43 2011-03-16 Geoffrey Garen <ggaren@apple.com> 2 44 -
trunk/Source/JavaScriptCore/interpreter/RegisterFile.cpp
r79601 r81262 30 30 #include "RegisterFile.h" 31 31 32 #include "ConservativeSet.h" 32 33 #include "Interpreter.h" 33 34 #include "JSGlobalData.h" … … 50 51 addToCommittedByteCount(-(reinterpret_cast<intptr_t>(m_commitEnd) - reinterpret_cast<intptr_t>(base))); 51 52 m_reservation.deallocate(); 53 } 54 55 void RegisterFile::gatherConservativeRoots(ConservativeRoots& conservativeRoots) 56 { 57 for (Register* it = start(); it != end(); ++it) { 58 JSValue v = it->jsValue(); 59 if (!v.isCell()) 60 continue; 61 conservativeRoots.add(v.asCell()); 62 } 52 63 } 53 64 -
trunk/Source/JavaScriptCore/interpreter/RegisterFile.h
r80969 r81262 114 114 RegisterFile(JSGlobalData&, size_t capacity = defaultCapacity, size_t maxGlobals = defaultMaxGlobals); 115 115 ~RegisterFile(); 116 117 void gatherConservativeRoots(ConservativeRoots&); 116 118 117 119 Register* start() const { return m_start; } -
trunk/Source/JavaScriptCore/runtime/ConservativeSet.cpp
r80995 r81262 27 27 #include "ConservativeSet.h" 28 28 29 #include "Heap.h"30 31 29 namespace JSC { 32 30 … … 54 52 ASSERT(isPointerAligned(end)); 55 53 56 for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it) { 57 if (!m_heap->contains(*it)) 58 continue; 59 60 if (m_size == m_capacity) 61 grow(); 62 63 m_roots[m_size++] = reinterpret_cast<JSCell*>(*it); 64 } 54 for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it) 55 add(*it); 65 56 } 66 57 -
trunk/Source/JavaScriptCore/runtime/ConservativeSet.h
r80995 r81262 27 27 #define ConservativeRoots_h 28 28 29 #include "Heap.h" 29 30 #include <wtf/OSAllocator.h> 30 31 #include <wtf/Vector.h> … … 42 43 ~ConservativeRoots(); 43 44 45 void add(void*); 44 46 void add(void* begin, void* end); 45 47 … … 74 76 } 75 77 78 inline void ConservativeRoots::add(void* p) 79 { 80 if (!m_heap->contains(p)) 81 return; 82 83 if (m_size == m_capacity) 84 grow(); 85 86 m_roots[m_size++] = reinterpret_cast<JSCell*>(p); 87 } 88 76 89 inline size_t ConservativeRoots::size() 77 90 { -
trunk/Source/JavaScriptCore/runtime/Heap.cpp
r81196 r81262 200 200 #endif 201 201 202 void* dummy; 203 202 204 ASSERT(m_operationInProgress == NoOperation); 203 205 if (m_operationInProgress != NoOperation) … … 206 208 m_operationInProgress = Collection; 207 209 208 // We gather the conservative set before clearing mark bits, because 210 MarkStack& markStack = m_markStack; 211 HeapRootMarker heapRootMarker(markStack); 212 213 // We gather conservative roots before clearing mark bits because 209 214 // conservative gathering uses the mark bits from our last mark pass to 210 215 // determine whether a reference is valid. 211 ConservativeRoots conservativeRoots(this); 212 m_machineThreads.gatherConservativeRoots(conservativeRoots); 213 conservativeRoots.add(registerFile().start(), registerFile().end()); 216 ConservativeRoots machineThreadRoots(this); 217 m_machineThreads.gatherConservativeRoots(machineThreadRoots, &dummy); 218 219 ConservativeRoots registerFileRoots(this); 220 registerFile().gatherConservativeRoots(registerFileRoots); 214 221 215 222 m_markedSpace.clearMarks(); 216 223 217 MarkStack& markStack = m_markStack;218 HeapRootMarker heapRootMarker(markStack);219 220 markStack.append( conservativeRoots);224 markStack.append(machineThreadRoots); 225 markStack.drain(); 226 227 markStack.append(registerFileRoots); 221 228 markStack.drain(); 222 229 -
trunk/Source/JavaScriptCore/runtime/MachineStackMarker.cpp
r80995 r81262 29 29 #include <setjmp.h> 30 30 #include <stdlib.h> 31 #include <wtf/StdLibExtras.h> 31 32 32 33 #if USE(PTHREAD_BASED_QT) && !defined(WTF_USE_PTHREADS) … … 84 85 85 86 #endif 87 88 using namespace WTF; 86 89 87 90 namespace JSC { … … 245 248 #endif 246 249 247 void NEVER_INLINE MachineThreads::gatherFromCurrentThreadInternal(ConservativeRoots& conservativeRoots)248 {249 void* begin = m_heap->globalData()->stack().current();250 void* end = m_heap->globalData()->stack().origin();251 swapIfBackwards(begin, end);252 conservativeRoots.add(begin, end);253 }254 255 250 #if COMPILER(GCC) 256 251 #define REGISTER_BUFFER_ALIGNMENT __attribute__ ((aligned (sizeof(void*)))) … … 259 254 #endif 260 255 261 void MachineThreads::gatherFromCurrentThread(ConservativeRoots& conservativeRoots )256 void MachineThreads::gatherFromCurrentThread(ConservativeRoots& conservativeRoots, void* stackCurrent) 262 257 { 263 258 // setjmp forces volatile registers onto the stack … … 272 267 #endif 273 268 274 gatherFromCurrentThreadInternal(conservativeRoots); 269 void* registersBegin = ®isters; 270 void* registersEnd = reinterpret_cast<void*>(roundUpToMultipleOf<sizeof(void*)>(reinterpret_cast<uintptr_t>(®isters + 1))); 271 swapIfBackwards(registersBegin, registersEnd); 272 conservativeRoots.add(registersBegin, registersEnd); 273 274 void* stackBegin = stackCurrent; 275 void* stackEnd = m_heap->globalData()->stack().origin(); 276 swapIfBackwards(stackBegin, stackEnd); 277 conservativeRoots.add(stackBegin, stackEnd); 275 278 } 276 279 … … 457 460 #endif 458 461 459 void MachineThreads::gatherConservativeRoots(ConservativeRoots& conservativeRoots )460 { 461 gatherFromCurrentThread(conservativeRoots );462 void MachineThreads::gatherConservativeRoots(ConservativeRoots& conservativeRoots, void* stackCurrent) 463 { 464 gatherFromCurrentThread(conservativeRoots, stackCurrent); 462 465 463 466 #if ENABLE(JSC_MULTIPLE_THREADS) -
trunk/Source/JavaScriptCore/runtime/MachineStackMarker.h
r80995 r81262 41 41 ~MachineThreads(); 42 42 43 void gatherConservativeRoots(ConservativeRoots& );43 void gatherConservativeRoots(ConservativeRoots&, void* stackCurrent); 44 44 45 45 #if ENABLE(JSC_MULTIPLE_THREADS) … … 49 49 50 50 private: 51 void gatherFromCurrentThread(ConservativeRoots&); 52 void gatherFromCurrentThreadInternal(ConservativeRoots&); 51 void gatherFromCurrentThread(ConservativeRoots&, void* stackCurrent); 53 52 54 53 #if ENABLE(JSC_MULTIPLE_THREADS) -
trunk/Source/JavaScriptCore/runtime/MarkStack.cpp
r81261 r81262 27 27 #include "MarkStack.h" 28 28 29 #include "ConservativeSet.h" 29 30 #include "Heap.h" 30 31 #include "JSArray.h" 31 32 #include "JSCell.h" 33 #include "JSObject.h" 34 #include "ScopeChain.h" 32 35 #include "Structure.h" 33 36 … … 41 44 m_values.shrinkAllocation(s_pageSize); 42 45 m_markSets.shrinkAllocation(s_pageSize); 46 } 47 48 void MarkStack::append(ConservativeRoots& conservativeRoots) 49 { 50 JSCell** roots = conservativeRoots.roots(); 51 size_t size = conservativeRoots.size(); 52 for (size_t i = 0; i < size; ++i) 53 internalAppend(roots[i]); 43 54 } 44 55 -
trunk/Source/JavaScriptCore/runtime/MarkStack.h
r81261 r81262 27 27 #define MarkStack_h 28 28 29 #include "ConservativeSet.h"30 29 #include "JSValue.h" 31 30 #include "Register.h" … … 37 36 namespace JSC { 38 37 38 class ConservativeRoots; 39 39 class JSGlobalData; 40 40 class Register; … … 80 80 } 81 81 82 void append(ConservativeRoots& conservativeRoots) 83 { 84 JSCell** roots = conservativeRoots.roots(); 85 size_t size = conservativeRoots.size(); 86 for (size_t i = 0; i < size; ++i) 87 internalAppend(roots[i]); 88 } 82 void append(ConservativeRoots&); 89 83 90 84 void drain(); -
trunk/Source/JavaScriptCore/runtime/MarkedBlock.h
r80052 r81262 25 25 #include <wtf/Bitmap.h> 26 26 #include <wtf/PageAllocationAligned.h> 27 #include <wtf/StdLibExtras.h> 27 28 28 29 namespace JSC { … … 35 36 36 37 static const size_t KB = 1024; 37 38 // Efficient implementation that takes advantage of powers of two.39 template<size_t divisor> inline size_t roundUpToMultipleOf(size_t x)40 {41 COMPILE_ASSERT(divisor && !(divisor & (divisor - 1)), divisor_is_a_power_of_two);42 43 size_t remainderMask = divisor - 1;44 return (x + remainderMask) & ~remainderMask;45 }46 38 47 39 class MarkedBlock { … … 110 102 inline size_t MarkedBlock::firstAtom() 111 103 { 112 return roundUpToMultipleOf<atomSize>(sizeof(MarkedBlock)) / atomSize;104 return WTF::roundUpToMultipleOf<atomSize>(sizeof(MarkedBlock)) / atomSize; 113 105 } 114 106 -
trunk/Source/JavaScriptCore/wtf/StdLibExtras.h
r72289 r81262 115 115 #define WTF_ARRAY_LENGTH(array) sizeof(::WTF::ArrayLengthHelperFunction(array)) 116 116 117 // Efficient implementation that takes advantage of powers of two. 118 template<size_t divisor> inline size_t roundUpToMultipleOf(size_t x) 119 { 120 COMPILE_ASSERT(divisor && !(divisor & (divisor - 1)), divisor_is_a_power_of_two); 121 122 size_t remainderMask = divisor - 1; 123 return (x + remainderMask) & ~remainderMask; 124 } 125 117 126 } // namespace WTF 118 127
Note: See TracChangeset
for help on using the changeset viewer.