Ignore:
Timestamp:
May 21, 2009, 3:12:39 PM (16 years ago)
Author:
[email protected]
Message:

2009-05-21 Cameron Zwarich <[email protected]>

Reviewed by Mark Rowe.

Bug 25945: Add support for MADV_FREE to TCMalloc
<https://bugs.webkit.org/show_bug.cgi?id=25945>
<rdar://problem/6910754>

Add support for MADV_FREE to TCMalloc_SystemRelease for platforms that
don't also support MADV_FREE_REUSE. The code is identical to the MADV_DONTNEED
case except for the advice passed to madvise(), so combining the two cases
makes the most sense.

  • wtf/Platform.h: Only define HAVE_MADV_FREE when not building on Tiger or Leopard, because while it is defined on these platforms it actually does nothing.
  • wtf/TCSystemAlloc.cpp: (TCMalloc_SystemRelease): use MADV_FREE if it is available; otherwise use MADV_DONTNEED.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/TCSystemAlloc.cpp

    r41660 r43988  
    389389}
    390390
    391 #elif HAVE(MADV_DONTNEED)
     391#elif HAVE(MADV_FREE) || HAVE(MADV_DONTNEED)
    392392
    393393void TCMalloc_SystemRelease(void* start, size_t length)
    394394{
     395    // MADV_FREE clears the modified bit on pages, which allows
     396    // them to be discarded immediately.
     397#if HAVE(MADV_FREE)
     398    const int advice = MADV_FREE;
     399#else
     400    const int advice = MADV_DONTNEED;
     401#endif
    395402  if (FLAGS_malloc_devmem_start) {
    396403    // It's not safe to use MADV_DONTNEED if we've been mapping
     
    419426    // doesn't matter...
    420427    while (madvise(reinterpret_cast<char*>(new_start), new_end - new_start,
    421                    MADV_DONTNEED) == -1 &&
     428                   advice) == -1 &&
    422429           errno == EAGAIN) {
    423430      // NOP
Note: See TracChangeset for help on using the changeset viewer.