fourthTier: don't GC when shutting down the VM
[WebKit-https.git] / Source / JavaScriptCore / heap / Heap.h
index 594b767..5d4ef76 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
- *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
 #ifndef Heap_h
 #define Heap_h
 
-#include "HandleHeap.h"
+#include "BlockAllocator.h"
+#include "CopyVisitor.h"
+#include "DFGCodeBlocks.h"
+#include "GCThreadSharedData.h"
+#include "HandleSet.h"
 #include "HandleStack.h"
+#include "JITStubRoutineSet.h"
+#include "MarkedAllocator.h"
 #include "MarkedBlock.h"
 #include "MarkedBlockSet.h"
-#include "NewSpace.h"
+#include "MarkedSpace.h"
+#include "Options.h"
 #include "SlotVisitor.h"
+#include "WeakHandleOwner.h"
 #include "WriteBarrierSupport.h"
-#include <wtf/Forward.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
 
+#define COLLECT_ON_EVERY_ALLOCATION 0
+
 namespace JSC {
 
+    class CopiedSpace;
+    class CodeBlock;
+    class ExecutableBase;
     class GCActivityCallback;
+    class GCAwareJITStubRoutine;
     class GlobalCodeBlock;
+    class Heap;
     class HeapRootVisitor;
+    class IncrementalSweeper;
+    class JITStubRoutine;
     class JSCell;
-    class JSGlobalData;
+    class VM;
+    class JSStack;
     class JSValue;
     class LiveObjectIterator;
+    class LLIntOffsetsExtractor;
     class MarkedArgumentBuffer;
-    class RegisterFile;
-    class UString;
     class WeakGCHandlePool;
     class SlotVisitor;
 
-    typedef std::pair<JSValue, UString> ValueStringPair;
+    typedef std::pair<JSValue, WTF::String> ValueStringPair;
     typedef HashCountedSet<JSCell*> ProtectCountSet;
     typedef HashCountedSet<const char*> TypeCountSet;
 
     enum OperationInProgress { NoOperation, Allocation, Collection };
-    
-    // Heap size hint.
-    enum HeapSize { SmallHeap, LargeHeap };
-    
+
+    enum HeapType { SmallHeap, LargeHeap };
+
     class Heap {
         WTF_MAKE_NONCOPYABLE(Heap);
     public:
-        static Heap* heap(JSValue); // 0 for immediate values
-        static Heap* heap(JSCell*);
-
+        friend class JIT;
+        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 bool testAndClearMarked(const void*);
         static void setMarked(const void*);
 
+        static bool isWriteBarrierEnabled();
         static void writeBarrier(const JSCell*, JSValue);
         static void writeBarrier(const JSCell*, JSCell*);
+        static uint8_t* addressOfCardFor(JSCell*);
 
-        Heap(JSGlobalData*, HeapSize);
+        Heap(VM*, HeapType);
         ~Heap();
-        void destroy(); // JSGlobalData must call destroy() before ~Heap().
+        JS_EXPORT_PRIVATE void lastChanceToFinalize();
 
-        JSGlobalData* globalData() const { return m_globalData; }
-        NewSpace& markedSpace() { return m_newSpace; }
+        VM* vm() const { return m_vm; }
+        MarkedSpace& objectSpace() { return m_objectSpace; }
         MachineThreads& machineThreads() { return m_machineThreads; }
 
-        GCActivityCallback* activityCallback();
-        void setActivityCallback(PassOwnPtr<GCActivityCallback>);
+        JS_EXPORT_PRIVATE GCActivityCallback* activityCallback();
+        JS_EXPORT_PRIVATE void setActivityCallback(PassOwnPtr<GCActivityCallback>);
+        JS_EXPORT_PRIVATE void setGarbageCollectionTimerEnabled(bool);
+
+        JS_EXPORT_PRIVATE IncrementalSweeper* sweeper();
 
+        // true if collection is in progress
+        inline bool isCollecting();
         // 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* allocate(size_t);
-        NewSpace::SizeClass& sizeClassFor(size_t);
-        void* allocate(NewSpace::SizeClass&);
         void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
-        void collectAllGarbage();
-
-        void reportExtraMemoryCost(size_t cost);
+        bool isSafeToCollect() const { return m_isSafeToCollect; }
 
-        void protect(JSValue);
-        bool unprotect(JSValue); // True when the protect count drops to 0.
+        JS_EXPORT_PRIVATE void collectAllGarbage();
+        enum SweepToggle { DoNotSweep, DoSweep };
+        bool shouldCollect();
+        void collect(SweepToggle);
+        bool collectIfNecessaryOrDefer(); // Returns true if it did collect.
 
-        size_t size();
-        size_t capacity();
-        size_t objectCount();
-        size_t globalObjectCount();
-        size_t protectedObjectCount();
-        size_t protectedGlobalObjectCount();
-        PassOwnPtr<TypeCountSet> protectedObjectTypeCounts();
-        PassOwnPtr<TypeCountSet> objectTypeCounts();
+        void reportExtraMemoryCost(size_t cost);
+        JS_EXPORT_PRIVATE void reportAbandonedObjectGraph();
 
-        void pushTempSortVector(Vector<ValueStringPair>*);
-        void popTempSortVector(Vector<ValueStringPair>*);
+        JS_EXPORT_PRIVATE void protect(JSValue);
+        JS_EXPORT_PRIVATE bool unprotect(JSValue); // True when the protect count drops to 0.
+        
+        void jettisonDFGCodeBlock(PassRefPtr<CodeBlock>);
+
+        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() { if (!m_markListSet) m_markListSet = new HashSet<MarkedArgumentBuffer*>; return *m_markListSet; }
+        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> typename Functor::ReturnType forEachCell(Functor&);
-        template<typename Functor> typename Functor::ReturnType forEachCell();
-        template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&);
-        template<typename Functor> typename Functor::ReturnType forEachBlock();
-        
-        HandleSlot allocateGlobalHandle() { return m_handleHeap.allocate(); }
-        HandleSlot allocateLocalHandle() { return m_handleStack.push(); }
 
+        HandleSet* handleSet() { return &m_handleSet; }
         HandleStack* handleStack() { return &m_handleStack; }
+
+        void canonicalizeCellLivenessData();
         void getConservativeRegisterRoots(HashSet<JSCell*>& roots);
 
+        double lastGCLength() { return m_lastGCLength; }
+        void increaseLastGCLength(double amount) { m_lastGCLength += amount; }
+
+        JS_EXPORT_PRIVATE void deleteAllCompiledCode();
+
+        void didAllocate(size_t);
+        void didAbandon(size_t);
+
+        bool isPagedOut(double deadline);
+        
+        const JITStubRoutineSet& jitStubRoutines() { return m_jitStubRoutines; }
+
     private:
+        friend class CodeBlock;
+        friend class CopiedBlock;
+        friend class DeferGC;
+        friend class GCAwareJITStubRoutine;
+        friend class HandleSet;
+        friend class JITStubRoutine;
+        friend class LLIntOffsetsExtractor;
+        friend class MarkedSpace;
+        friend class MarkedAllocator;
         friend class MarkedBlock;
-        
-        typedef HashSet<MarkedBlock*>::iterator BlockIterator;
+        friend class CopiedSpace;
+        friend class CopyVisitor;
+        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;
         
-        enum AllocationEffort { AllocationMustSucceed, AllocationCanFail };
-        
-#if ENABLE(GGC)
-        static void writeBarrierFastCase(const JSCell* owner, JSCell*);
-#endif
-
-        bool isValidAllocation(size_t);
-        void reportExtraMemoryCostSlowCase(size_t);
-        void canonicalizeBlocks();
-        void resetAllocator();
+        class FinalizerOwner : public WeakHandleOwner {
+            virtual void finalize(Handle<Unknown>, void* context);
+        };
 
-        MarkedBlock* allocateBlock(size_t cellSize, AllocationEffort);
-        void freeBlocks(MarkedBlock*);
+        JS_EXPORT_PRIVATE bool isValidAllocation(size_t);
+        JS_EXPORT_PRIVATE void reportExtraMemoryCostSlowCase(size_t);
 
-        void clearMarks();
         void markRoots();
         void markProtectedObjects(HeapRootVisitor&);
         void markTempSortVectors(HeapRootVisitor&);
+        void copyBackingStores();
         void harvestWeakReferences();
+        void finalizeUnconditionalFinalizers();
+        void deleteUnmarkedCompiledCode();
+        void zombifyDeadObjects();
+        void markDeadObjects();
 
-        void* tryAllocate(NewSpace::SizeClass&);
-        void* allocateSlowCase(NewSpace::SizeClass&);
+        JSStack& stack();
+        BlockAllocator& blockAllocator();
         
-        enum SweepToggle { DoNotSweep, DoSweep };
-        void collect(SweepToggle);
-        void shrink();
-        void releaseFreeBlocks();
-        void sweep();
-
-        RegisterFile& registerFile();
-
-        static void writeBarrierSlowCase(const JSCell*, JSCell*);
-
-#if ENABLE(LAZY_BLOCK_FREEING)
-        void waitForRelativeTimeWhileHoldingLock(double relative);
-        void waitForRelativeTime(double relative);
-        void blockFreeingThreadMain();
-        static void* blockFreeingThreadStartFunc(void* heap);
-#endif
+        void incrementDeferralDepth();
+        void decrementDeferralDepthAndGCIfNeeded();
 
-        const HeapSize m_heapSize;
+        const HeapType m_heapType;
+        const size_t m_ramSize;
         const size_t m_minBytesPerCycle;
-        
-        OperationInProgress m_operationInProgress;
-        NewSpace m_newSpace;
-        MarkedBlockSet m_blocks;
+        size_t m_sizeAfterLastCollect;
 
-#if ENABLE(LAZY_BLOCK_FREEING)
-        DoublyLinkedList<MarkedBlock> m_freeBlocks;
-        size_t m_numberOfFreeBlocks;
+        size_t m_bytesAllocatedLimit;
+        size_t m_bytesAllocated;
+        size_t m_bytesAbandoned;
         
-        ThreadIdentifier m_blockFreeingThread;
-        Mutex m_freeBlockLock;
-        ThreadCondition m_freeBlockCondition;
-        bool m_blockFreeingThreadShouldQuit;
-#endif
+        OperationInProgress m_operationInProgress;
+        BlockAllocator m_blockAllocator;
+        MarkedSpace m_objectSpace;
+        CopiedSpace m_storageSpace;
+        size_t m_extraMemoryUsage;
 
 #if ENABLE(SIMPLE_HEAP_PROFILING)
         VTableSpectrum m_destroyedTypeCounts;
 #endif
 
-        size_t m_extraCost;
-
         ProtectCountSet m_protectedValues;
-        Vector<Vector<ValueStringPair>* > m_tempSortingVectors;
-        HashSet<MarkedArgumentBuffer*>* m_markListSet;
+        Vector<Vector<ValueStringPair, 0, UnsafeVectorOverflow>* > m_tempSortingVectors;
+        OwnPtr<HashSet<MarkedArgumentBuffer*> > m_markListSet;
 
-        OwnPtr<GCActivityCallback> m_activityCallback;
-        
         MachineThreads m_machineThreads;
+        
+        GCThreadSharedData m_sharedData;
         SlotVisitor m_slotVisitor;
-        HandleHeap m_handleHeap;
+        CopyVisitor m_copyVisitor;
+
+        HandleSet m_handleSet;
         HandleStack m_handleStack;
+        DFGCodeBlocks m_dfgCodeBlocks;
+        JITStubRoutineSet m_jitStubRoutines;
+        FinalizerOwner m_finalizerOwner;
         
         bool m_isSafeToCollect;
 
-        JSGlobalData* m_globalData;
+        VM* m_vm;
+        double m_lastGCLength;
+        double m_lastCodeDiscardTime;
+
+        DoublyLinkedList<ExecutableBase> m_compiledCode;
+        
+        OwnPtr<GCActivityCallback> m_activityCallback;
+        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 operator()(MarkedBlock* block) { m_blocks[m_index++] = block; }
+    
+        size_t m_index;
+        Vector<MarkedBlock*>& m_blocks;
     };
 
+    inline bool Heap::shouldCollect()
+    {
+        if (Options::gcMaxHeapSize())
+            return m_bytesAllocated > Options::gcMaxHeapSize() && m_isSafeToCollect && m_operationInProgress == NoOperation;
+        return m_bytesAllocated > m_bytesAllocatedLimit && m_isSafeToCollect && m_operationInProgress == NoOperation;
+    }
+
     bool Heap::isBusy()
     {
         return m_operationInProgress != NoOperation;
     }
 
-    inline Heap* Heap::heap(JSCell* cell)
+    bool Heap::isCollecting()
+    {
+        return m_operationInProgress == Collection;
+    }
+
+    inline Heap* Heap::heap(const JSCell* cell)
     {
         return MarkedBlock::blockFor(cell)->heap();
     }
 
-    inline Heap* Heap::heap(JSValue v)
+    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);
@@ -237,40 +339,19 @@ namespace JSC {
         return MarkedBlock::blockFor(cell)->testAndSetMarked(cell);
     }
 
-    inline bool Heap::testAndClearMarked(const void* cell)
-    {
-        return MarkedBlock::blockFor(cell)->testAndClearMarked(cell);
-    }
-
     inline void Heap::setMarked(const void* cell)
     {
         MarkedBlock::blockFor(cell)->setMarked(cell);
     }
 
-#if ENABLE(GGC)
-    inline void Heap::writeBarrierFastCase(const JSCell* owner, JSCell* cell)
+    inline bool Heap::isWriteBarrierEnabled()
     {
-        if (MarkedBlock::blockFor(owner)->inNewSpace())
-            return;
-        writeBarrierSlowCase(owner, cell);
-    }
-
-    inline void Heap::writeBarrier(const JSCell* owner, JSCell* cell)
-    {
-        WriteBarrierCounters::countWriteBarrier();
-        writeBarrierFastCase(owner, cell);
-    }
-
-    inline void Heap::writeBarrier(const JSCell* owner, JSValue value)
-    {
-        WriteBarrierCounters::countWriteBarrier();
-        if (!value)
-            return;
-        if (!value.isCell())
-            return;
-        writeBarrierFastCase(owner, value.asCell());
-    }
+#if ENABLE(WRITE_BARRIER_PROFILING)
+        return true;
 #else
+        return false;
+#endif
+    }
 
     inline void Heap::writeBarrier(const JSCell*, JSCell*)
     {
@@ -281,7 +362,6 @@ namespace JSC {
     {
         WriteBarrierCounters::countWriteBarrier();
     }
-#endif
 
     inline void Heap::reportExtraMemoryCost(size_t cost)
     {
@@ -291,11 +371,10 @@ namespace JSC {
 
     template<typename Functor> inline typename Functor::ReturnType Heap::forEachProtectedCell(Functor& functor)
     {
-        canonicalizeBlocks();
         ProtectCountSet::iterator end = m_protectedValues.end();
         for (ProtectCountSet::iterator it = m_protectedValues.begin(); it != end; ++it)
-            functor(it->first);
-        m_handleHeap.forEachStrongHandle(functor, m_protectedValues);
+            functor(it->key);
+        m_handleSet.forEachStrongHandle(functor, m_protectedValues);
 
         return functor.returnValue();
     }
@@ -306,57 +385,71 @@ namespace JSC {
         return forEachProtectedCell(functor);
     }
 
-    template<typename Functor> inline typename Functor::ReturnType Heap::forEachCell(Functor& functor)
+    inline void* Heap::allocateWithNormalDestructor(size_t bytes)
     {
-        canonicalizeBlocks();
-        BlockIterator end = m_blocks.set().end();
-        for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
-            (*it)->forEachCell(functor);
-        return functor.returnValue();
+#if ENABLE(ALLOCATION_LOGGING)
+        dataLogF("JSC GC allocating %lu bytes with normal destructor.\n", bytes);
+#endif
+        ASSERT(isValidAllocation(bytes));
+        return m_objectSpace.allocateWithNormalDestructor(bytes);
     }
-
-    template<typename Functor> inline typename Functor::ReturnType Heap::forEachCell()
+    
+    inline void* Heap::allocateWithImmortalStructureDestructor(size_t bytes)
     {
-        Functor functor;
-        return forEachCell(functor);
+#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);
     }
-
-    template<typename Functor> inline typename Functor::ReturnType Heap::forEachBlock(Functor& functor)
+    
+    inline void* Heap::allocateWithoutDestructor(size_t bytes)
     {
-        canonicalizeBlocks();
-        BlockIterator end = m_blocks.set().end();
-        for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
-            functor(*it);
-        return functor.returnValue();
+#if ENABLE(ALLOCATION_LOGGING)
+        dataLogF("JSC GC allocating %lu bytes without destructor.\n", bytes);
+#endif
+        ASSERT(isValidAllocation(bytes));
+        return m_objectSpace.allocateWithoutDestructor(bytes);
     }
-
-    template<typename Functor> inline typename Functor::ReturnType Heap::forEachBlock()
+   
+    inline CheckedBoolean Heap::tryAllocateStorage(JSCell* intendedOwner, size_t bytes, void** outPtr)
     {
-        Functor functor;
-        return forEachBlock(functor);
+        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 NewSpace::SizeClass& Heap::sizeClassFor(size_t bytes)
+    inline CheckedBoolean Heap::tryReallocateStorage(JSCell* intendedOwner, void** ptr, size_t oldSize, size_t newSize)
     {
-        return m_newSpace.sizeClassFor(bytes);
+#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::allocate(NewSpace::SizeClass& sizeClass)
+
+    inline void Heap::ascribeOwner(JSCell* intendedOwner, void* storage)
     {
-        // This is a light-weight fast path to cover the most common case.
-        MarkedBlock::FreeCell* firstFreeCell = sizeClass.firstFreeCell;
-        if (UNLIKELY(!firstFreeCell))
-            return allocateSlowCase(sizeClass);
-        
-        sizeClass.firstFreeCell = firstFreeCell->next;
-        return firstFreeCell;
+#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 void* Heap::allocate(size_t bytes)
+    inline BlockAllocator& Heap::blockAllocator()
     {
-        ASSERT(isValidAllocation(bytes));
-        NewSpace::SizeClass& sizeClass = sizeClassFor(bytes);
-        return allocate(sizeClass);
+        return m_blockAllocator;
     }
 
 } // namespace JSC