Changeset 132143 in webkit for trunk/Source/JavaScriptCore/interpreter/JSStack.cpp
- Timestamp:
- Oct 22, 2012, 3:09:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/JSStack.cpp
r130726 r132143 42 42 return staticMutex; 43 43 } 44 44 45 JSStack::JSStack(size_t capacity) 46 : m_end(0) 47 { 48 ASSERT(capacity && isPageAligned(capacity)); 49 50 m_reservation = PageReservation::reserve(roundUpAllocationSize(capacity * sizeof(Register), commitSize), OSAllocator::JSVMStackPages); 51 m_end = static_cast<Register*>(m_reservation.base()); 52 m_commitEnd = static_cast<Register*>(m_reservation.base()); 53 54 disableErrorStackReserve(); 55 } 56 45 57 JSStack::~JSStack() 46 58 { … … 53 65 bool JSStack::growSlowCase(Register* newEnd) 54 66 { 67 // If we have already committed enough memory to satisfy this request, 68 // just update the end pointer and return. 55 69 if (newEnd <= m_commitEnd) { 56 70 m_end = newEnd; … … 58 72 } 59 73 74 // Compute the chunk size of additional memory to commit, and see if we 75 // have it is still within our budget. If not, we'll fail to grow and 76 // return false. 60 77 long delta = roundUpAllocationSize(reinterpret_cast<char*>(newEnd) - reinterpret_cast<char*>(m_commitEnd), commitSize); 61 if (reinterpret_cast<char*>(m_commitEnd) + delta > static_cast<char*>(m_reservation.base()) + m_reservation.size())78 if (reinterpret_cast<char*>(m_commitEnd) + delta > reinterpret_cast<char*>(m_useableEnd)) 62 79 return false; 63 80 81 // Otherwise, the growth is still within our budget. Go ahead and commit 82 // it and return true. 64 83 m_reservation.commit(m_commitEnd, delta); 65 84 addToCommittedByteCount(delta); … … 105 124 } 106 125 126 void JSStack::enableErrorStackReserve() 127 { 128 m_useableEnd = reservationEnd(); 129 } 130 131 void JSStack::disableErrorStackReserve() 132 { 133 char* useableEnd = reinterpret_cast<char*>(reservationEnd()) - commitSize; 134 m_useableEnd = reinterpret_cast<Register*>(useableEnd); 135 136 // By the time we get here, we are guaranteed to be destructing the last 137 // Interpreter::ErrorHandlingMode that enabled this reserve in the first 138 // place. That means the stack space beyond m_useableEnd before we 139 // enabled the reserve was not previously in use. Hence, it is safe to 140 // shrink back to that m_useableEnd. 141 if (m_end > m_useableEnd) 142 shrink(m_useableEnd); 143 } 144 107 145 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.