Changeset 44993 in webkit for trunk/JavaScriptCore/runtime/Collector.cpp
- Timestamp:
- Jun 23, 2009, 8:45:12 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/Collector.cpp
r44813 r44993 393 393 return heapAllocate<NumberHeap>(s); 394 394 } 395 396 #if PLATFORM(WINCE) 397 void* g_stackBase = 0; 398 399 inline bool isPageWritable(void* page) 400 { 401 MEMORY_BASIC_INFORMATION memoryInformation; 402 DWORD result = VirtualQuery(page, &memoryInformation, sizeof(memoryInformation)); 403 404 // return false on error, including ptr outside memory 405 if (result != sizeof(memoryInformation)) 406 return false; 407 408 DWORD protect = memoryInformation.Protect & ~(PAGE_GUARD | PAGE_NOCACHE); 409 return protect == PAGE_READWRITE 410 || protect == PAGE_WRITECOPY 411 || protect == PAGE_EXECUTE_READWRITE 412 || protect == PAGE_EXECUTE_WRITECOPY; 413 } 414 415 static void* getStackBase(void* previousFrame) 416 { 417 // find the address of this stack frame by taking the address of a local variable 418 bool isGrowingDownward; 419 void* thisFrame = (void*)(&isGrowingDownward); 420 421 isGrowingDownward = previousFrame < &thisFrame; 422 static DWORD pageSize = 0; 423 if (!pageSize) { 424 SYSTEM_INFO systemInfo; 425 GetSystemInfo(&systemInfo); 426 pageSize = systemInfo.dwPageSize; 427 } 428 429 // scan all of memory starting from this frame, and return the last writeable page found 430 register char* currentPage = (char*)((DWORD)thisFrame & ~(pageSize - 1)); 431 if (isGrowingDownward) { 432 while (currentPage > 0) { 433 // check for underflow 434 if (currentPage >= (char*)pageSize) 435 currentPage -= pageSize; 436 else 437 currentPage = 0; 438 if (!isPageWritable(currentPage)) 439 return currentPage + pageSize; 440 } 441 return 0; 442 } else { 443 while (true) { 444 // guaranteed to complete because isPageWritable returns false at end of memory 445 currentPage += pageSize; 446 if (!isPageWritable(currentPage)) 447 return currentPage; 448 } 449 } 450 } 451 #endif 395 452 396 453 static inline void* currentThreadStackBase() … … 459 516 } 460 517 return static_cast<char*>(stackBase) + stackSize; 518 #elif PLATFORM(WINCE) 519 if (g_stackBase) 520 return g_stackBase; 521 else { 522 int dummy; 523 return getStackBase(&dummy); 524 } 461 525 #else 462 526 #error Need a way to get the stack base on this platform
Note:
See TracChangeset
for help on using the changeset viewer.