|
Lines 749-756
size_t VM::updateReservedZoneSize(size_t
Source/JavaScriptCore/runtime/VM.cpp_sec1
|
| 749 |
return oldReservedZoneSize; |
749 |
return oldReservedZoneSize; |
| 750 |
} |
750 |
} |
| 751 |
|
751 |
|
|
|
752 |
#if PLATFORM(WIN) |
| 753 |
// On Windows the reserved stack space consists of committed memory, a guard page, and uncommitted memory, |
| 754 |
// where the guard page is a barrier between committed and uncommitted memory. |
| 755 |
// When data from the guard page is read or written, the guard page is moved, and memory is committed. |
| 756 |
// This is how the system grows the stack. |
| 757 |
// When using the C stack on Windows we need to precommit the needed stack space. |
| 758 |
// Otherwise we might crash later if we access uncommitted stack memory. |
| 759 |
// This can happen if we allocate stack space larger than the page guard size (4K). |
| 760 |
// The system does not get the chance to move the guard page, and commit more memory, |
| 761 |
// and we crash if uncommitted memory is accessed. |
| 762 |
// The MSVC compiler fixes this by inserting a call to the _chkstk() function, |
| 763 |
// when needed, see http://support.microsoft.com/kb/100775. |
| 764 |
|
| 765 |
static void preCommitStackMemory(void* stackLimit) |
| 766 |
{ |
| 767 |
MEMORY_BASIC_INFORMATION uncommittedMemory; |
| 768 |
if (VirtualQuery(stackLimit, &uncommittedMemory, sizeof(uncommittedMemory)) > 0) |
| 769 |
if (uncommittedMemory.State == MEM_RESERVE) { |
| 770 |
int size = uncommittedMemory.RegionSize; |
| 771 |
OSAllocator::commit(stackLimit, size, true, false); |
| 772 |
} |
| 773 |
} |
| 774 |
#endif |
| 775 |
|
| 752 |
inline void VM::updateStackLimit() |
776 |
inline void VM::updateStackLimit() |
| 753 |
{ |
777 |
{ |
|
|
778 |
#if PLATFORM(WIN) |
| 779 |
void* lastStackLimit = m_stackLimit; |
| 780 |
#endif |
| 781 |
|
| 754 |
if (m_stackPointerAtVMEntry) { |
782 |
if (m_stackPointerAtVMEntry) { |
| 755 |
ASSERT(wtfThreadData().stack().isGrowingDownward()); |
783 |
ASSERT(wtfThreadData().stack().isGrowingDownward()); |
| 756 |
char* startOfStack = reinterpret_cast<char*>(m_stackPointerAtVMEntry); |
784 |
char* startOfStack = reinterpret_cast<char*>(m_stackPointerAtVMEntry); |
|
Lines 769-774
inline void VM::updateStackLimit()
Source/JavaScriptCore/runtime/VM.cpp_sec2
|
| 769 |
#endif |
797 |
#endif |
| 770 |
} |
798 |
} |
| 771 |
|
799 |
|
|
|
800 |
#if PLATFORM(WIN) |
| 801 |
if (lastStackLimit != m_stackLimit) |
| 802 |
preCommitStackMemory(m_stackLimit); |
| 803 |
#endif |
| 772 |
} |
804 |
} |
| 773 |
|
805 |
|
| 774 |
#if ENABLE(FTL_JIT) |
806 |
#if ENABLE(FTL_JIT) |