2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "MachineStackMarker.h"
26 #include "MarkedBlock.h"
27 #include "PageAllocationAligned.h"
28 #include <wtf/Bitmap.h>
29 #include <wtf/FixedArray.h>
30 #include <wtf/HashCountedSet.h>
31 #include <wtf/Noncopyable.h>
32 #include <wtf/Vector.h>
39 class LiveObjectIterator;
43 struct CollectorHeap {
46 PageAllocationAligned* blocks;
51 MarkedBlock* collectorBlock(size_t index) const
53 return static_cast<MarkedBlock*>(blocks[index].base());
58 WTF_MAKE_NONCOPYABLE(MarkedSpace);
60 static Heap* heap(JSCell*);
62 static bool isMarked(const JSCell*);
63 static bool testAndSetMarked(const JSCell*);
64 static void setMarked(const JSCell*);
66 MarkedSpace(JSGlobalData*);
69 JSGlobalData* globalData() { return m_globalData; }
71 void* allocate(size_t);
79 size_t capacity() const;
80 size_t objectCount() const;
82 bool contains(const void*);
84 LiveObjectIterator primaryHeapBegin();
85 LiveObjectIterator primaryHeapEnd();
88 bool containsSlowCase(const void*);
90 NEVER_INLINE MarkedBlock* allocateBlock();
91 NEVER_INLINE void freeBlock(size_t);
93 void growBlocks(size_t neededBlocks);
94 void shrinkBlocks(size_t neededBlocks);
96 void clearMarkBits(MarkedBlock*);
97 size_t markedCells(size_t startBlock = 0, size_t startCell = 0) const;
100 JSGlobalData* m_globalData;
103 inline Heap* MarkedSpace::heap(JSCell* cell)
105 return MarkedBlock::blockFor(cell)->heap;
108 inline bool MarkedSpace::isMarked(const JSCell* cell)
110 return MarkedBlock::blockFor(cell)->isMarked(cell);
113 inline bool MarkedSpace::testAndSetMarked(const JSCell* cell)
115 return MarkedBlock::blockFor(cell)->testAndSetMarked(cell);
118 inline void MarkedSpace::setMarked(const JSCell* cell)
120 MarkedBlock::blockFor(cell)->setMarked(cell);
123 inline bool MarkedSpace::contains(const void* x)
125 if (!MarkedBlock::isPossibleCell(x))
128 return containsSlowCase(x);
133 #endif // MarkedSpace_h