Changeset 133812 in webkit


Ignore:
Timestamp:
Nov 7, 2012, 3:34:30 PM (13 years ago)
Author:
[email protected]
Message:

WeakBlocks should be HeapBlocks
https://bugs.webkit.org/show_bug.cgi?id=101411

Reviewed by Oliver Hunt.

Currently WeakBlocks use fastMalloc memory. They are very similar to the other HeapBlocks, however,
so we should change them to being allocated with the BlockAllocator.

  • heap/BlockAllocator.cpp:

(JSC::BlockAllocator::BlockAllocator):

  • heap/BlockAllocator.h: Added a new RegionSet for WeakBlocks.

(JSC):
(BlockAllocator):
(JSC::WeakBlock):

  • heap/Heap.h: Friended WeakSet to allow access to the BlockAllocator.

(Heap):

  • heap/WeakBlock.cpp:

(JSC::WeakBlock::create): Refactored to use HeapBlocks rather than fastMalloc.
(JSC::WeakBlock::WeakBlock):

  • heap/WeakBlock.h: Changed the WeakBlock size to 4 KB so that it divides evenly into the Region size.

(JSC):
(WeakBlock):

  • heap/WeakSet.cpp:

(JSC::WeakSet::~WeakSet):
(JSC::WeakSet::addAllocator):

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r133800 r133812  
     12012-11-07  Mark Hahnenberg  <[email protected]>
     2
     3        WeakBlocks should be HeapBlocks
     4        https://bugs.webkit.org/show_bug.cgi?id=101411
     5
     6        Reviewed by Oliver Hunt.
     7
     8        Currently WeakBlocks use fastMalloc memory. They are very similar to the other HeapBlocks, however,
     9        so we should change them to being allocated with the BlockAllocator.
     10
     11        * heap/BlockAllocator.cpp:
     12        (JSC::BlockAllocator::BlockAllocator):
     13        * heap/BlockAllocator.h: Added a new RegionSet for WeakBlocks.
     14        (JSC):
     15        (BlockAllocator):
     16        (JSC::WeakBlock):
     17        * heap/Heap.h: Friended WeakSet to allow access to the BlockAllocator.
     18        (Heap):
     19        * heap/WeakBlock.cpp:
     20        (JSC::WeakBlock::create): Refactored to use HeapBlocks rather than fastMalloc.
     21        (JSC::WeakBlock::WeakBlock):
     22        * heap/WeakBlock.h: Changed the WeakBlock size to 4 KB so that it divides evenly into the Region size.
     23        (JSC):
     24        (WeakBlock):
     25        * heap/WeakSet.cpp:
     26        (JSC::WeakSet::~WeakSet):
     27        (JSC::WeakSet::addAllocator):
     28
    1292012-11-07  Filip Pizlo  <[email protected]>
    230
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp

    r131619 r133812  
    2929#include "CopiedBlock.h"
    3030#include "MarkedBlock.h"
     31#include "WeakBlock.h"
    3132#include <wtf/CurrentTime.h>
    3233
     
    3637    : m_copiedRegionSet(CopiedBlock::blockSize)
    3738    , m_markedRegionSet(MarkedBlock::blockSize)
     39    , m_weakRegionSet(WeakBlock::blockSize)
    3840    , m_numberOfEmptyRegions(0)
    3941    , m_isCurrentlyAllocating(false)
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.h

    r131321 r133812  
    4040class MarkedBlock;
    4141class Region;
     42class WeakBlock;
    4243
    4344// Simple allocator to reduce VM cost by holding onto blocks of memory for
     
    185186    RegionSet m_copiedRegionSet;
    186187    RegionSet m_markedRegionSet;
     188    RegionSet m_weakRegionSet;
    187189
    188190    DoublyLinkedList<Region> m_emptyRegions;
     
    312314
    313315template <>
     316inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<WeakBlock>()
     317{
     318    return m_weakRegionSet;
     319}
     320
     321template <>
    314322inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<CopiedBlock> >()
    315323{
     
    321329{
    322330    return m_markedRegionSet;
     331}
     332
     333template <>
     334inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<WeakBlock> >()
     335{
     336    return m_weakRegionSet;
    323337}
    324338
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r133358 r133812  
    189189        friend class IncrementalSweeper;
    190190        friend class HeapStatistics;
     191        friend class WeakSet;
    191192        template<typename T> friend void* allocateCell(Heap&);
    192193        template<typename T> friend void* allocateCell(Heap&, size_t);
  • trunk/Source/JavaScriptCore/heap/WeakBlock.cpp

    r133358 r133812  
    3535namespace JSC {
    3636
    37 WeakBlock* WeakBlock::create()
     37WeakBlock* WeakBlock::create(DeadBlock* block)
    3838{
    39     void* allocation = fastMalloc(blockSize);
    40     return new (NotNull, allocation) WeakBlock;
     39    Region* region = block->region();
     40    return new (NotNull, block) WeakBlock(region);
    4141}
    4242
    43 void WeakBlock::destroy(WeakBlock* block)
    44 {
    45     fastFree(block);
    46 }
    47 
    48 WeakBlock::WeakBlock()
     43WeakBlock::WeakBlock(Region* region)
     44    : HeapBlock<WeakBlock>(region)
    4945{
    5046    for (size_t i = 0; i < weakImplCount(); ++i) {
  • trunk/Source/JavaScriptCore/heap/WeakBlock.h

    r118616 r133812  
    3535namespace JSC {
    3636
     37class DeadBlock;
    3738class HeapRootVisitor;
    3839class JSValue;
    3940class WeakHandleOwner;
    4041
    41 class WeakBlock : public DoublyLinkedListNode<WeakBlock> {
     42class WeakBlock : public HeapBlock<WeakBlock> {
    4243public:
    4344    friend class WTF::DoublyLinkedListNode<WeakBlock>;
    44     static const size_t blockSize = 3 * KB; // 5% of MarkedBlock size
     45    static const size_t blockSize = 4 * KB; // 5% of MarkedBlock size
    4546
    4647    struct FreeCell {
     
    5657    };
    5758
    58     static WeakBlock* create();
    59     static void destroy(WeakBlock*);
     59    static WeakBlock* create(DeadBlock*);
    6060
    6161    static WeakImpl* asWeakImpl(FreeCell*);
     
    7474    static FreeCell* asFreeCell(WeakImpl*);
    7575
    76     WeakBlock();
     76    WeakBlock(Region*);
    7777    WeakImpl* firstWeakImpl();
    7878    void finalize(WeakImpl*);
     
    8181    void addToFreeList(FreeCell**, WeakImpl*);
    8282
    83     WeakBlock* m_prev;
    84     WeakBlock* m_next;
    8583    SweepResult m_sweepResult;
    8684};
  • trunk/Source/JavaScriptCore/heap/WeakSet.cpp

    r127338 r133812  
    3737    for (WeakBlock* block = m_blocks.head(); block; block = next) {
    3838        next = block->next();
    39         WeakBlock::destroy(block);
     39        heap()->blockAllocator().deallocate(WeakBlock::destroy(block));
    4040    }
    4141    m_blocks.clear();
     
    7474WeakBlock::FreeCell* WeakSet::addAllocator()
    7575{
    76     WeakBlock* block = WeakBlock::create();
     76    WeakBlock* block = WeakBlock::create(heap()->blockAllocator().allocate<WeakBlock>());
    7777    heap()->didAllocate(WeakBlock::blockSize);
    7878    m_blocks.append(block);
Note: See TracChangeset for help on using the changeset viewer.