Commit 826691b6 authored by adachan@apple.com's avatar adachan@apple.com

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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47159 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 52355c39
2009-08-12 Ada Chan <adachan@apple.com>
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 <kelemen.balazs.3@stud.u-szeged.hu>
Reviewed by Ariya Hidayat.
......
......@@ -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<T*>(allocateStack(size));
#else
releaseStack(reinterpret_cast<char*>(m_data) + size, m_allocated - size);
#endif
m_allocated = size;
m_capacity = m_allocated / sizeof(T);
}
......
......@@ -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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment