Changeset 75180 in webkit
- Timestamp:
- Jan 6, 2011 12:39:55 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r75141 r75180 1 2011-01-06 Patrick Gansterer <paroga@webkit.org> 2 3 Reviewed by Gavin Barraclough. 4 5 [WINCE] Determine stack extent 6 https://bugs.webkit.org/show_bug.cgi?id=26276 7 8 Scan the stack for writeable pages and use the limits. 9 10 * wtf/StackBounds.cpp: 11 (WTF::detectGrowingDownward): 12 (WTF::isPageWritable): 13 (WTF::getLowerStackBound): 14 (WTF::getUpperStackBound): 15 (WTF::StackBounds::initialize): 16 1 17 2011-01-05 Steve Falkenburg <sfalken@apple.com> 2 18 -
trunk/Source/JavaScriptCore/wtf/StackBounds.cpp
-
Property
svn:eol-style
set to
native
r74595 r75180 66 66 // 67 67 // FIXME: remove this! - this code unsafely guesses at stack sizes! 68 #if OS(WINDOWS) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU) || OS(WINCE)68 #if OS(WINDOWS) || OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU) 69 69 // Based on the current limit used by the JSC parser, guess the stack size. 70 70 static const ptrdiff_t estimatedStackSize = 128 * sizeof(void*) * 1024; … … 185 185 namespace WTF { 186 186 187 inline bool isPageWritable(void* page) 187 static bool detectGrowingDownward(void* previousFrame) 188 { 189 // Find the address of this stack frame by taking the address of a local variable. 190 int thisFrame; 191 return previousFrame > &thisFrame; 192 } 193 194 static inline bool isPageWritable(void* page) 188 195 { 189 196 MEMORY_BASIC_INFORMATION memoryInformation; … … 201 208 } 202 209 203 static void* getStackMax(void* previousFrame, bool& isGrowingDownward) 210 static inline void* getLowerStackBound(char* currentPage, DWORD pageSize) 211 { 212 while (currentPage > 0) { 213 // check for underflow 214 if (currentPage >= reinterpret_cast<char*>(pageSize)) 215 currentPage -= pageSize; 216 else 217 currentPage = 0; 218 219 if (!isPageWritable(currentPage)) 220 return currentPage + pageSize; 221 } 222 223 return 0; 224 } 225 226 static inline void* getUpperStackBound(char* currentPage, DWORD pageSize) 227 { 228 do { 229 // guaranteed to complete because isPageWritable returns false at end of memory 230 currentPage += pageSize; 231 } while (isPageWritable(currentPage)); 232 233 return currentPage - pageSize; 234 } 235 236 void StackBounds::initialize() 204 237 { 205 238 // find the address of this stack frame by taking the address of a local variable 206 239 void* thisFrame = &thisFrame; 207 isGrowingDownward = previousFrame < &thisFrame; 208 209 if (JSC::g_stackBase) 210 return JSC::g_stackBase; 240 bool isGrowingDownward = detectGrowingDownward(thisFrame); 211 241 212 242 SYSTEM_INFO systemInfo; … … 215 245 216 246 // scan all of memory starting from this frame, and return the last writeable page found 217 register char* currentPage = (char*)((DWORD)thisFrame & ~(pageSize - 1)); 218 if (isGrowingDownward) { 219 while (currentPage > 0) { 220 // check for underflow 221 if (currentPage >= (char*)pageSize) 222 currentPage -= pageSize; 223 else 224 currentPage = 0; 225 if (!isPageWritable(currentPage)) 226 return currentPage + pageSize; 227 } 228 return 0; 229 } else { 230 while (true) { 231 // guaranteed to complete because isPageWritable returns false at end of memory 232 currentPage += pageSize; 233 if (!isPageWritable(currentPage)) 234 return currentPage; 235 } 236 } 237 } 238 239 void StackBounds::initialize() 240 { 241 int dummy; 242 bool isGrowingDownward; 243 m_origin = getStackMax(&dummy, isGrowingDownward); 244 m_bound = isGrowingDownward 245 ? static_cast<char*>(m_origin) - estimatedStackSize 246 : static_cast<char*>(m_origin) + estimatedStackSize; 247 char* currentPage = reinterpret_cast<char*>(reinterpret_cast<DWORD>(thisFrame) & ~(pageSize - 1)); 248 void* lowerStackBound = getLowerStackBound(currentPage, pageSize); 249 void* upperStackBound = getUpperStackBound(currentPage, pageSize); 250 251 m_origin = isGrowingDownward ? upperStackBound : lowerStackBound; 252 m_bound = isGrowingDownward ? lowerStackBound : upperStackBound; 247 253 } 248 254 -
Property
svn:eol-style
set to
Note: See TracChangeset
for help on using the changeset viewer.