Ignore:
Timestamp:
Apr 24, 2009, 2:53:46 PM (16 years ago)
Author:
[email protected]
Message:

<rdar://problem/6050421> JavaScript register file should remap to release physical pages accumulated during deep recursion

Reviewed by Geoff Garen

We now track the maximum extent of the RegisterFile, and when we reach the final
return from JS (so the stack portion of the registerfile becomes empty) we see
if that extent is greater than maxExcessCapacity. If it is we use madvise or
VirtualFree to release the physical pages that were backing the excess.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/RegisterFile.cpp

    r39673 r42842  
    4343}
    4444
     45void RegisterFile::releaseExcessCapacity()
     46{
     47    m_maxUsed = m_start;
     48    void* memoryToRelease = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(reinterpret_cast<char*>(m_start) + commitSize * 2 - 1) & ~(commitSize - 1));
     49    ptrdiff_t size = reinterpret_cast<char*>(m_end) - reinterpret_cast<char*>(memoryToRelease);
     50#if HAVE(MMAP) && !HAVE(VIRTUALALLOC)
     51    while (madvise(memoryToRelease, size, MADV_FREE) == -1 && errno == EAGAIN) { }
     52#elif HAVE(VIRTUALALLOC)
     53    VirtualFree(memoryToRelease, size, MEM_DECOMMIT);
     54    m_commitEnd = memoryToRelease;
     55#endif
     56}
     57
    4558} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.