diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog index c2a309f1becbeab48728052680ddc64e4a6d5333..7bf883245deb4482c0383e14a8200020ee2bbaac 100644 --- a/JavaScriptCore/ChangeLog +++ b/JavaScriptCore/ChangeLog @@ -1,3 +1,16 @@ +2009-08-12 Ada Chan + + Added workaround for the limitation that VirtualFree with MEM_RELEASE + can only accept the base address returned by VirtualAlloc when the region + was reserved and it can only free the entire region, and not a part of it. + + Reviewed by Oliver Hunt. + + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + * runtime/MarkStackWin.cpp: + (JSC::MarkStack::releaseStack): + 2009-08-12 Balazs Kelemen Reviewed by Ariya Hidayat. diff --git a/JavaScriptCore/runtime/MarkStack.h b/JavaScriptCore/runtime/MarkStack.h index 7a7b3afb5c3afb0e3fa6046048980243e65c98bb..ee537959d68cd16ee8a6037f964989daa8bd2ec8 100644 --- a/JavaScriptCore/runtime/MarkStack.h +++ b/JavaScriptCore/runtime/MarkStack.h @@ -150,7 +150,14 @@ namespace JSC { ASSERT(0 == (size % MarkStack::pageSize())); if (size == m_allocated) return; +#if PLATFORM(WIN) + // We cannot release a part of a region with VirtualFree. To get around this, + // we'll release the entire region and reallocate the size that we want. + releaseStack(m_data, m_allocated); + m_data = reinterpret_cast(allocateStack(size)); +#else releaseStack(reinterpret_cast(m_data) + size, m_allocated - size); +#endif m_allocated = size; m_capacity = m_allocated / sizeof(T); } diff --git a/JavaScriptCore/runtime/MarkStackWin.cpp b/JavaScriptCore/runtime/MarkStackWin.cpp index dbc330692810c05c5e7395d5b7f0228da046b00d..1fdd06a655c370dfbc9e0da041b0871f31ab0029 100644 --- a/JavaScriptCore/runtime/MarkStackWin.cpp +++ b/JavaScriptCore/runtime/MarkStackWin.cpp @@ -43,9 +43,11 @@ void* MarkStack::allocateStack(size_t size) { return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); } -void MarkStack::releaseStack(void* addr, size_t size) +void MarkStack::releaseStack(void* addr, size_t) { - VirtualFree(addr, size, MEM_RELEASE); + // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx, + // dwSize must be 0 if dwFreeType is MEM_RELEASE. + VirtualFree(addr, 0, MEM_RELEASE); } }