Changeset 43885 in webkit


Ignore:
Timestamp:
May 19, 2009 8:25:47 PM (15 years ago)
Author:
ggaren@apple.com
Message:

2009-05-19 Geoffrey Garen <ggaren@apple.com>

Reviewed by Sam Weinig.


Fixed <rdar://problem/6885680> CrashTracer: [USER] 1 crash in Install
Mac OS X at <unknown binary> • 0x9274241c


(Original patch by Joe Sokol and Ronnie Misra.)


SunSpider says 1.004x faster.

  • interpreter/RegisterFile.cpp: (JSC::RegisterFile::releaseExcessCapacity): Instead of doing complicated math that sometimes used to overflow, just release the full range of the register file.
  • interpreter/RegisterFile.h: (JSC::isPageAligned): (JSC::RegisterFile::RegisterFile): Added ASSERTs to verify that it's safe to release the full range of the register file.

(JSC::RegisterFile::shrink): No need to releaseExcessCapacity() if the
new end is not smaller than the old end. (Also, doing so used to cause
numeric overflow, unmapping basically the whole process from memory.)

Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r43881 r43885  
     12009-05-19  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4       
     5        Fixed <rdar://problem/6885680> CrashTracer: [USER] 1 crash in Install
     6        Mac OS X at <unknown binary> • 0x9274241c
     7       
     8        (Original patch by Joe Sokol and Ronnie Misra.)
     9       
     10        SunSpider says 1.004x faster.
     11
     12        * interpreter/RegisterFile.cpp:
     13        (JSC::RegisterFile::releaseExcessCapacity): Instead of doing complicated
     14        math that sometimes used to overflow, just release the full range of the
     15        register file.
     16
     17        * interpreter/RegisterFile.h:
     18        (JSC::isPageAligned):
     19        (JSC::RegisterFile::RegisterFile): Added ASSERTs to verify that it's
     20        safe to release the full range of the register file.
     21
     22        (JSC::RegisterFile::shrink): No need to releaseExcessCapacity() if the
     23        new end is not smaller than the old end. (Also, doing so used to cause
     24        numeric overflow, unmapping basically the whole process from memory.)
     25
    1262009-05-19  Oliver Hunt  <oliver@apple.com>
    227
  • trunk/JavaScriptCore/interpreter/RegisterFile.cpp

    r42862 r43885  
    4545void RegisterFile::releaseExcessCapacity()
    4646{
     47#if HAVE(MMAP) && HAVE(MADV_FREE) && !HAVE(VIRTUALALLOC)
     48    while (madvise(m_start, (m_max - m_start) * sizeof(Register), MADV_FREE) == -1 && errno == EAGAIN) { }
     49#elif HAVE(VIRTUALALLOC)
     50    VirtualFree(madvise(m_start, (m_max - m_start) * sizeof(Register), MEM_DECOMMIT);
     51    m_commitEnd = m_start;
     52#endif
    4753    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(MADV_FREE) && !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 = reinterpret_cast<Register*>(memoryToRelease);
    55 #endif
    5654}
    5755
  • trunk/JavaScriptCore/interpreter/RegisterFile.h

    r42842 r43885  
    157157    };
    158158
     159    // FIXME: Add a generic getpagesize() to WTF, then move this function to WTF as well.
     160    inline bool isPageAligned(size_t size) { return size != 0 && size % (8 * 1024) == 0; }
     161
    159162    inline RegisterFile::RegisterFile(size_t capacity, size_t maxGlobals)
    160163        : m_numGlobals(0)
     
    166169        , m_globalObject(0)
    167170    {
     171        // Verify that our values will play nice with mmap and VirtualAlloc.
     172        ASSERT(isPageAligned(maxGlobals));
     173        ASSERT(isPageAligned(capacity));
     174
    168175        size_t bufferLength = (capacity + maxGlobals) * sizeof(Register);
    169176    #if HAVE(MMAP)
     
    197204    inline void RegisterFile::shrink(Register* newEnd)
    198205    {
    199         if (newEnd < m_end)
    200             m_end = newEnd;
    201         if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity)
     206        if (newEnd >= m_end)
     207            return;
     208        m_end = newEnd;
     209        if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity)
    202210            releaseExcessCapacity();
    203211    }
Note: See TracChangeset for help on using the changeset viewer.