Changeset 146734 in webkit


Ignore:
Timestamp:
Mar 24, 2013 3:45:36 PM (11 years ago)
Author:
mhahnenberg@apple.com
Message:

HandleSet should use HeapBlocks for storing handles
https://bugs.webkit.org/show_bug.cgi?id=113145

Reviewed by Geoffrey Garen.

  • GNUmakefile.list.am: Build project changes.
  • JavaScriptCore.gypi: Ditto.
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto.
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: Ditto.
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: Ditto.
  • JavaScriptCore.xcodeproj/project.pbxproj: Ditto.
  • heap/BlockAllocator.cpp: Rename the RegionSet to m_fourKBBlockRegionSet because there are

too many block types to include them all in the name now.
(JSC::BlockAllocator::BlockAllocator):

  • heap/BlockAllocator.h:

(BlockAllocator): Add the appropriate override for regionSetFor.
(JSC::WeakBlock):
(JSC::MarkStackSegment):
(JSC::HandleBlock):

  • heap/HandleBlock.h: Added.

(HandleBlock): New class for HandleBlocks.
(JSC::HandleBlock::blockFor): Static method to get the block of the given HandleNode pointer. Allows
us to quickly figure out which HandleSet the HandleNode belongs to without storing the pointer to it
in the HandleNode.
(JSC::HandleBlock::handleSet): Getter.

  • heap/HandleBlockInlines.h: Added.

(JSC::HandleBlock::create):
(JSC::HandleBlock::HandleBlock):
(JSC::HandleBlock::payloadEnd):
(JSC::HandleBlock::payload):
(JSC::HandleBlock::nodes):
(JSC::HandleBlock::nodeAtIndex):
(JSC::HandleBlock::nodeCapacity):

  • heap/HandleSet.cpp:

(JSC::HandleSet::~HandleSet):
(JSC::HandleSet::grow):

  • heap/HandleSet.h:

(HandleNode): Move the internal Node class from HandleSet to be its own public class so it can be
used by HandleBlock.
(HandleSet): Add a typedef so that Node refers to the new HandleNode class.
(JSC::HandleSet::toHandle):
(JSC::HandleSet::toNode):
(JSC::HandleSet::allocate):
(JSC::HandleSet::deallocate):
(JSC::HandleNode::HandleNode):
(JSC::HandleNode::slot):
(JSC::HandleNode::handleSet): Use the new blockFor static function to get the right HandleBlock and lookup
the HandleSet.
(JSC::HandleNode::setPrev):
(JSC::HandleNode::prev):
(JSC::HandleNode::setNext):
(JSC::HandleNode::next):
(JSC::HandleSet::forEachStrongHandle):

  • heap/Heap.h: Friend HandleSet so that it can access the BlockAllocator when allocating HandleBlocks.
Location:
trunk/Source/JavaScriptCore
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r146712 r146734  
     12013-03-23  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        HandleSet should use HeapBlocks for storing handles
     4        https://bugs.webkit.org/show_bug.cgi?id=113145
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * GNUmakefile.list.am: Build project changes.
     9        * JavaScriptCore.gypi: Ditto.
     10        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto.
     11        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: Ditto.
     12        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: Ditto.
     13        * JavaScriptCore.xcodeproj/project.pbxproj: Ditto.
     14        * heap/BlockAllocator.cpp: Rename the RegionSet to m_fourKBBlockRegionSet because there are
     15        too many block types to include them all in the name now.
     16        (JSC::BlockAllocator::BlockAllocator):
     17        * heap/BlockAllocator.h:
     18        (BlockAllocator): Add the appropriate override for regionSetFor.
     19        (JSC::WeakBlock):
     20        (JSC::MarkStackSegment):
     21        (JSC::HandleBlock):
     22        * heap/HandleBlock.h: Added.
     23        (HandleBlock): New class for HandleBlocks.
     24        (JSC::HandleBlock::blockFor): Static method to get the block of the given HandleNode pointer. Allows
     25        us to quickly figure out which HandleSet the HandleNode belongs to without storing the pointer to it
     26        in the HandleNode.
     27        (JSC::HandleBlock::handleSet): Getter.
     28        * heap/HandleBlockInlines.h: Added.
     29        (JSC::HandleBlock::create):
     30        (JSC::HandleBlock::HandleBlock):
     31        (JSC::HandleBlock::payloadEnd):
     32        (JSC::HandleBlock::payload):
     33        (JSC::HandleBlock::nodes):
     34        (JSC::HandleBlock::nodeAtIndex):
     35        (JSC::HandleBlock::nodeCapacity):
     36        * heap/HandleSet.cpp:
     37        (JSC::HandleSet::~HandleSet):
     38        (JSC::HandleSet::grow):
     39        * heap/HandleSet.h:
     40        (HandleNode): Move the internal Node class from HandleSet to be its own public class so it can be
     41        used by HandleBlock.
     42        (HandleSet): Add a typedef so that Node refers to the new HandleNode class.
     43        (JSC::HandleSet::toHandle):
     44        (JSC::HandleSet::toNode):
     45        (JSC::HandleSet::allocate):
     46        (JSC::HandleSet::deallocate):
     47        (JSC::HandleNode::HandleNode):
     48        (JSC::HandleNode::slot):
     49        (JSC::HandleNode::handleSet): Use the new blockFor static function to get the right HandleBlock and lookup
     50        the HandleSet.
     51        (JSC::HandleNode::setPrev):
     52        (JSC::HandleNode::prev):
     53        (JSC::HandleNode::setNext):
     54        (JSC::HandleNode::next):
     55        (JSC::HandleSet::forEachStrongHandle):
     56        * heap/Heap.h: Friend HandleSet so that it can access the BlockAllocator when allocating HandleBlocks.
     57
    1582013-03-22  David Kilzer  <ddkilzer@apple.com>
    259
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r146494 r146734  
    312312        Source/JavaScriptCore/heap/GCAssertions.h \
    313313        Source/JavaScriptCore/heap/Handle.h \
     314    Source/JavaScriptCore/heap/HandleBlock.h \
     315    Source/JavaScriptCore/heap/HandleBlockInlines.h \
    314316        Source/JavaScriptCore/heap/HandleSet.cpp \
    315317        Source/JavaScriptCore/heap/HandleSet.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.gypi

    r146494 r146734  
    359359            'heap/GCThreadSharedData.h',
    360360            'heap/Handle.h',
     361            'heap/HandleBlock.h',
     362            'heap/HandleBlockInlines.h',
    361363            'heap/HandleSet.cpp',
    362364            'heap/HandleSet.h',
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r146494 r146734  
    26552655                        </File>
    26562656                        <File
     2657                                RelativePath="..\..\heap\HandleBlock.h"
     2658                                >
     2659                        </File>
     2660                        <File
     2661                                RelativePath="..\..\heap\HandleBlockInlines.h"
     2662                                >
     2663                        </File>
     2664                        <File
    26572665                                RelativePath="..\..\heap\HandleSet.cpp"
    26582666                                >
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r146530 r146734  
    508508    <ClInclude Include="..\heap\GCThreadSharedData.h" />
    509509    <ClInclude Include="..\heap\Handle.h" />
     510    <ClInclude Include="..\heap\HandleBlock.h" />
     511    <ClInclude Include="..\heap\HandleBlockInlines.h" />
    510512    <ClInclude Include="..\heap\HandleSet.h" />
    511513    <ClInclude Include="..\heap\HandleStack.h" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r146494 r146734  
    10711071      <Filter>heap</Filter>
    10721072    </ClInclude>
     1073    <ClInclude Include="..\heap\HandleBlock.h">
     1074      <Filter>heap</Filter>
     1075    </ClInclude>
     1076    <ClInclude Include="..\heap\HandleBlockInlines.h">
     1077      <Filter>heap</Filter>
     1078    </ClInclude>
    10731079    <ClInclude Include="..\heap\HandleSet.h">
    10741080      <Filter>heap</Filter>
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r146682 r146734  
    838838                C25F8BCD157544A900245B71 /* IncrementalSweeper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C25F8BCB157544A900245B71 /* IncrementalSweeper.cpp */; };
    839839                C25F8BCE157544A900245B71 /* IncrementalSweeper.h in Headers */ = {isa = PBXBuildFile; fileRef = C25F8BCC157544A900245B71 /* IncrementalSweeper.h */; settings = {ATTRIBUTES = (Private, ); }; };
     840                C283190016FE4B7D00157BFD /* HandleBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C28318FF16FE4B7D00157BFD /* HandleBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
     841                C283190216FE533E00157BFD /* HandleBlockInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C283190116FE533E00157BFD /* HandleBlockInlines.h */; };
    840842                C2A7F688160432D400F76B98 /* JSDestructibleObject.h in Headers */ = {isa = PBXBuildFile; fileRef = C2A7F687160432D400F76B98 /* JSDestructibleObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
    841843                C2B916C214DA014E00CBAC86 /* MarkedAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = C2B916C114DA014E00CBAC86 /* MarkedAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    17401742                C25F8BCB157544A900245B71 /* IncrementalSweeper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IncrementalSweeper.cpp; sourceTree = "<group>"; };
    17411743                C25F8BCC157544A900245B71 /* IncrementalSweeper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IncrementalSweeper.h; sourceTree = "<group>"; };
     1744                C28318FF16FE4B7D00157BFD /* HandleBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandleBlock.h; sourceTree = "<group>"; };
     1745                C283190116FE533E00157BFD /* HandleBlockInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HandleBlockInlines.h; sourceTree = "<group>"; };
    17421746                C2A7F687160432D400F76B98 /* JSDestructibleObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDestructibleObject.h; sourceTree = "<group>"; };
    17431747                C2B916C114DA014E00CBAC86 /* MarkedAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkedAllocator.h; sourceTree = "<group>"; };
     
    21582162                                0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */,
    21592163                                0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */,
     2164                                C28318FF16FE4B7D00157BFD /* HandleBlock.h */,
     2165                                C283190116FE533E00157BFD /* HandleBlockInlines.h */,
    21602166                        );
    21612167                        path = heap;
     
    29572963                                0F63945515D07057006A597C /* ArrayProfile.h in Headers */,
    29582964                                BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */,
     2965                                C283190016FE4B7D00157BFD /* HandleBlock.h in Headers */,
    29592966                                BC18C41D0E16F5CD00B34460 /* JSClassRef.h in Headers */,
    29602967                                86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */,
     
    33743381                                0F5F08CF146C7633000472A9 /* UnconditionalFinalizer.h in Headers */,
    33753382                                A7B601821639FD2A00372BA3 /* UnlinkedCodeBlock.h in Headers */,
     3383                                C283190216FE533E00157BFD /* HandleBlockInlines.h in Headers */,
    33763384                                0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */,
    33773385                                0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */,
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.cpp

    r140619 r146734  
    3838    : m_copiedRegionSet(CopiedBlock::blockSize)
    3939    , m_markedRegionSet(MarkedBlock::blockSize)
    40     , m_weakAndMarkStackRegionSet(WeakBlock::blockSize)
     40    , m_fourKBBlockRegionSet(WeakBlock::blockSize)
    4141    , m_workListRegionSet(CopyWorkListSegment::blockSize)
    4242    , m_numberOfEmptyRegions(0)
  • trunk/Source/JavaScriptCore/heap/BlockAllocator.h

    r140594 r146734  
    3939class CopiedBlock;
    4040class CopyWorkListSegment;
     41class HandleBlock;
    4142class MarkStackSegment;
    4243class MarkedBlock;
     
    192193    RegionSet m_markedRegionSet;
    193194    // WeakBlocks and MarkStackSegments use the same RegionSet since they're the same size.
    194     RegionSet m_weakAndMarkStackRegionSet;
     195    RegionSet m_fourKBBlockRegionSet;
    195196    RegionSet m_workListRegionSet;
    196197
     
    324325inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<WeakBlock>()
    325326{
    326     return m_weakAndMarkStackRegionSet;
     327    return m_fourKBBlockRegionSet;
    327328}
    328329
     
    330331inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<MarkStackSegment>()
    331332{
    332     return m_weakAndMarkStackRegionSet;
     333    return m_fourKBBlockRegionSet;
    333334}
    334335
     
    340341
    341342template <>
     343inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HandleBlock>()
     344{
     345    return m_fourKBBlockRegionSet;
     346}
     347
     348template <>
    342349inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<CopiedBlock> >()
    343350{
     
    354361inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<WeakBlock> >()
    355362{
    356     return m_weakAndMarkStackRegionSet;
     363    return m_fourKBBlockRegionSet;
    357364}
    358365
     
    360367inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<MarkStackSegment> >()
    361368{
    362     return m_weakAndMarkStackRegionSet;
     369    return m_fourKBBlockRegionSet;
    363370}
    364371
     
    367374{
    368375    return m_workListRegionSet;
     376}
     377
     378template <>
     379inline BlockAllocator::RegionSet& BlockAllocator::regionSetFor<HeapBlock<HandleBlock> >()
     380{
     381    return m_fourKBBlockRegionSet;
    369382}
    370383
  • trunk/Source/JavaScriptCore/heap/HandleSet.cpp

    r140584 r146734  
    2727#include "HandleSet.h"
    2828
     29#include "HandleBlock.h"
     30#include "HandleBlockInlines.h"
    2931#include "HeapRootVisitor.h"
    3032#include "JSObject.h"
    3133#include "Operations.h"
     34#include <wtf/DataLog.h>
    3235
    3336namespace JSC {
     
    4043}
    4144
     45HandleSet::~HandleSet()
     46{
     47    while (!m_blockList.isEmpty())
     48        m_globalData->heap.blockAllocator().deallocate(HandleBlock::destroy(m_blockList.removeHead()));
     49}
     50
    4251void HandleSet::grow()
    4352{
    44     Node* block = m_blockStack.grow();
    45     for (int i = m_blockStack.blockLength - 1; i >= 0; --i) {
    46         Node* node = &block[i];
    47         new (NotNull, node) Node(this);
     53    HandleBlock* newBlock = HandleBlock::create(m_globalData->heap.blockAllocator().allocate<HandleBlock>(), this);
     54    m_blockList.append(newBlock);
     55
     56    for (int i = newBlock->nodeCapacity() - 1; i >= 0; --i) {
     57        Node* node = newBlock->nodeAtIndex(i);
     58        new (NotNull, node) Node;
    4859        m_freeList.push(node);
    4960    }
  • trunk/Source/JavaScriptCore/heap/HandleSet.h

    r140584 r146734  
    2727#define HandleSet_h
    2828
    29 #include <wtf/BlockStack.h>
    3029#include "Handle.h"
     30#include "HandleBlock.h"
     31#include <wtf/DoublyLinkedList.h>
    3132#include <wtf/HashCountedSet.h>
    3233#include <wtf/SentinelLinkedList.h>
     
    3536namespace JSC {
    3637
     38class HandleBlock;
    3739class HandleSet;
    3840class HeapRootVisitor;
     
    4143class SlotVisitor;
    4244
     45class HandleNode {
     46public:
     47    HandleNode(WTF::SentinelTag);
     48    HandleNode();
     49   
     50    HandleSlot slot();
     51    HandleSet* handleSet();
     52
     53    void setPrev(HandleNode*);
     54    HandleNode* prev();
     55
     56    void setNext(HandleNode*);
     57    HandleNode* next();
     58
     59private:
     60    JSValue m_value;
     61    HandleNode* m_prev;
     62    HandleNode* m_next;
     63};
     64
    4365class HandleSet {
     66    friend class HandleBlock;
    4467public:
    4568    static HandleSet* heapFor(HandleSlot);
    4669
    4770    HandleSet(JSGlobalData*);
    48    
     71    ~HandleSet();
     72
    4973    JSGlobalData* globalData();
    5074
     
    6185
    6286private:
    63     class Node {
    64     public:
    65         Node(WTF::SentinelTag);
    66         Node(HandleSet*);
    67        
    68         HandleSlot slot();
    69         HandleSet* handleSet();
    70 
    71         void setPrev(Node*);
    72         Node* prev();
    73 
    74         void setNext(Node*);
    75         Node* next();
    76 
    77     private:
    78         JSValue m_value;
    79         HandleSet* m_handleSet;
    80         Node* m_prev;
    81         Node* m_next;
    82     };
    83 
     87    typedef HandleNode Node;
    8488    static HandleSlot toHandle(Node*);
    8589    static Node* toNode(HandleSlot);
     
    9296
    9397    JSGlobalData* m_globalData;
    94     BlockStack<Node> m_blockStack;
     98    DoublyLinkedList<HandleBlock> m_blockList;
    9599
    96100    SentinelLinkedList<Node> m_strongList;
     
    110114}
    111115
    112 inline HandleSlot HandleSet::toHandle(Node* node)
     116inline HandleSlot HandleSet::toHandle(HandleSet::Node* node)
    113117{
    114118    return reinterpret_cast<HandleSlot>(node);
     
    117121inline HandleSet::Node* HandleSet::toNode(HandleSlot handle)
    118122{
    119     return reinterpret_cast<Node*>(handle);
     123    return reinterpret_cast<HandleSet::Node*>(handle);
    120124}
    121125
     
    129133        grow();
    130134
    131     Node* node = m_freeList.pop();
    132     new (NotNull, node) Node(this);
     135    HandleSet::Node* node = m_freeList.pop();
     136    new (NotNull, node) HandleSet::Node();
    133137    m_immediateList.push(node);
    134138    return toHandle(node);
     
    137141inline void HandleSet::deallocate(HandleSlot handle)
    138142{
    139     Node* node = toNode(handle);
     143    HandleSet::Node* node = toNode(handle);
    140144    if (node == m_nextToFinalize) {
    141145        ASSERT(m_nextToFinalize->next());
     
    143147    }
    144148
    145     SentinelLinkedList<Node>::remove(node);
     149    SentinelLinkedList<HandleSet::Node>::remove(node);
    146150    m_freeList.push(node);
    147151}
    148152
    149 inline HandleSet::Node::Node(HandleSet* handleSet)
    150     : m_handleSet(handleSet)
    151     , m_prev(0)
     153inline HandleNode::HandleNode()
     154    : m_prev(0)
    152155    , m_next(0)
    153156{
    154157}
    155158
    156 inline HandleSet::Node::Node(WTF::SentinelTag)
    157     : m_handleSet(0)
    158     , m_prev(0)
     159inline HandleNode::HandleNode(WTF::SentinelTag)
     160    : m_prev(0)
    159161    , m_next(0)
    160162{
    161163}
    162164
    163 inline HandleSlot HandleSet::Node::slot()
     165inline HandleSlot HandleNode::slot()
    164166{
    165167    return &m_value;
    166168}
    167169
    168 inline HandleSet* HandleSet::Node::handleSet()
    169 {
    170     return m_handleSet;
    171 }
    172 
    173 inline void HandleSet::Node::setPrev(Node* prev)
     170inline HandleSet* HandleNode::handleSet()
     171{
     172    return HandleBlock::blockFor(this)->handleSet();
     173}
     174
     175inline void HandleNode::setPrev(HandleNode* prev)
    174176{
    175177    m_prev = prev;
    176178}
    177179
    178 inline HandleSet::Node* HandleSet::Node::prev()
     180inline HandleNode* HandleNode::prev()
    179181{
    180182    return m_prev;
    181183}
    182184
    183 inline void HandleSet::Node::setNext(Node* next)
     185inline void HandleNode::setNext(HandleNode* next)
    184186{
    185187    m_next = next;
    186188}
    187189
    188 inline HandleSet::Node* HandleSet::Node::next()
     190inline HandleNode* HandleNode::next()
    189191{
    190192    return m_next;
     
    193195template<typename Functor> void HandleSet::forEachStrongHandle(Functor& functor, const HashCountedSet<JSCell*>& skipSet)
    194196{
    195     Node* end = m_strongList.end();
    196     for (Node* node = m_strongList.begin(); node != end; node = node->next()) {
     197    HandleSet::Node* end = m_strongList.end();
     198    for (HandleSet::Node* node = m_strongList.begin(); node != end; node = node->next()) {
    197199        JSValue value = *node->slot();
    198200        if (!value || !value.isCell())
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r141192 r146734  
    181181        friend class CopiedBlock;
    182182        friend class GCAwareJITStubRoutine;
     183        friend class HandleSet;
    183184        friend class JITStubRoutine;
    184185        friend class LLIntOffsetsExtractor;
Note: See TracChangeset for help on using the changeset viewer.