Changeset 161036 in webkit
- Timestamp:
- Dec 23, 2013, 4:25:14 PM (11 years ago)
- Location:
- branches/jsCStack/Source/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/jsCStack/Source/JavaScriptCore/ChangeLog
r161030 r161036 1 2013-12-23 Mark Lam <mark.lam@apple.com> 2 3 CStack: Fix JSStack::grow(), shrink(), growSlowCase(), and setStackLimit(). 4 https://bugs.webkit.org/show_bug.cgi?id=126188. 5 6 Not yet reviewed. 7 8 These functions were inappropriately mixing "end" and "top" pointer idioms. 9 Specifically: 10 1. growSlowCase() was comparing a newEnd pointer against m_commitTop, and 11 using this to compute the size that the stack needs to grow. 12 2. shrink() was wrongly computing excess capacity by subtracting 13 baseOfStack() (which is at high memory) from m_commitTop (which points 14 to lower memory). Also, baseOfStack() is an "end" pointer while 15 m_commitTop is a "top" pointer. This is a mismatch. 16 17 To fix this and simplify the code a bit, I changed all of these functions 18 to take a newTopOfStack pointer instead of a newEnd pointer, and adjusted 19 their callers where needed to pass the appropropriate pointer values. 20 21 * interpreter/JSStack.cpp: 22 (JSC::JSStack::growSlowCase): 23 * interpreter/JSStack.h: 24 * interpreter/JSStackInlines.h: 25 (JSC::JSStack::popFrame): 26 (JSC::JSStack::shrink): 27 (JSC::JSStack::grow): 28 (JSC::JSStack::setStackLimit): 29 1 30 2013-12-23 Mark Lam <mark.lam@apple.com> 2 31 -
branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.cpp
r161030 r161036 78 78 } 79 79 80 bool JSStack::growSlowCase(Register* new End)80 bool JSStack::growSlowCase(Register* newTopOfStack) 81 81 { 82 82 // If we have already committed enough memory to satisfy this request, 83 83 // just update the end pointer and return. 84 if (new End>= m_commitTop) {85 setStackLimit(new End);84 if (newTopOfStack >= m_commitTop) { 85 setStackLimit(newTopOfStack); 86 86 return true; 87 87 } … … 90 90 // have it is still within our budget. If not, we'll fail to grow and 91 91 // return false. 92 long delta = roundUpAllocationSize(reinterpret_cast<char*>(m_commitTop) - reinterpret_cast<char*>(new End), commitSize);92 long delta = roundUpAllocationSize(reinterpret_cast<char*>(m_commitTop) - reinterpret_cast<char*>(newTopOfStack), commitSize); 93 93 if (reinterpret_cast<char*>(m_commitTop) - delta <= reinterpret_cast<char*>(m_useableTop)) 94 94 return false; … … 99 99 addToCommittedByteCount(delta); 100 100 m_commitTop = reinterpret_cast_ptr<Register*>(reinterpret_cast<char*>(m_commitTop) - delta); 101 setStackLimit(new End);101 setStackLimit(newTopOfStack); 102 102 return true; 103 103 } -
branches/jsCStack/Source/JavaScriptCore/interpreter/JSStack.h
r161030 r161036 161 161 #endif 162 162 163 bool grow(Register* topOfStack);164 bool growSlowCase(Register* );165 void shrink(Register* );163 bool grow(Register* newTopOfStack); 164 bool growSlowCase(Register* newTopOfStack); 165 void shrink(Register* newTopOfStack); 166 166 void releaseExcessCapacity(); 167 167 void addToCommittedByteCount(long); 168 168 169 void setStackLimit(Register* new End);169 void setStackLimit(Register* newTopOfStack); 170 170 #endif // ENABLE(LLINT_C_LOOP) 171 171 -
branches/jsCStack/Source/JavaScriptCore/interpreter/JSStackInlines.h
r161030 r161036 167 167 // are no more frames on the stack. 168 168 if (!callerFrame) 169 shrink( baseOfStack());169 shrink(highAddress()); 170 170 171 171 installTrapsAfterFrame(callerFrame); 172 172 } 173 173 174 inline void JSStack::shrink(Register* newEnd) 175 { 174 inline void JSStack::shrink(Register* newTopOfStack) 175 { 176 Register* newEnd = newTopOfStack - 1; 176 177 if (newEnd >= m_end) 177 178 return; 178 setStackLimit(new End);179 if (m_end == baseOfStack() && ( m_commitTop - baseOfStack()) >= maxExcessCapacity)179 setStackLimit(newTopOfStack); 180 if (m_end == baseOfStack() && (highAddress() - m_commitTop) >= maxExcessCapacity) 180 181 releaseExcessCapacity(); 181 182 } 182 183 183 inline bool JSStack::grow(Register* topOfStack)184 { 185 Register* newEnd = topOfStack - 1;184 inline bool JSStack::grow(Register* newTopOfStack) 185 { 186 Register* newEnd = newTopOfStack - 1; 186 187 if (newEnd >= m_end) 187 188 return true; 188 return growSlowCase(newEnd); 189 } 190 191 inline void JSStack::setStackLimit(Register* newEnd) 192 { 189 return growSlowCase(newTopOfStack); 190 } 191 192 inline void JSStack::setStackLimit(Register* newTopOfStack) 193 { 194 Register* newEnd = newTopOfStack - 1; 193 195 m_end = newEnd; 194 196 #if ENABLE(LLINT_C_LOOP) 195 m_vm.setJSStackLimit(new End + 1);197 m_vm.setJSStackLimit(newTopOfStack); 196 198 #endif 197 199 }
Note:
See TracChangeset
for help on using the changeset viewer.