Add HeapInlines
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Mar 2014 02:37:51 +0000 (02:37 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Mar 2014 02:37:51 +0000 (02:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130759

Reviewed by Filip Pizlo.

* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* heap/Heap.cpp:
(JSC::MarkedBlockSnapshotFunctor::MarkedBlockSnapshotFunctor):
(JSC::MarkedBlockSnapshotFunctor::operator()):
* heap/Heap.h: Also reindented while we're here.
(JSC::Heap::writeBarrierBuffer):
(JSC::Heap::vm):
(JSC::Heap::objectSpace):
(JSC::Heap::machineThreads):
(JSC::Heap::operationInProgress):
(JSC::Heap::allocatorForObjectWithoutDestructor):
(JSC::Heap::allocatorForObjectWithNormalDestructor):
(JSC::Heap::allocatorForObjectWithImmortalStructureDestructor):
(JSC::Heap::storageAllocator):
(JSC::Heap::notifyIsSafeToCollect):
(JSC::Heap::isSafeToCollect):
(JSC::Heap::handleSet):
(JSC::Heap::handleStack):
(JSC::Heap::lastFullGCLength):
(JSC::Heap::lastEdenGCLength):
(JSC::Heap::increaseLastFullGCLength):
(JSC::Heap::sizeBeforeLastEdenCollection):
(JSC::Heap::sizeAfterLastEdenCollection):
(JSC::Heap::sizeBeforeLastFullCollection):
(JSC::Heap::sizeAfterLastFullCollection):
(JSC::Heap::jitStubRoutines):
(JSC::Heap::isDeferred):
(JSC::Heap::structureIDTable):
(JSC::Heap::removeCodeBlock):
* heap/HeapInlines.h: Added.
(JSC::Heap::shouldCollect):
(JSC::Heap::isBusy):
(JSC::Heap::isCollecting):
(JSC::Heap::heap):
(JSC::Heap::isLive):
(JSC::Heap::isInRememberedSet):
(JSC::Heap::isMarked):
(JSC::Heap::testAndSetMarked):
(JSC::Heap::setMarked):
(JSC::Heap::isWriteBarrierEnabled):
(JSC::Heap::writeBarrier):
(JSC::Heap::reportExtraMemoryCost):
(JSC::Heap::forEachProtectedCell):
(JSC::Heap::forEachCodeBlock):
(JSC::Heap::allocateWithNormalDestructor):
(JSC::Heap::allocateWithImmortalStructureDestructor):
(JSC::Heap::allocateWithoutDestructor):
(JSC::Heap::tryAllocateStorage):
(JSC::Heap::tryReallocateStorage):
(JSC::Heap::ascribeOwner):
(JSC::Heap::blockAllocator):
(JSC::Heap::releaseSoon):
(JSC::Heap::incrementDeferralDepth):
(JSC::Heap::decrementDeferralDepth):
(JSC::Heap::collectIfNecessaryOrDefer):
(JSC::Heap::decrementDeferralDepthAndGCIfNeeded):
(JSC::Heap::markListSet):
* runtime/JSCInlines.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166278 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/HeapInlines.h [new file with mode: 0644]
Source/JavaScriptCore/llint/LLIntEntrypoint.cpp
Source/JavaScriptCore/runtime/JSCInlines.h
Source/JavaScriptCore/runtime/JSObject.h

index 1bc14e6..27fba11 100644 (file)
@@ -1,3 +1,72 @@
+2014-03-25  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        Add HeapInlines
+        https://bugs.webkit.org/show_bug.cgi?id=130759
+
+        Reviewed by Filip Pizlo.
+
+        * GNUmakefile.list.am:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * heap/Heap.cpp:
+        (JSC::MarkedBlockSnapshotFunctor::MarkedBlockSnapshotFunctor):
+        (JSC::MarkedBlockSnapshotFunctor::operator()):
+        * heap/Heap.h: Also reindented while we're here.
+        (JSC::Heap::writeBarrierBuffer):
+        (JSC::Heap::vm):
+        (JSC::Heap::objectSpace):
+        (JSC::Heap::machineThreads):
+        (JSC::Heap::operationInProgress):
+        (JSC::Heap::allocatorForObjectWithoutDestructor):
+        (JSC::Heap::allocatorForObjectWithNormalDestructor):
+        (JSC::Heap::allocatorForObjectWithImmortalStructureDestructor):
+        (JSC::Heap::storageAllocator):
+        (JSC::Heap::notifyIsSafeToCollect):
+        (JSC::Heap::isSafeToCollect):
+        (JSC::Heap::handleSet):
+        (JSC::Heap::handleStack):
+        (JSC::Heap::lastFullGCLength):
+        (JSC::Heap::lastEdenGCLength):
+        (JSC::Heap::increaseLastFullGCLength):
+        (JSC::Heap::sizeBeforeLastEdenCollection):
+        (JSC::Heap::sizeAfterLastEdenCollection):
+        (JSC::Heap::sizeBeforeLastFullCollection):
+        (JSC::Heap::sizeAfterLastFullCollection):
+        (JSC::Heap::jitStubRoutines):
+        (JSC::Heap::isDeferred):
+        (JSC::Heap::structureIDTable):
+        (JSC::Heap::removeCodeBlock):
+        * heap/HeapInlines.h: Added.
+        (JSC::Heap::shouldCollect):
+        (JSC::Heap::isBusy):
+        (JSC::Heap::isCollecting):
+        (JSC::Heap::heap):
+        (JSC::Heap::isLive):
+        (JSC::Heap::isInRememberedSet):
+        (JSC::Heap::isMarked):
+        (JSC::Heap::testAndSetMarked):
+        (JSC::Heap::setMarked):
+        (JSC::Heap::isWriteBarrierEnabled):
+        (JSC::Heap::writeBarrier):
+        (JSC::Heap::reportExtraMemoryCost):
+        (JSC::Heap::forEachProtectedCell):
+        (JSC::Heap::forEachCodeBlock):
+        (JSC::Heap::allocateWithNormalDestructor):
+        (JSC::Heap::allocateWithImmortalStructureDestructor):
+        (JSC::Heap::allocateWithoutDestructor):
+        (JSC::Heap::tryAllocateStorage):
+        (JSC::Heap::tryReallocateStorage):
+        (JSC::Heap::ascribeOwner):
+        (JSC::Heap::blockAllocator):
+        (JSC::Heap::releaseSoon):
+        (JSC::Heap::incrementDeferralDepth):
+        (JSC::Heap::decrementDeferralDepth):
+        (JSC::Heap::collectIfNecessaryOrDefer):
+        (JSC::Heap::decrementDeferralDepthAndGCIfNeeded):
+        (JSC::Heap::markListSet):
+        * runtime/JSCInlines.h:
+
 2014-03-25  Filip Pizlo  <fpizlo@apple.com>
 
         DFG::ByteCodeParser::SetMode should distinguish between setting immediately without a flush and setting immediately with a flush
index 4c71330..815fd26 100644 (file)
@@ -594,6 +594,7 @@ javascriptcore_sources += \
        Source/JavaScriptCore/heap/GCThread.h \
        Source/JavaScriptCore/heap/Heap.cpp \
        Source/JavaScriptCore/heap/Heap.h \
+       Source/JavaScriptCore/heap/HeapInlines.h \
        Source/JavaScriptCore/heap/HeapIterationScope.h \
        Source/JavaScriptCore/heap/HeapOperation.h \
        Source/JavaScriptCore/heap/HeapStatistics.cpp \
index da1938a..294b148 100644 (file)
     <ClInclude Include="..\heap\HandleTypes.h" />
     <ClInclude Include="..\heap\Heap.h" />
     <ClInclude Include="..\heap\HeapBlock.h" />
+    <ClInclude Include="..\heap\HeapInlines.h" />
     <ClInclude Include="..\heap\HeapOperation.h" />
     <ClInclude Include="..\heap\HeapRootVisitor.h" />
     <ClInclude Include="..\heap\HeapStatistics.h" />
index 3a8168e..de167e7 100644 (file)
     <ClInclude Include="..\heap\HeapBlock.h">
       <Filter>heap</Filter>
     </ClInclude>
+    <ClInclude Include="..\heap\HeapInlines.h">
+      <Filter>heap</Filter>
+    </ClInclude>
     <ClInclude Include="..\heap\HeapOperation.h">
       <Filter>heap</Filter>
     </ClInclude>
index f18dd82..c3006c1 100644 (file)
                C2C8D03114A3CEFC00578E65 /* HeapBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = C2C8D02F14A3CEFC00578E65 /* HeapBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2CF39C116E15A8100DD69BE /* JSAPIWrapperObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = C2CF39BF16E15A8100DD69BE /* JSAPIWrapperObject.mm */; };
                C2CF39C216E15A8100DD69BE /* JSAPIWrapperObject.h in Headers */ = {isa = PBXBuildFile; fileRef = C2CF39C016E15A8100DD69BE /* JSAPIWrapperObject.h */; };
+               C2DA778318E259990066FCB6 /* HeapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = C2DA778218E259990066FCB6 /* HeapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2DF442F1707AC0100A5CA96 /* SuperRegion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2DF442D1707AC0100A5CA96 /* SuperRegion.cpp */; };
                C2DF44301707AC0100A5CA96 /* SuperRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = C2DF442E1707AC0100A5CA96 /* SuperRegion.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2E526BD1590EF000054E48D /* HeapTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2E526BB1590EF000054E48D /* HeapTimer.cpp */; };
                C2C8D02F14A3CEFC00578E65 /* HeapBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapBlock.h; sourceTree = "<group>"; };
                C2CF39BF16E15A8100DD69BE /* JSAPIWrapperObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JSAPIWrapperObject.mm; sourceTree = "<group>"; };
                C2CF39C016E15A8100DD69BE /* JSAPIWrapperObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAPIWrapperObject.h; sourceTree = "<group>"; };
+               C2DA778218E259990066FCB6 /* HeapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapInlines.h; sourceTree = "<group>"; };
                C2DF442D1707AC0100A5CA96 /* SuperRegion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SuperRegion.cpp; sourceTree = "<group>"; };
                C2DF442E1707AC0100A5CA96 /* SuperRegion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuperRegion.h; sourceTree = "<group>"; };
                C2E526BB1590EF000054E48D /* HeapTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HeapTimer.cpp; sourceTree = "<group>"; };
                142E312A134FF0A600AFADB5 /* heap */ = {
                        isa = PBXGroup;
                        children = (
+                               C2DA778218E259990066FCB6 /* HeapInlines.h */,
                                ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */,
                                2AACE63A18CA5A0300ED0191 /* GCActivityCallback.cpp */,
                                2AACE63B18CA5A0300ED0191 /* GCActivityCallback.h */,
                                A1A009C11831A26E00CF8711 /* ARM64Assembler.h in Headers */,
                                86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
                                A584032018BFFBE1005A0811 /* InspectorAgent.h in Headers */,
+                               C2DA778318E259990066FCB6 /* HeapInlines.h in Headers */,
                                2AACE63D18CA5A0300ED0191 /* GCActivityCallback.h in Headers */,
                                2A83638618D7D0EE0000EBCC /* EdenGCActivityCallback.h in Headers */,
                                2A83638A18D7D0FE0000EBCC /* FullGCActivityCallback.h in Headers */,
index eab9782..273c52c 100644 (file)
@@ -1016,6 +1016,19 @@ void Heap::sweepArrayBuffers()
     m_arrayBuffers.sweep();
 }
 
+struct MarkedBlockSnapshotFunctor : public MarkedBlock::VoidFunctor {
+    MarkedBlockSnapshotFunctor(Vector<MarkedBlock*>& blocks) 
+        : m_index(0) 
+        , m_blocks(blocks)
+    {
+    }
+
+    void operator()(MarkedBlock* block) { m_blocks[m_index++] = block; }
+
+    size_t m_index;
+    Vector<MarkedBlock*>& m_blocks;
+};
+
 void Heap::snapshotMarkedSpace()
 {
     GCPHASE(SnapshotMarkedSpace);
index e8a9a03..cfad987 100644 (file)
 
 namespace JSC {
 
-    class CopiedSpace;
-    class CodeBlock;
-    class ExecutableBase;
-    class EdenGCActivityCallback;
-    class FullGCActivityCallback;
-    class GCActivityCallback;
-    class GCAwareJITStubRoutine;
-    class GlobalCodeBlock;
-    class Heap;
-    class HeapRootVisitor;
-    class IncrementalSweeper;
-    class JITStubRoutine;
-    class JSCell;
-    class VM;
-    class JSStack;
-    class JSValue;
-    class LiveObjectIterator;
-    class LLIntOffsetsExtractor;
-    class MarkedArgumentBuffer;
-    class WeakGCHandlePool;
-    class SlotVisitor;
-
-    typedef std::pair<JSValue, WTF::String> ValueStringPair;
-    typedef HashCountedSet<JSCell*> ProtectCountSet;
-    typedef HashCountedSet<const char*> TypeCountSet;
-
-    enum HeapType { SmallHeap, LargeHeap };
-
-    class Heap {
-        WTF_MAKE_NONCOPYABLE(Heap);
-    public:
-        friend class JIT;
-        friend class DFG::SpeculativeJIT;
-        friend class GCThreadSharedData;
-        static Heap* heap(const JSValue); // 0 for immediate values
-        static Heap* heap(const JSCell*);
-
-        // This constant determines how many blocks we iterate between checks of our 
-        // deadline when calling Heap::isPagedOut. Decreasing it will cause us to detect 
-        // overstepping our deadline more quickly, while increasing it will cause 
-        // our scan to run faster. 
-        static const unsigned s_timeCheckResolution = 16;
-
-        static bool isLive(const void*);
-        static bool isMarked(const void*);
-        static bool testAndSetMarked(const void*);
-        static void setMarked(const void*);
-
-        JS_EXPORT_PRIVATE void addToRememberedSet(const JSCell*);
-        bool isInRememberedSet(const JSCell* cell) const
-        {
-            ASSERT(cell);
-            ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread());
-            return MarkedBlock::blockFor(cell)->isRemembered(cell);
-        }
-        static bool isWriteBarrierEnabled();
-        JS_EXPORT_PRIVATE void writeBarrier(const JSCell*);
-        void writeBarrier(const JSCell*, JSValue);
-        void writeBarrier(const JSCell*, JSCell*);
-
-        WriteBarrierBuffer& writeBarrierBuffer() { return m_writeBarrierBuffer; }
-        void flushWriteBarrierBuffer(JSCell*);
-
-        Heap(VM*, HeapType);
-        ~Heap();
-        JS_EXPORT_PRIVATE void lastChanceToFinalize();
-
-        VM* vm() const { return m_vm; }
-        MarkedSpace& objectSpace() { return m_objectSpace; }
-        MachineThreads& machineThreads() { return m_machineThreads; }
-
-        JS_EXPORT_PRIVATE GCActivityCallback* fullActivityCallback();
-        JS_EXPORT_PRIVATE GCActivityCallback* edenActivityCallback();
-        JS_EXPORT_PRIVATE void setFullActivityCallback(PassRefPtr<FullGCActivityCallback>);
-        JS_EXPORT_PRIVATE void setEdenActivityCallback(PassRefPtr<EdenGCActivityCallback>);
-        JS_EXPORT_PRIVATE void setGarbageCollectionTimerEnabled(bool);
-
-        JS_EXPORT_PRIVATE IncrementalSweeper* sweeper();
-        JS_EXPORT_PRIVATE void setIncrementalSweeper(PassOwnPtr<IncrementalSweeper>);
-
-        // true if collection is in progress
-        inline bool isCollecting();
-        inline HeapOperation operationInProgress() { return m_operationInProgress; }
-        // true if an allocation or collection is in progress
-        inline bool isBusy();
-        
-        MarkedAllocator& allocatorForObjectWithoutDestructor(size_t bytes) { return m_objectSpace.allocatorFor(bytes); }
-        MarkedAllocator& allocatorForObjectWithNormalDestructor(size_t bytes) { return m_objectSpace.normalDestructorAllocatorFor(bytes); }
-        MarkedAllocator& allocatorForObjectWithImmortalStructureDestructor(size_t bytes) { return m_objectSpace.immortalStructureDestructorAllocatorFor(bytes); }
-        CopiedAllocator& storageAllocator() { return m_storageSpace.allocator(); }
-        CheckedBoolean tryAllocateStorage(JSCell* intendedOwner, size_t, void**);
-        CheckedBoolean tryReallocateStorage(JSCell* intendedOwner, void**, size_t, size_t);
-        void ascribeOwner(JSCell* intendedOwner, void*);
-
-        typedef void (*Finalizer)(JSCell*);
-        JS_EXPORT_PRIVATE void addFinalizer(JSCell*, Finalizer);
-        void addCompiledCode(ExecutableBase*);
-
-        void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
-        bool isSafeToCollect() const { return m_isSafeToCollect; }
-
-        JS_EXPORT_PRIVATE void collectAllGarbage();
-        bool shouldCollect();
-        JS_EXPORT_PRIVATE void collect(HeapOperation collectionType = AnyCollection);
-        bool collectIfNecessaryOrDefer(); // Returns true if it did collect.
-
-        void reportExtraMemoryCost(size_t cost);
-        JS_EXPORT_PRIVATE void reportAbandonedObjectGraph();
-
-        JS_EXPORT_PRIVATE void protect(JSValue);
-        JS_EXPORT_PRIVATE bool unprotect(JSValue); // True when the protect count drops to 0.
-        
-        size_t extraSize(); // extra memory usage outside of pages allocated by the heap
-        JS_EXPORT_PRIVATE size_t size();
-        JS_EXPORT_PRIVATE size_t capacity();
-        JS_EXPORT_PRIVATE size_t objectCount();
-        JS_EXPORT_PRIVATE size_t globalObjectCount();
-        JS_EXPORT_PRIVATE size_t protectedObjectCount();
-        JS_EXPORT_PRIVATE size_t protectedGlobalObjectCount();
-        JS_EXPORT_PRIVATE PassOwnPtr<TypeCountSet> protectedObjectTypeCounts();
-        JS_EXPORT_PRIVATE PassOwnPtr<TypeCountSet> objectTypeCounts();
-        void showStatistics();
-
-        void pushTempSortVector(Vector<ValueStringPair, 0, UnsafeVectorOverflow>*);
-        void popTempSortVector(Vector<ValueStringPair, 0, UnsafeVectorOverflow>*);
+class CopiedSpace;
+class CodeBlock;
+class ExecutableBase;
+class EdenGCActivityCallback;
+class FullGCActivityCallback;
+class GCActivityCallback;
+class GCAwareJITStubRoutine;
+class GlobalCodeBlock;
+class Heap;
+class HeapRootVisitor;
+class IncrementalSweeper;
+class JITStubRoutine;
+class JSCell;
+class VM;
+class JSStack;
+class JSValue;
+class LiveObjectIterator;
+class LLIntOffsetsExtractor;
+class MarkedArgumentBuffer;
+class WeakGCHandlePool;
+class SlotVisitor;
+
+typedef std::pair<JSValue, WTF::String> ValueStringPair;
+typedef HashCountedSet<JSCell*> ProtectCountSet;
+typedef HashCountedSet<const char*> TypeCountSet;
+
+enum HeapType { SmallHeap, LargeHeap };
+
+class Heap {
+    WTF_MAKE_NONCOPYABLE(Heap);
+public:
+    friend class JIT;
+    friend class DFG::SpeculativeJIT;
+    friend class GCThreadSharedData;
+    static Heap* heap(const JSValue); // 0 for immediate values
+    static Heap* heap(const JSCell*);
+
+    // This constant determines how many blocks we iterate between checks of our 
+    // deadline when calling Heap::isPagedOut. Decreasing it will cause us to detect 
+    // overstepping our deadline more quickly, while increasing it will cause 
+    // our scan to run faster. 
+    static const unsigned s_timeCheckResolution = 16;
+
+    static bool isLive(const void*);
+    static bool isMarked(const void*);
+    static bool testAndSetMarked(const void*);
+    static void setMarked(const void*);
+    static bool isRemembered(const void*);
+
+    JS_EXPORT_PRIVATE void addToRememberedSet(const JSCell*);
+    bool isInRememberedSet(const JSCell*) const;
+    static bool isWriteBarrierEnabled();
+    JS_EXPORT_PRIVATE void writeBarrier(const JSCell*);
+    void writeBarrier(const JSCell*, JSValue);
+    void writeBarrier(const JSCell*, JSCell*);
+
+    WriteBarrierBuffer& writeBarrierBuffer() { return m_writeBarrierBuffer; }
+    void flushWriteBarrierBuffer(JSCell*);
+
+    Heap(VM*, HeapType);
+    ~Heap();
+    JS_EXPORT_PRIVATE void lastChanceToFinalize();
+
+    VM* vm() const { return m_vm; }
+    MarkedSpace& objectSpace() { return m_objectSpace; }
+    MachineThreads& machineThreads() { return m_machineThreads; }
+
+    JS_EXPORT_PRIVATE GCActivityCallback* fullActivityCallback();
+    JS_EXPORT_PRIVATE GCActivityCallback* edenActivityCallback();
+    JS_EXPORT_PRIVATE void setFullActivityCallback(PassRefPtr<FullGCActivityCallback>);
+    JS_EXPORT_PRIVATE void setEdenActivityCallback(PassRefPtr<EdenGCActivityCallback>);
+    JS_EXPORT_PRIVATE void setGarbageCollectionTimerEnabled(bool);
+
+    JS_EXPORT_PRIVATE IncrementalSweeper* sweeper();
+    JS_EXPORT_PRIVATE void setIncrementalSweeper(PassOwnPtr<IncrementalSweeper>);
+
+    // true if collection is in progress
+    bool isCollecting();
+    HeapOperation operationInProgress() { return m_operationInProgress; }
+    // true if an allocation or collection is in progress
+    bool isBusy();
     
-        HashSet<MarkedArgumentBuffer*>& markListSet() { if (!m_markListSet) m_markListSet = adoptPtr(new HashSet<MarkedArgumentBuffer*>); return *m_markListSet; }
-        
-        template<typename Functor> typename Functor::ReturnType forEachProtectedCell(Functor&);
-        template<typename Functor> typename Functor::ReturnType forEachProtectedCell();
-        template<typename Functor> inline void forEachCodeBlock(Functor&);
+    MarkedAllocator& allocatorForObjectWithoutDestructor(size_t bytes) { return m_objectSpace.allocatorFor(bytes); }
+    MarkedAllocator& allocatorForObjectWithNormalDestructor(size_t bytes) { return m_objectSpace.normalDestructorAllocatorFor(bytes); }
+    MarkedAllocator& allocatorForObjectWithImmortalStructureDestructor(size_t bytes) { return m_objectSpace.immortalStructureDestructorAllocatorFor(bytes); }
+    CopiedAllocator& storageAllocator() { return m_storageSpace.allocator(); }
+    CheckedBoolean tryAllocateStorage(JSCell* intendedOwner, size_t, void**);
+    CheckedBoolean tryReallocateStorage(JSCell* intendedOwner, void**, size_t, size_t);
+    void ascribeOwner(JSCell* intendedOwner, void*);
+
+    typedef void (*Finalizer)(JSCell*);
+    JS_EXPORT_PRIVATE void addFinalizer(JSCell*, Finalizer);
+    void addCompiledCode(ExecutableBase*);
+
+    void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
+    bool isSafeToCollect() const { return m_isSafeToCollect; }
+
+    JS_EXPORT_PRIVATE void collectAllGarbage();
+    bool shouldCollect();
+    JS_EXPORT_PRIVATE void collect(HeapOperation collectionType = AnyCollection);
+    bool collectIfNecessaryOrDefer(); // Returns true if it did collect.
+
+    void reportExtraMemoryCost(size_t cost);
+    JS_EXPORT_PRIVATE void reportAbandonedObjectGraph();
+
+    JS_EXPORT_PRIVATE void protect(JSValue);
+    JS_EXPORT_PRIVATE bool unprotect(JSValue); // True when the protect count drops to 0.
+    
+    size_t extraSize(); // extra memory usage outside of pages allocated by the heap
+    JS_EXPORT_PRIVATE size_t size();
+    JS_EXPORT_PRIVATE size_t capacity();
+    JS_EXPORT_PRIVATE size_t objectCount();
+    JS_EXPORT_PRIVATE size_t globalObjectCount();
+    JS_EXPORT_PRIVATE size_t protectedObjectCount();
+    JS_EXPORT_PRIVATE size_t protectedGlobalObjectCount();
+    JS_EXPORT_PRIVATE PassOwnPtr<TypeCountSet> protectedObjectTypeCounts();
+    JS_EXPORT_PRIVATE PassOwnPtr<TypeCountSet> objectTypeCounts();
+    void showStatistics();
+
+    void pushTempSortVector(Vector<ValueStringPair, 0, UnsafeVectorOverflow>*);
+    void popTempSortVector(Vector<ValueStringPair, 0, UnsafeVectorOverflow>*);
+
+    HashSet<MarkedArgumentBuffer*>& markListSet();
+    
+    template<typename Functor> typename Functor::ReturnType forEachProtectedCell(Functor&);
+    template<typename Functor> typename Functor::ReturnType forEachProtectedCell();
+    template<typename Functor> void forEachCodeBlock(Functor&);
 
-        HandleSet* handleSet() { return &m_handleSet; }
-        HandleStack* handleStack() { return &m_handleStack; }
+    HandleSet* handleSet() { return &m_handleSet; }
+    HandleStack* handleStack() { return &m_handleStack; }
 
-        void willStartIterating();
-        void didFinishIterating();
-        void getConservativeRegisterRoots(HashSet<JSCell*>& roots);
+    void willStartIterating();
+    void didFinishIterating();
+    void getConservativeRegisterRoots(HashSet<JSCell*>& roots);
 
-        double lastFullGCLength() const { return m_lastFullGCLength; }
-        double lastEdenGCLength() const { return m_lastEdenGCLength; }
-        void increaseLastFullGCLength(double amount) { m_lastFullGCLength += amount; }
+    double lastFullGCLength() const { return m_lastFullGCLength; }
+    double lastEdenGCLength() const { return m_lastEdenGCLength; }
+    void increaseLastFullGCLength(double amount) { m_lastFullGCLength += amount; }
 
-        size_t sizeBeforeLastEdenCollection() const { return m_sizeBeforeLastEdenCollect; }
-        size_t sizeAfterLastEdenCollection() const { return m_sizeAfterLastEdenCollect; }
-        size_t sizeBeforeLastFullCollection() const { return m_sizeBeforeLastFullCollect; }
-        size_t sizeAfterLastFullCollection() const { return m_sizeAfterLastFullCollect; }
+    size_t sizeBeforeLastEdenCollection() const { return m_sizeBeforeLastEdenCollect; }
+    size_t sizeAfterLastEdenCollection() const { return m_sizeAfterLastEdenCollect; }
+    size_t sizeBeforeLastFullCollection() const { return m_sizeBeforeLastFullCollect; }
+    size_t sizeAfterLastFullCollection() const { return m_sizeAfterLastFullCollect; }
 
-        JS_EXPORT_PRIVATE void deleteAllCompiledCode();
-        void deleteAllUnlinkedFunctionCode();
+    JS_EXPORT_PRIVATE void deleteAllCompiledCode();
+    void deleteAllUnlinkedFunctionCode();
 
-        void didAllocate(size_t);
-        void didAbandon(size_t);
+    void didAllocate(size_t);
+    void didAbandon(size_t);
 
-        bool isPagedOut(double deadline);
-        
-        const JITStubRoutineSet& jitStubRoutines() { return m_jitStubRoutines; }
-        
-        void addReference(JSCell*, ArrayBuffer*);
-        
-        bool isDeferred() const { return !!m_deferralDepth || Options::disableGC(); }
+    bool isPagedOut(double deadline);
+    
+    const JITStubRoutineSet& jitStubRoutines() { return m_jitStubRoutines; }
+    
+    void addReference(JSCell*, ArrayBuffer*);
+    
+    bool isDeferred() const { return !!m_deferralDepth || Options::disableGC(); }
 
-        BlockAllocator& blockAllocator();
-        StructureIDTable& structureIDTable() { return m_structureIDTable; }
+    BlockAllocator& blockAllocator();
+    StructureIDTable& structureIDTable() { return m_structureIDTable; }
 
 #if USE(CF)
         template<typename T> void releaseSoon(RetainPtr<T>&&);
 #endif
 
-        void removeCodeBlock(CodeBlock* cb) { m_codeBlocks.remove(cb); }
-
-    private:
-        friend class CodeBlock;
-        friend class CopiedBlock;
-        friend class DeferGC;
-        friend class DeferGCForAWhile;
-        friend class DelayedReleaseScope;
-        friend class GCAwareJITStubRoutine;
-        friend class HandleSet;
-        friend class JITStubRoutine;
-        friend class LLIntOffsetsExtractor;
-        friend class MarkedSpace;
-        friend class MarkedAllocator;
-        friend class MarkedBlock;
-        friend class CopiedSpace;
-        friend class CopyVisitor;
-        friend class RecursiveAllocationScope;
-        friend class SlotVisitor;
-        friend class SuperRegion;
-        friend class IncrementalSweeper;
-        friend class HeapStatistics;
-        friend class VM;
-        friend class WeakSet;
-        template<typename T> friend void* allocateCell(Heap&);
-        template<typename T> friend void* allocateCell(Heap&, size_t);
-
-        void* allocateWithImmortalStructureDestructor(size_t); // For use with special objects whose Structures never die.
-        void* allocateWithNormalDestructor(size_t); // For use with objects that inherit directly or indirectly from JSDestructibleObject.
-        void* allocateWithoutDestructor(size_t); // For use with objects without destructors.
-
-        static const size_t minExtraCost = 256;
-        static const size_t maxExtraCost = 1024 * 1024;
-        
-        class FinalizerOwner : public WeakHandleOwner {
-            virtual void finalize(Handle<Unknown>, void* context) override;
-        };
-
-        JS_EXPORT_PRIVATE bool isValidAllocation(size_t);
-        JS_EXPORT_PRIVATE void reportExtraMemoryCostSlowCase(size_t);
-
-        void suspendCompilerThreads();
-        void willStartCollection(HeapOperation collectionType);
-        void deleteOldCode(double gcStartTime);
-        void flushOldStructureIDTables();
-        void flushWriteBarrierBuffer();
-        void stopAllocation();
-
-        void markRoots();
-        void gatherStackRoots(ConservativeRoots&, void** dummy);
-        void gatherJSStackRoots(ConservativeRoots&);
-        void gatherScratchBufferRoots(ConservativeRoots&);
-        void clearLivenessData();
-        void visitSmallStrings();
-        void visitConservativeRoots(ConservativeRoots&);
-        void visitCompilerWorklists();
-        void visitProtectedObjects(HeapRootVisitor&);
-        void visitTempSortVectors(HeapRootVisitor&);
-        void visitArgumentBuffers(HeapRootVisitor&);
-        void visitException(HeapRootVisitor&);
-        void visitStrongHandles(HeapRootVisitor&);
-        void visitHandleStack(HeapRootVisitor&);
-        void traceCodeBlocksAndJITStubRoutines();
-        void converge();
-        void visitWeakHandles(HeapRootVisitor&);
-        void clearRememberedSet(Vector<const JSCell*>&);
-        void updateObjectCounts();
-        void resetVisitors();
-
-        void reapWeakHandles();
-        void sweepArrayBuffers();
-        void snapshotMarkedSpace();
-        void deleteSourceProviderCaches();
-        void notifyIncrementalSweeper();
-        void rememberCurrentlyExecutingCodeBlocks();
-        void resetAllocators();
-        void copyBackingStores();
-        void harvestWeakReferences();
-        void finalizeUnconditionalFinalizers();
-        void deleteUnmarkedCompiledCode();
-        void updateAllocationLimits();
-        void didFinishCollection(double gcStartTime);
-        void resumeCompilerThreads();
-        void zombifyDeadObjects();
-        void markDeadObjects();
-
-        bool shouldDoFullCollection(HeapOperation requestedCollectionType) const;
-        size_t sizeAfterCollect();
-
-        JSStack& stack();
-        
-        void incrementDeferralDepth();
-        void decrementDeferralDepth();
-        void decrementDeferralDepthAndGCIfNeeded();
-
-        const HeapType m_heapType;
-        const size_t m_ramSize;
-        const size_t m_minBytesPerCycle;
-        size_t m_sizeAfterLastCollect;
-        size_t m_sizeAfterLastFullCollect;
-        size_t m_sizeBeforeLastFullCollect;
-        size_t m_sizeAfterLastEdenCollect;
-        size_t m_sizeBeforeLastEdenCollect;
-
-        size_t m_bytesAllocatedThisCycle;
-        size_t m_bytesAbandonedSinceLastFullCollect;
-        size_t m_maxEdenSize;
-        size_t m_maxHeapSize;
-        bool m_shouldDoFullCollection;
-        size_t m_totalBytesVisited;
-        size_t m_totalBytesCopied;
-        
-        HeapOperation m_operationInProgress;
-        BlockAllocator m_blockAllocator;
-        StructureIDTable m_structureIDTable;
-        MarkedSpace m_objectSpace;
-        CopiedSpace m_storageSpace;
-        GCIncomingRefCountedSet<ArrayBuffer> m_arrayBuffers;
-        size_t m_extraMemoryUsage;
-
-        HashSet<const JSCell*> m_copyingRememberedSet;
-
-        ProtectCountSet m_protectedValues;
-        Vector<Vector<ValueStringPair, 0, UnsafeVectorOverflow>*> m_tempSortingVectors;
-        OwnPtr<HashSet<MarkedArgumentBuffer*>> m_markListSet;
-
-        MachineThreads m_machineThreads;
-        
-        GCThreadSharedData m_sharedData;
-        SlotVisitor m_slotVisitor;
-        CopyVisitor m_copyVisitor;
-
-        HandleSet m_handleSet;
-        HandleStack m_handleStack;
-        CodeBlockSet m_codeBlocks;
-        JITStubRoutineSet m_jitStubRoutines;
-        FinalizerOwner m_finalizerOwner;
-        
-        bool m_isSafeToCollect;
-
-        WriteBarrierBuffer m_writeBarrierBuffer;
-
-        VM* m_vm;
-        double m_lastFullGCLength;
-        double m_lastEdenGCLength;
-        double m_lastCodeDiscardTime;
-
-        DoublyLinkedList<ExecutableBase> m_compiledCode;
-        
-        RefPtr<GCActivityCallback> m_fullActivityCallback;
-        RefPtr<GCActivityCallback> m_edenActivityCallback;
-        OwnPtr<IncrementalSweeper> m_sweeper;
-        Vector<MarkedBlock*> m_blockSnapshot;
-        
-        unsigned m_deferralDepth;
-    };
-
-    struct MarkedBlockSnapshotFunctor : public MarkedBlock::VoidFunctor {
-        MarkedBlockSnapshotFunctor(Vector<MarkedBlock*>& blocks) 
-            : m_index(0) 
-            , m_blocks(blocks)
-        {
-        }
+    void removeCodeBlock(CodeBlock* cb) { m_codeBlocks.remove(cb); }
+
+private:
+    friend class CodeBlock;
+    friend class CopiedBlock;
+    friend class DeferGC;
+    friend class DeferGCForAWhile;
+    friend class DelayedReleaseScope;
+    friend class GCAwareJITStubRoutine;
+    friend class HandleSet;
+    friend class JITStubRoutine;
+    friend class LLIntOffsetsExtractor;
+    friend class MarkedSpace;
+    friend class MarkedAllocator;
+    friend class MarkedBlock;
+    friend class CopiedSpace;
+    friend class CopyVisitor;
+    friend class RecursiveAllocationScope;
+    friend class SlotVisitor;
+    friend class SuperRegion;
+    friend class IncrementalSweeper;
+    friend class HeapStatistics;
+    friend class VM;
+    friend class WeakSet;
+    template<typename T> friend void* allocateCell(Heap&);
+    template<typename T> friend void* allocateCell(Heap&, size_t);
+
+    void* allocateWithImmortalStructureDestructor(size_t); // For use with special objects whose Structures never die.
+    void* allocateWithNormalDestructor(size_t); // For use with objects that inherit directly or indirectly from JSDestructibleObject.
+    void* allocateWithoutDestructor(size_t); // For use with objects without destructors.
+
+    static const size_t minExtraCost = 256;
+    static const size_t maxExtraCost = 1024 * 1024;
     
-        void operator()(MarkedBlock* block) { m_blocks[m_index++] = block; }
-    
-        size_t m_index;
-        Vector<MarkedBlock*>& m_blocks;
+    class FinalizerOwner : public WeakHandleOwner {
+        virtual void finalize(Handle<Unknown>, void* context) override;
     };
 
-    inline bool Heap::shouldCollect()
-    {
-        if (isDeferred())
-            return false;
-        if (Options::gcMaxHeapSize())
-            return m_bytesAllocatedThisCycle > Options::gcMaxHeapSize() && m_isSafeToCollect && m_operationInProgress == NoOperation;
-        return m_bytesAllocatedThisCycle > m_maxEdenSize && m_isSafeToCollect && m_operationInProgress == NoOperation;
-    }
-
-    bool Heap::isBusy()
-    {
-        return m_operationInProgress != NoOperation;
-    }
-
-    bool Heap::isCollecting()
-    {
-        return m_operationInProgress == FullCollection || m_operationInProgress == EdenCollection;
-    }
-
-    inline Heap* Heap::heap(const JSCell* cell)
-    {
-        return MarkedBlock::blockFor(cell)->heap();
-    }
-
-    inline Heap* Heap::heap(const JSValue v)
-    {
-        if (!v.isCell())
-            return 0;
-        return heap(v.asCell());
-    }
-
-    inline bool Heap::isLive(const void* cell)
-    {
-        return MarkedBlock::blockFor(cell)->isLiveCell(cell);
-    }
-
-    inline bool Heap::isMarked(const void* cell)
-    {
-        return MarkedBlock::blockFor(cell)->isMarked(cell);
-    }
-
-    inline bool Heap::testAndSetMarked(const void* cell)
-    {
-        return MarkedBlock::blockFor(cell)->testAndSetMarked(cell);
-    }
-
-    inline void Heap::setMarked(const void* cell)
-    {
-        MarkedBlock::blockFor(cell)->setMarked(cell);
-    }
-
-    inline bool Heap::isWriteBarrierEnabled()
-    {
-#if ENABLE(WRITE_BARRIER_PROFILING) || ENABLE(GGC)
-        return true;
-#else
-        return false;
-#endif
-    }
-
-    inline void Heap::writeBarrier(const JSCell* from, JSValue to)
-    {
-#if ENABLE(WRITE_BARRIER_PROFILING)
-        WriteBarrierCounters::countWriteBarrier();
-#endif
-        if (!to.isCell())
-            return;
-        writeBarrier(from, to.asCell());
-    }
-
-    inline void Heap::reportExtraMemoryCost(size_t cost)
-    {
-        if (cost > minExtraCost) 
-            reportExtraMemoryCostSlowCase(cost);
-    }
-
-    template<typename Functor> inline typename Functor::ReturnType Heap::forEachProtectedCell(Functor& functor)
-    {
-        for (auto& pair : m_protectedValues)
-            functor(pair.key);
-        m_handleSet.forEachStrongHandle(functor, m_protectedValues);
-
-        return functor.returnValue();
-    }
-
-    template<typename Functor> inline typename Functor::ReturnType Heap::forEachProtectedCell()
-    {
-        Functor functor;
-        return forEachProtectedCell(functor);
-    }
-
-    template<typename Functor> inline void Heap::forEachCodeBlock(Functor& functor)
-    {
-        return m_codeBlocks.iterate<Functor>(functor);
-    }
-
-    inline void* Heap::allocateWithNormalDestructor(size_t bytes)
-    {
-#if ENABLE(ALLOCATION_LOGGING)
-        dataLogF("JSC GC allocating %lu bytes with normal destructor.\n", bytes);
-#endif
-        ASSERT(isValidAllocation(bytes));
-        return m_objectSpace.allocateWithNormalDestructor(bytes);
-    }
-    
-    inline void* Heap::allocateWithImmortalStructureDestructor(size_t bytes)
-    {
-#if ENABLE(ALLOCATION_LOGGING)
-        dataLogF("JSC GC allocating %lu bytes with immortal structure destructor.\n", bytes);
-#endif
-        ASSERT(isValidAllocation(bytes));
-        return m_objectSpace.allocateWithImmortalStructureDestructor(bytes);
-    }
+    JS_EXPORT_PRIVATE bool isValidAllocation(size_t);
+    JS_EXPORT_PRIVATE void reportExtraMemoryCostSlowCase(size_t);
+
+    void suspendCompilerThreads();
+    void willStartCollection(HeapOperation collectionType);
+    void deleteOldCode(double gcStartTime);
+    void flushOldStructureIDTables();
+    void flushWriteBarrierBuffer();
+    void stopAllocation();
+
+    void markRoots();
+    void gatherStackRoots(ConservativeRoots&, void** dummy);
+    void gatherJSStackRoots(ConservativeRoots&);
+    void gatherScratchBufferRoots(ConservativeRoots&);
+    void clearLivenessData();
+    void visitSmallStrings();
+    void visitConservativeRoots(ConservativeRoots&);
+    void visitCompilerWorklists();
+    void visitProtectedObjects(HeapRootVisitor&);
+    void visitTempSortVectors(HeapRootVisitor&);
+    void visitArgumentBuffers(HeapRootVisitor&);
+    void visitException(HeapRootVisitor&);
+    void visitStrongHandles(HeapRootVisitor&);
+    void visitHandleStack(HeapRootVisitor&);
+    void traceCodeBlocksAndJITStubRoutines();
+    void converge();
+    void visitWeakHandles(HeapRootVisitor&);
+    void clearRememberedSet(Vector<const JSCell*>&);
+    void updateObjectCounts();
+    void resetVisitors();
+
+    void reapWeakHandles();
+    void sweepArrayBuffers();
+    void snapshotMarkedSpace();
+    void deleteSourceProviderCaches();
+    void notifyIncrementalSweeper();
+    void rememberCurrentlyExecutingCodeBlocks();
+    void resetAllocators();
+    void copyBackingStores();
+    void harvestWeakReferences();
+    void finalizeUnconditionalFinalizers();
+    void deleteUnmarkedCompiledCode();
+    void updateAllocationLimits();
+    void didFinishCollection(double gcStartTime);
+    void resumeCompilerThreads();
+    void zombifyDeadObjects();
+    void markDeadObjects();
+
+    bool shouldDoFullCollection(HeapOperation requestedCollectionType) const;
+    size_t sizeAfterCollect();
+
+    JSStack& stack();
     
-    inline void* Heap::allocateWithoutDestructor(size_t bytes)
-    {
-#if ENABLE(ALLOCATION_LOGGING)
-        dataLogF("JSC GC allocating %lu bytes without destructor.\n", bytes);
-#endif
-        ASSERT(isValidAllocation(bytes));
-        return m_objectSpace.allocateWithoutDestructor(bytes);
-    }
-   
-    inline CheckedBoolean Heap::tryAllocateStorage(JSCell* intendedOwner, size_t bytes, void** outPtr)
-    {
-        CheckedBoolean result = m_storageSpace.tryAllocate(bytes, outPtr);
-#if ENABLE(ALLOCATION_LOGGING)
-        dataLogF("JSC GC allocating %lu bytes of storage for %p: %p.\n", bytes, intendedOwner, *outPtr);
-#else
-        UNUSED_PARAM(intendedOwner);
-#endif
-        return result;
-    }
+    void incrementDeferralDepth();
+    void decrementDeferralDepth();
+    void decrementDeferralDepthAndGCIfNeeded();
+
+    const HeapType m_heapType;
+    const size_t m_ramSize;
+    const size_t m_minBytesPerCycle;
+    size_t m_sizeAfterLastCollect;
+    size_t m_sizeAfterLastFullCollect;
+    size_t m_sizeBeforeLastFullCollect;
+    size_t m_sizeAfterLastEdenCollect;
+    size_t m_sizeBeforeLastEdenCollect;
+
+    size_t m_bytesAllocatedThisCycle;
+    size_t m_bytesAbandonedSinceLastFullCollect;
+    size_t m_maxEdenSize;
+    size_t m_maxHeapSize;
+    bool m_shouldDoFullCollection;
+    size_t m_totalBytesVisited;
+    size_t m_totalBytesCopied;
     
-    inline CheckedBoolean Heap::tryReallocateStorage(JSCell* intendedOwner, void** ptr, size_t oldSize, size_t newSize)
-    {
-#if ENABLE(ALLOCATION_LOGGING)
-        void* oldPtr = *ptr;
-#endif
-        CheckedBoolean result = m_storageSpace.tryReallocate(ptr, oldSize, newSize);
-#if ENABLE(ALLOCATION_LOGGING)
-        dataLogF("JSC GC reallocating %lu -> %lu bytes of storage for %p: %p -> %p.\n", oldSize, newSize, intendedOwner, oldPtr, *ptr);
-#else
-        UNUSED_PARAM(intendedOwner);
-#endif
-        return result;
-    }
-
-    inline void Heap::ascribeOwner(JSCell* intendedOwner, void* storage)
-    {
-#if ENABLE(ALLOCATION_LOGGING)
-        dataLogF("JSC GC ascribing %p as owner of storage %p.\n", intendedOwner, storage);
-#else
-        UNUSED_PARAM(intendedOwner);
-        UNUSED_PARAM(storage);
-#endif
-    }
-
-    inline BlockAllocator& Heap::blockAllocator()
-    {
-        return m_blockAllocator;
-    }
-
-#if USE(CF)
-    template <typename T>
-    inline void Heap::releaseSoon(RetainPtr<T>&& object)
-    {
-        m_objectSpace.releaseSoon(std::move(object));
-    }
-#endif
+    HeapOperation m_operationInProgress;
+    BlockAllocator m_blockAllocator;
+    StructureIDTable m_structureIDTable;
+    MarkedSpace m_objectSpace;
+    CopiedSpace m_storageSpace;
+    GCIncomingRefCountedSet<ArrayBuffer> m_arrayBuffers;
+    size_t m_extraMemoryUsage;
 
+    HashSet<const JSCell*> m_copyingRememberedSet;
 
-inline void Heap::incrementDeferralDepth()
-{
-    RELEASE_ASSERT(m_deferralDepth < 100); // Sanity check to make sure this doesn't get ridiculous.
-    m_deferralDepth++;
-}
+    ProtectCountSet m_protectedValues;
+    Vector<Vector<ValueStringPair, 0, UnsafeVectorOverflow>*> m_tempSortingVectors;
+    OwnPtr<HashSet<MarkedArgumentBuffer*>> m_markListSet;
 
-inline void Heap::decrementDeferralDepth()
-{
-    RELEASE_ASSERT(m_deferralDepth >= 1);
-    m_deferralDepth--;
-}
-
-inline bool Heap::collectIfNecessaryOrDefer()
-{
-    if (isDeferred())
-        return false;
+    MachineThreads m_machineThreads;
+    
+    GCThreadSharedData m_sharedData;
+    SlotVisitor m_slotVisitor;
+    CopyVisitor m_copyVisitor;
+
+    HandleSet m_handleSet;
+    HandleStack m_handleStack;
+    CodeBlockSet m_codeBlocks;
+    JITStubRoutineSet m_jitStubRoutines;
+    FinalizerOwner m_finalizerOwner;
+    
+    bool m_isSafeToCollect;
 
-    if (!shouldCollect())
-        return false;
+    WriteBarrierBuffer m_writeBarrierBuffer;
 
-    collect();
-    return true;
-}
+    VM* m_vm;
+    double m_lastFullGCLength;
+    double m_lastEdenGCLength;
+    double m_lastCodeDiscardTime;
 
-inline void Heap::decrementDeferralDepthAndGCIfNeeded()
-{
-    decrementDeferralDepth();
-    collectIfNecessaryOrDefer();
-}
+    DoublyLinkedList<ExecutableBase> m_compiledCode;
+    
+    RefPtr<GCActivityCallback> m_fullActivityCallback;
+    RefPtr<GCActivityCallback> m_edenActivityCallback;
+    OwnPtr<IncrementalSweeper> m_sweeper;
+    Vector<MarkedBlock*> m_blockSnapshot;
+    
+    unsigned m_deferralDepth;
+};
 
 } // namespace JSC
 
diff --git a/Source/JavaScriptCore/heap/HeapInlines.h b/Source/JavaScriptCore/heap/HeapInlines.h
new file mode 100644 (file)
index 0000000..6b39cb6
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HeapInlines_h
+#define HeapInlines_h
+
+#include "Heap.h"
+#include "JSCell.h"
+
+namespace JSC {
+
+inline bool Heap::shouldCollect()
+{
+    if (isDeferred())
+        return false;
+    if (Options::gcMaxHeapSize())
+        return m_bytesAllocatedThisCycle > Options::gcMaxHeapSize() && m_isSafeToCollect && m_operationInProgress == NoOperation;
+    return m_bytesAllocatedThisCycle > m_maxEdenSize && m_isSafeToCollect && m_operationInProgress == NoOperation;
+}
+
+inline bool Heap::isBusy()
+{
+    return m_operationInProgress != NoOperation;
+}
+
+inline bool Heap::isCollecting()
+{
+    return m_operationInProgress == FullCollection || m_operationInProgress == EdenCollection;
+}
+
+inline Heap* Heap::heap(const JSCell* cell)
+{
+    return MarkedBlock::blockFor(cell)->heap();
+}
+
+inline Heap* Heap::heap(const JSValue v)
+{
+    if (!v.isCell())
+        return 0;
+    return heap(v.asCell());
+}
+
+inline bool Heap::isLive(const void* cell)
+{
+    return MarkedBlock::blockFor(cell)->isLiveCell(cell);
+}
+
+inline bool Heap::isInRememberedSet(const JSCell* cell) const
+{
+    ASSERT(cell);
+    ASSERT(!Options::enableConcurrentJIT() || !isCompilationThread());
+    return MarkedBlock::blockFor(cell)->isRemembered(cell);
+}
+
+inline bool Heap::isMarked(const void* cell)
+{
+    return MarkedBlock::blockFor(cell)->isMarked(cell);
+}
+
+inline bool Heap::testAndSetMarked(const void* cell)
+{
+    return MarkedBlock::blockFor(cell)->testAndSetMarked(cell);
+}
+
+inline void Heap::setMarked(const void* cell)
+{
+    MarkedBlock::blockFor(cell)->setMarked(cell);
+}
+
+inline bool Heap::isWriteBarrierEnabled()
+{
+#if ENABLE(WRITE_BARRIER_PROFILING) || ENABLE(GGC)
+    return true;
+#else
+    return false;
+#endif
+}
+
+inline void Heap::writeBarrier(const JSCell* from, JSValue to)
+{
+#if ENABLE(WRITE_BARRIER_PROFILING)
+    WriteBarrierCounters::countWriteBarrier();
+#endif
+    if (!to.isCell())
+        return;
+    writeBarrier(from, to.asCell());
+}
+
+inline void Heap::reportExtraMemoryCost(size_t cost)
+{
+    if (cost > minExtraCost) 
+        reportExtraMemoryCostSlowCase(cost);
+}
+
+template<typename Functor> inline typename Functor::ReturnType Heap::forEachProtectedCell(Functor& functor)
+{
+    for (auto& pair : m_protectedValues)
+        functor(pair.key);
+    m_handleSet.forEachStrongHandle(functor, m_protectedValues);
+
+    return functor.returnValue();
+}
+
+template<typename Functor> inline typename Functor::ReturnType Heap::forEachProtectedCell()
+{
+    Functor functor;
+    return forEachProtectedCell(functor);
+}
+
+template<typename Functor> inline void Heap::forEachCodeBlock(Functor& functor)
+{
+    return m_codeBlocks.iterate<Functor>(functor);
+}
+
+inline void* Heap::allocateWithNormalDestructor(size_t bytes)
+{
+#if ENABLE(ALLOCATION_LOGGING)
+    dataLogF("JSC GC allocating %lu bytes with normal destructor.\n", bytes);
+#endif
+    ASSERT(isValidAllocation(bytes));
+    return m_objectSpace.allocateWithNormalDestructor(bytes);
+}
+
+inline void* Heap::allocateWithImmortalStructureDestructor(size_t bytes)
+{
+#if ENABLE(ALLOCATION_LOGGING)
+    dataLogF("JSC GC allocating %lu bytes with immortal structure destructor.\n", bytes);
+#endif
+    ASSERT(isValidAllocation(bytes));
+    return m_objectSpace.allocateWithImmortalStructureDestructor(bytes);
+}
+
+inline void* Heap::allocateWithoutDestructor(size_t bytes)
+{
+#if ENABLE(ALLOCATION_LOGGING)
+    dataLogF("JSC GC allocating %lu bytes without destructor.\n", bytes);
+#endif
+    ASSERT(isValidAllocation(bytes));
+    return m_objectSpace.allocateWithoutDestructor(bytes);
+}
+
+inline CheckedBoolean Heap::tryAllocateStorage(JSCell* intendedOwner, size_t bytes, void** outPtr)
+{
+    CheckedBoolean result = m_storageSpace.tryAllocate(bytes, outPtr);
+#if ENABLE(ALLOCATION_LOGGING)
+    dataLogF("JSC GC allocating %lu bytes of storage for %p: %p.\n", bytes, intendedOwner, *outPtr);
+#else
+    UNUSED_PARAM(intendedOwner);
+#endif
+    return result;
+}
+
+inline CheckedBoolean Heap::tryReallocateStorage(JSCell* intendedOwner, void** ptr, size_t oldSize, size_t newSize)
+{
+#if ENABLE(ALLOCATION_LOGGING)
+    void* oldPtr = *ptr;
+#endif
+    CheckedBoolean result = m_storageSpace.tryReallocate(ptr, oldSize, newSize);
+#if ENABLE(ALLOCATION_LOGGING)
+    dataLogF("JSC GC reallocating %lu -> %lu bytes of storage for %p: %p -> %p.\n", oldSize, newSize, intendedOwner, oldPtr, *ptr);
+#else
+    UNUSED_PARAM(intendedOwner);
+#endif
+    return result;
+}
+
+inline void Heap::ascribeOwner(JSCell* intendedOwner, void* storage)
+{
+#if ENABLE(ALLOCATION_LOGGING)
+    dataLogF("JSC GC ascribing %p as owner of storage %p.\n", intendedOwner, storage);
+#else
+    UNUSED_PARAM(intendedOwner);
+    UNUSED_PARAM(storage);
+#endif
+}
+
+inline BlockAllocator& Heap::blockAllocator()
+{
+    return m_blockAllocator;
+}
+
+#if USE(CF)
+template <typename T>
+inline void Heap::releaseSoon(RetainPtr<T>&& object)
+{
+    m_objectSpace.releaseSoon(std::move(object));
+}
+#endif
+
+inline void Heap::incrementDeferralDepth()
+{
+    RELEASE_ASSERT(m_deferralDepth < 100); // Sanity check to make sure this doesn't get ridiculous.
+    m_deferralDepth++;
+}
+
+inline void Heap::decrementDeferralDepth()
+{
+    RELEASE_ASSERT(m_deferralDepth >= 1);
+    m_deferralDepth--;
+}
+
+inline bool Heap::collectIfNecessaryOrDefer()
+{
+    if (isDeferred())
+        return false;
+
+    if (!shouldCollect())
+        return false;
+
+    collect();
+    return true;
+}
+
+inline void Heap::decrementDeferralDepthAndGCIfNeeded()
+{
+    decrementDeferralDepth();
+    collectIfNecessaryOrDefer();
+}
+
+inline HashSet<MarkedArgumentBuffer*>& Heap::markListSet()
+{
+    if (!m_markListSet)
+        m_markListSet = adoptPtr(new HashSet<MarkedArgumentBuffer*>); 
+    return *m_markListSet;
+}
+    
+} // namespace JSC
+
+#endif // HeapInlines_h
index 5d91be6..769163a 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(LLINT)
 
 #include "CodeBlock.h"
+#include "HeapInlines.h"
 #include "JITCode.h"
 #include "JSObject.h"
 #include "LLIntThunks.h"
index a6e5ebc..9cf7028 100644 (file)
@@ -40,6 +40,7 @@
 #include "CallFrameInlines.h"
 #include "ExceptionHelpers.h"
 #include "GCIncomingRefCountedInlines.h"
+#include "HeapInlines.h"
 #include "IdentifierInlines.h"
 #include "Interpreter.h"
 #include "JSArrayBufferViewInlines.h"
index 985ce28..338d3db 100644 (file)
@@ -33,6 +33,7 @@
 #include "CopyWriteBarrier.h"
 #include "DeferGC.h"
 #include "Heap.h"
+#include "HeapInlines.h"
 #include "IndexingHeaderInlines.h"
 #include "JSCell.h"
 #include "PropertySlot.h"