Ignore:
Timestamp:
Dec 21, 2010, 3:53:25 PM (15 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements
https://bugs.webkit.org/show_bug.cgi?id=51359

Patch by Geoffrey Garen <[email protected]> on 2010-12-21
Reviewed by Gavin Barraclough & Oliver Hunt.

I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in
Heap::allocateBlock (1902752929), and some other leaks and crashes as well.

  • runtime/AlignedMemoryAllocator.h: Removed. Supplanted by

PageAllocationAligned.

  • runtime/Collector.cpp:

(JSC::Heap::destroy):
(JSC::Heap::allocateBlock):
(JSC::Heap::freeBlock):
(JSC::Heap::addWeakGCHandle):

  • runtime/Collector.h: Switched from AlignedMemoryAllocator to

PageAllocationAligned.

  • runtime/GCHandle.cpp:
  • runtime/GCHandle.h: Ditto.
  • wtf/PageAllocation.h:

(WTF::PageAllocation::PageAllocation): Removed aligned memory allocation
functions. Supplanted by PageAllocationAligned.

  • wtf/PageAllocationAligned.cpp: Added.

(WTF::PageAllocationAligned::allocate):
(WTF::PageAllocationAligned::deallocate):

  • wtf/PageAllocationAligned.h: Added.

(WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform
class for doing aligned memory allocation. This class properly matches
allocation and deallocation library calls, fixing a long-standing bug
in PageAllocation.

  • wtf/Platform.h: Removed some defunction VM platform defines.
  • wtf/wtf.pri: Updated build files.

JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements
https://bugs.webkit.org/show_bug.cgi?id=51359

Patch by Geoffrey Garen <[email protected]> on 2010-12-21
Reviewed by Gavin Barraclough & Oliver Hunt.

  • ForwardingHeaders/wtf/PageAllocationAligned.h: Added.

WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements
https://bugs.webkit.org/show_bug.cgi?id=51359

Patch by Geoffrey Garen <[email protected]> on 2010-12-21
Reviewed by Gavin Barraclough & Oliver Hunt.

  • ForwardingHeaders/wtf/PageAllocationAligned.h: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/PageReservation.h

    r74382 r74431  
    5858public:
    5959    PageReservation()
     60        : m_writable(false)
     61        , m_executable(false)
     62#ifndef NDEBUG
     63        , m_committed(0)
     64#endif
    6065    {
    6166    }
     
    7075        ASSERT(isPageAligned(start));
    7176        ASSERT(isPageAligned(size));
     77        ASSERT(contains(start, size));
    7278
    7379#ifndef NDEBUG
     
    8288        ASSERT(isPageAligned(start));
    8389        ASSERT(isPageAligned(size));
     90        ASSERT(contains(start, size));
    8491
    8592#ifndef NDEBUG
     
    9299    {
    93100        ASSERT(isPageAligned(size));
    94         return PageReservation(OSAllocator::reserve(size, usage, writable, executable), size, writable, executable);
     101        return PageReservation(OSAllocator::reserveUncommitted(size, usage, writable, executable), size, writable, executable);
    95102    }
    96103
     
    98105    {
    99106        ASSERT(!m_committed);
    100         ASSERT(*this);
    101107
    102         // Zero these before calling release; if this is *inside* allocation,
    103         // we won't be able to clear then after the call to OSAllocator::release.
    104         void* base = m_base;
    105         size_t size = m_size;
    106         m_base = 0;
    107         m_size = 0;
     108        // Clear base & size before calling release; if this is *inside* allocation
     109        // then we won't be able to clear then after deallocating the memory.
     110        PageReservation tmp;
     111        std::swap(tmp, *this);
    108112
    109         OSAllocator::release(base, size);
     113        ASSERT(tmp);
     114        ASSERT(!*this);
     115
     116        OSAllocator::releaseDecommitted(tmp.base(), tmp.size());
    110117    }
    111118
     
    113120    PageReservation(void* base, size_t size, bool writable, bool executable)
    114121        : PageBlock(base, size)
     122        , m_writable(writable)
     123        , m_executable(executable)
    115124#ifndef NDEBUG
    116125        , m_committed(0)
    117126#endif
    118         , m_writable(writable)
    119         , m_executable(executable)
    120127    {
    121128    }
    122129
     130    bool m_writable;
     131    bool m_executable;
    123132#ifndef NDEBUG
    124133    size_t m_committed;
    125134#endif
    126     bool m_writable;
    127     bool m_executable;
    128135};
    129136
Note: See TracChangeset for help on using the changeset viewer.