Ignore:
Timestamp:
Jan 27, 2015, 10:29:29 AM (10 years ago)
Author:
[email protected]
Message:

Use FastMalloc (bmalloc) instead of BlockAllocator for GC pages
https://bugs.webkit.org/show_bug.cgi?id=140900

Reviewed by Mark Hahnenberg.

Source/JavaScriptCore:

Removes some more custom allocation code.

Looks like a speedup. (See results attached to bugzilla.)

Will hopefully reduce memory use by improving sharing between the GC and
malloc heaps.

  • heap/BlockAllocator.cpp: Removed.
  • heap/BlockAllocator.h: Removed. No need for a custom allocator anymore.
  • heap/CodeBlockSet.cpp:

(JSC::CodeBlockSet::CodeBlockSet):

  • heap/CodeBlockSet.h: Feed the compiler.
  • heap/CopiedBlock.h:

(JSC::CopiedBlock::createNoZeroFill):
(JSC::CopiedBlock::create):
(JSC::CopiedBlock::CopiedBlock):
(JSC::CopiedBlock::isOversize):
(JSC::CopiedBlock::payloadEnd):
(JSC::CopiedBlock::capacity):

  • heap/CopiedBlockInlines.h:

(JSC::CopiedBlock::reportLiveBytes): Each copied block now tracks its
own size, since we can't rely on Region to tell us our size anymore.

  • heap/CopiedSpace.cpp:

(JSC::CopiedSpace::~CopiedSpace):
(JSC::CopiedSpace::tryAllocateOversize):
(JSC::CopiedSpace::tryReallocateOversize):

  • heap/CopiedSpaceInlines.h:

(JSC::CopiedSpace::recycleEvacuatedBlock):
(JSC::CopiedSpace::recycleBorrowedBlock):
(JSC::CopiedSpace::allocateBlockForCopyingPhase):
(JSC::CopiedSpace::allocateBlock):
(JSC::CopiedSpace::startedCopying): Deallocate blocks directly, rather
than pushing them onto the block allocator's free list; the block
allocator doesn't exist anymore.

  • heap/CopyWorkList.h:

(JSC::CopyWorkListSegment::create):
(JSC::CopyWorkListSegment::CopyWorkListSegment):
(JSC::CopyWorkList::~CopyWorkList):
(JSC::CopyWorkList::append):
(JSC::CopyWorkList::CopyWorkList): Deleted.

  • heap/GCSegmentedArray.h:

(JSC::GCArraySegment::GCArraySegment):

  • heap/GCSegmentedArrayInlines.h:

(JSC::GCSegmentedArray<T>::GCSegmentedArray):
(JSC::GCSegmentedArray<T>::~GCSegmentedArray):
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::refill):
(JSC::GCArraySegment<T>::create):

  • heap/GCThreadSharedData.cpp:

(JSC::GCThreadSharedData::GCThreadSharedData):

  • heap/GCThreadSharedData.h: Feed the compiler.
  • heap/HandleBlock.h:
  • heap/HandleBlockInlines.h:

(JSC::HandleBlock::create):
(JSC::HandleBlock::HandleBlock):
(JSC::HandleBlock::payloadEnd):

  • heap/HandleSet.cpp:

(JSC::HandleSet::~HandleSet):
(JSC::HandleSet::grow): Same as above.

  • heap/Heap.cpp:

(JSC::Heap::Heap):

  • heap/Heap.h: Removed the block allocator since it is unused now.
  • heap/HeapBlock.h:

(JSC::HeapBlock::destroy):
(JSC::HeapBlock::HeapBlock):
(JSC::HeapBlock::region): Deleted. Removed the Region pointer from each
HeapBlock since a HeapBlock is just a normal allocation now.

  • heap/HeapInlines.h:

(JSC::Heap::blockAllocator): Deleted.

  • heap/HeapTimer.cpp:
  • heap/MarkStack.cpp:

(JSC::MarkStackArray::MarkStackArray):

  • heap/MarkStack.h: Feed the compiler.
  • heap/MarkedAllocator.cpp:

(JSC::MarkedAllocator::allocateBlock): No need to use a custom code path
based on size, since we use a general purpose allocator now.

  • heap/MarkedBlock.cpp:

(JSC::MarkedBlock::create):
(JSC::MarkedBlock::destroy):
(JSC::MarkedBlock::MarkedBlock):

  • heap/MarkedBlock.h:

(JSC::MarkedBlock::capacity): Track block size explicitly, like CopiedBlock.

  • heap/MarkedSpace.cpp:

(JSC::MarkedSpace::freeBlock):

  • heap/MarkedSpace.h:
  • heap/Region.h: Removed.
  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::SlotVisitor): Removed reference to block allocator.

  • heap/SuperRegion.cpp: Removed.
  • heap/SuperRegion.h: Removed.
  • heap/WeakBlock.cpp:

(JSC::WeakBlock::create):
(JSC::WeakBlock::WeakBlock):

  • heap/WeakBlock.h:
  • heap/WeakSet.cpp:

(JSC::WeakSet::~WeakSet):
(JSC::WeakSet::addAllocator):
(JSC::WeakSet::removeAllocator): Removed reference to block allocator.

Source/WebCore:

  • platform/cocoa/MemoryPressureHandlerCocoa.mm:

(WebCore::MemoryPressureHandler::install): Be sure to release other
memory after GC and not before, since GC might contribute to free
malloc pages now.

Source/WTF:

New interface for aligned allocation: fastAlignedMalloc / fastAlignedFree.
We require a special function call on free because Windows.

  • wtf/FastMalloc.cpp:

(WTF::fastAlignedMalloc):
(WTF::fastAlignedFree): Do it.

(WTF::do_memalign): Un-ifdef this, since we use it now.

  • wtf/FastMalloc.h: Make our new function names visible like the rest

of fastMalloc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/CopiedBlock.h

    r177130 r179192  
    2727#define CopiedBlock_h
    2828
    29 #include "BlockAllocator.h"
    3029#include "CopyWorkList.h"
    3130#include "HeapBlock.h"
     
    3332#include "Options.h"
    3433#include <wtf/Atomics.h>
     34#include <wtf/TCSpinLock.h>
    3535
    3636namespace JSC {
     
    4242    friend class CopiedAllocator;
    4343public:
    44     static CopiedBlock* create(DeadBlock*);
    45     static CopiedBlock* createNoZeroFill(DeadBlock*);
     44    static CopiedBlock* create(size_t);
     45    static CopiedBlock* createNoZeroFill(size_t);
    4646
    4747    void pin();
     
    8787
    8888private:
    89     CopiedBlock(Region*);
     89    CopiedBlock(size_t);
    9090    void zeroFillWilderness(); // Can be called at any time to zero-fill to the end of the block.
    9191
     
    9595    std::unique_ptr<CopyWorkList> m_workList;
    9696
     97    size_t m_blockSize;
    9798    size_t m_remaining;
    9899    bool m_isPinned : 1;
     
    104105};
    105106
    106 inline CopiedBlock* CopiedBlock::createNoZeroFill(DeadBlock* block)
    107 {
    108     Region* region = block->region();
    109     return new(NotNull, block) CopiedBlock(region);
    110 }
    111 
    112 inline CopiedBlock* CopiedBlock::create(DeadBlock* block)
    113 {
    114     CopiedBlock* newBlock = createNoZeroFill(block);
     107inline CopiedBlock* CopiedBlock::createNoZeroFill(size_t blockSize)
     108{
     109    return new(NotNull, fastAlignedMalloc(CopiedBlock::blockSize, blockSize)) CopiedBlock(blockSize);
     110}
     111
     112inline CopiedBlock* CopiedBlock::create(size_t blockSize)
     113{
     114    CopiedBlock* newBlock = createNoZeroFill(blockSize);
    115115    newBlock->zeroFillWilderness();
    116116    return newBlock;
     
    129129}
    130130
    131 inline CopiedBlock::CopiedBlock(Region* region)
    132     : HeapBlock<CopiedBlock>(region)
     131inline CopiedBlock::CopiedBlock(size_t blockSize)
     132    : HeapBlock<CopiedBlock>()
     133    , m_blockSize(blockSize)
    133134    , m_remaining(payloadCapacity())
    134135    , m_isPinned(false)
     
    204205inline bool CopiedBlock::isOversize()
    205206{
    206     return region()->isCustomSize();
     207    return m_blockSize != blockSize;
    207208}
    208209
     
    220221inline char* CopiedBlock::payloadEnd()
    221222{
    222     return reinterpret_cast<char*>(this) + region()->blockSize();
     223    return reinterpret_cast<char*>(this) + m_blockSize;
    223224}
    224225
     
    265266inline size_t CopiedBlock::capacity()
    266267{
    267     return region()->blockSize();
     268    return m_blockSize;
    268269}
    269270
Note: See TracChangeset for help on using the changeset viewer.