diff options
Diffstat (limited to 'Source/JavaScriptCore/heap/Heap.h')
-rw-r--r-- | Source/JavaScriptCore/heap/Heap.h | 85 |
1 files changed, 62 insertions, 23 deletions
diff --git a/Source/JavaScriptCore/heap/Heap.h b/Source/JavaScriptCore/heap/Heap.h index 1b228253b..40a8376f0 100644 --- a/Source/JavaScriptCore/heap/Heap.h +++ b/Source/JavaScriptCore/heap/Heap.h @@ -22,7 +22,6 @@ #ifndef Heap_h #define Heap_h -#include "AllocationSpace.h" #include "DFGCodeBlocks.h" #include "HandleHeap.h" #include "HandleStack.h" @@ -31,12 +30,16 @@ #include "MarkedSpace.h" #include "SlotVisitor.h" #include "WriteBarrierSupport.h" +#include <wtf/DoublyLinkedList.h> #include <wtf/Forward.h> #include <wtf/HashCountedSet.h> #include <wtf/HashSet.h> +#define COLLECT_ON_EVERY_ALLOCATION 0 + namespace JSC { + class BumpSpace; class CodeBlock; class GCActivityCallback; class GlobalCodeBlock; @@ -57,7 +60,7 @@ namespace JSC { typedef HashCountedSet<const char*> TypeCountSet; enum OperationInProgress { NoOperation, Allocation, Collection }; - + // Heap size hint. enum HeapSize { SmallHeap, LargeHeap }; @@ -65,6 +68,7 @@ namespace JSC { WTF_MAKE_NONCOPYABLE(Heap); public: friend class JIT; + friend class MarkStackThreadSharedData; static Heap* heap(JSValue); // 0 for immediate values static Heap* heap(JSCell*); @@ -78,42 +82,44 @@ namespace JSC { Heap(JSGlobalData*, HeapSize); ~Heap(); - void destroy(); // JSGlobalData must call destroy() before ~Heap(). + JS_EXPORT_PRIVATE void destroy(); // JSGlobalData must call destroy() before ~Heap(). JSGlobalData* globalData() const { return m_globalData; } - AllocationSpace& objectSpace() { return m_objectSpace; } + 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>); // true if an allocation or collection is in progress inline bool isBusy(); MarkedSpace::SizeClass& sizeClassForObject(size_t bytes) { return m_objectSpace.sizeClassFor(bytes); } void* allocate(size_t); + CheckedBoolean tryAllocateStorage(size_t, void**); + CheckedBoolean tryReallocateStorage(void**, size_t, size_t); typedef void (*Finalizer)(JSCell*); - void addFinalizer(JSCell*, Finalizer); + JS_EXPORT_PRIVATE void addFinalizer(JSCell*, Finalizer); void notifyIsSafeToCollect() { m_isSafeToCollect = true; } - void collectAllGarbage(); + JS_EXPORT_PRIVATE void collectAllGarbage(); void reportExtraMemoryCost(size_t cost); - void protect(JSValue); - bool unprotect(JSValue); // True when the protect count drops to 0. + JS_EXPORT_PRIVATE void protect(JSValue); + JS_EXPORT_PRIVATE bool unprotect(JSValue); // True when the protect count drops to 0. void jettisonDFGCodeBlock(PassOwnPtr<CodeBlock>); - size_t size(); - size_t capacity(); - size_t objectCount(); - size_t globalObjectCount(); - size_t protectedObjectCount(); - size_t protectedGlobalObjectCount(); - PassOwnPtr<TypeCountSet> protectedObjectTypeCounts(); - PassOwnPtr<TypeCountSet> objectTypeCounts(); + 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 pushTempSortVector(Vector<ValueStringPair>*); void popTempSortVector(Vector<ValueStringPair>*); @@ -129,11 +135,16 @@ namespace JSC { void getConservativeRegisterRoots(HashSet<JSCell*>& roots); private: + friend class MarkedSpace; friend class MarkedBlock; - friend class AllocationSpace; + friend class BumpSpace; friend class SlotVisitor; friend class CodeBlock; + size_t waterMark(); + size_t highWaterMark(); + void setHighWaterMark(size_t); + static const size_t minExtraCost = 256; static const size_t maxExtraCost = 1024 * 1024; @@ -141,8 +152,8 @@ namespace JSC { virtual void finalize(Handle<Unknown>, void* context); }; - bool isValidAllocation(size_t); - void reportExtraMemoryCostSlowCase(size_t); + JS_EXPORT_PRIVATE bool isValidAllocation(size_t); + JS_EXPORT_PRIVATE void reportExtraMemoryCostSlowCase(size_t); // Call this function before any operation that needs to know which cells // in the heap are live. (For example, call this function before @@ -175,11 +186,14 @@ namespace JSC { const HeapSize m_heapSize; const size_t m_minBytesPerCycle; size_t m_lastFullGCSize; + size_t m_waterMark; + size_t m_highWaterMark; OperationInProgress m_operationInProgress; - AllocationSpace m_objectSpace; + MarkedSpace m_objectSpace; + BumpSpace m_storageSpace; - DoublyLinkedList<MarkedBlock> m_freeBlocks; + DoublyLinkedList<HeapBlock> m_freeBlocks; size_t m_numberOfFreeBlocks; ThreadIdentifier m_blockFreeingThread; @@ -246,6 +260,21 @@ namespace JSC { MarkedBlock::blockFor(cell)->setMarked(cell); } + inline size_t Heap::waterMark() + { + return m_objectSpace.waterMark() + m_storageSpace.totalMemoryUtilized(); + } + + inline size_t Heap::highWaterMark() + { + return m_highWaterMark; + } + + inline void Heap::setHighWaterMark(size_t newHighWaterMark) + { + m_highWaterMark = newHighWaterMark; + } + #if ENABLE(GGC) inline uint8_t* Heap::addressOfCardFor(JSCell* cell) { @@ -308,6 +337,16 @@ namespace JSC { ASSERT(isValidAllocation(bytes)); return m_objectSpace.allocate(bytes); } + + inline CheckedBoolean Heap::tryAllocateStorage(size_t bytes, void** outPtr) + { + return m_storageSpace.tryAllocate(bytes, outPtr); + } + + inline CheckedBoolean Heap::tryReallocateStorage(void** ptr, size_t oldSize, size_t newSize) + { + return m_storageSpace.tryReallocate(ptr, oldSize, newSize); + } } // namespace JSC |