| Index: third_party/WebKit/Source/platform/heap/ThreadState.h
|
| diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.h b/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| index e8b1a0c354b0dfe03386d5f1e892d222d0be973c..72b5ab092df39e8e594b2e975a64a356622f852b 100644
|
| --- a/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| +++ b/third_party/WebKit/Source/platform/heap/ThreadState.h
|
| @@ -55,15 +55,20 @@ namespace blink {
|
| class BasePage;
|
| class CallbackStack;
|
| class CrossThreadPersistentRegion;
|
| +class FreePagePool;
|
| struct GCInfo;
|
| class GarbageCollectedMixinConstructorMarker;
|
| +class HeapDoesNotContainCache;
|
| class HeapObjectHeader;
|
| +class OrphanedPagePool;
|
| class PersistentRegion;
|
| +class XThreadPersistentRegion;
|
| class BaseHeap;
|
| class SafePointAwareMutexLocker;
|
| class SafePointBarrier;
|
| class ThreadState;
|
| class Visitor;
|
| +class PageMemoryRegion;
|
|
|
| // Declare that a class has a pre-finalizer. The pre-finalizer is called
|
| // before any object gets swept, so it is safe to touch on-heap objects
|
| @@ -125,6 +130,25 @@ class PLATFORM_EXPORT ThreadState {
|
| public:
|
| typedef std::pair<void*, PreFinalizerCallback> PreFinalizer;
|
|
|
| + // A RegionTree is a simple binary search tree of PageMemoryRegions sorted
|
| + // by base addresses.
|
| + class RegionTree {
|
| + public:
|
| + explicit RegionTree(PageMemoryRegion* region) : m_region(region), m_left(nullptr), m_right(nullptr) { }
|
| + ~RegionTree()
|
| + {
|
| + delete m_left;
|
| + delete m_right;
|
| + }
|
| + PageMemoryRegion* lookup(Address);
|
| + static void add(RegionTree*, RegionTree**);
|
| + static void remove(PageMemoryRegion*, RegionTree**);
|
| + private:
|
| + PageMemoryRegion* m_region;
|
| + RegionTree* m_left;
|
| + RegionTree* m_right;
|
| + };
|
| +
|
| // See setGCState() for possible state transitions.
|
| enum GCState {
|
| NoGCScheduled,
|
| @@ -225,12 +249,67 @@ public:
|
| return **s_threadSpecific;
|
| #endif
|
| }
|
| + static ThreadState* terminating()
|
| + {
|
| + // TLS lookup is fast in these platforms.
|
| + return **s_threadSpecificTerminating;
|
| + }
|
|
|
| static ThreadState* mainThreadState()
|
| {
|
| return reinterpret_cast<ThreadState*>(s_mainThreadStateStorage);
|
| }
|
|
|
| + CallbackStack* markingStack() const { return m_markingStack.get(); }
|
| + CallbackStack* postMarkingCallbackStack() const { return m_postMarkingCallbackStack.get(); }
|
| + CallbackStack* globalWeakCallbackStack() const { return m_globalWeakCallbackStack.get(); }
|
| + CallbackStack* ephemeronStack() const { return m_ephemeronStack.get(); }
|
| + FreePagePool* freePagePool() const { return m_freePagePool.get(); }
|
| + void setMarkedObjectSizeAtLastCompleteSweep(size_t size) { releaseStore(&m_markedObjectSizeAtLastCompleteSweep, size); }
|
| + size_t markedObjectSizeAtLastCompleteSweep() { return acquireLoad(&m_markedObjectSizeAtLastCompleteSweep); }
|
| + void increaseAllocatedObjectSize(size_t delta) { atomicAdd(&m_allocatedObjectSize, static_cast<long>(delta)); }
|
| + void decreaseAllocatedObjectSize(size_t delta) { atomicSubtract(&m_allocatedObjectSize, static_cast<long>(delta)); }
|
| + size_t allocatedObjectSize() { return acquireLoad(&m_allocatedObjectSize); }
|
| + void increaseMarkedObjectSize(size_t delta) { atomicAdd(&m_markedObjectSize, static_cast<long>(delta)); }
|
| + size_t markedObjectSize() { return acquireLoad(&m_markedObjectSize); }
|
| + void increaseAllocatedSpace(size_t delta) { atomicAdd(&m_allocatedSpace, static_cast<long>(delta)); }
|
| + void decreaseAllocatedSpace(size_t delta) { atomicSubtract(&m_allocatedSpace, static_cast<long>(delta)); }
|
| + size_t allocatedSpace() { return acquireLoad(&m_allocatedSpace); }
|
| + size_t objectSizeAtLastGC() { return acquireLoad(&m_objectSizeAtLastGC); }
|
| + void increaseWrapperCount(size_t delta) { atomicAdd(&m_wrapperCount, static_cast<long>(delta)); }
|
| + void decreaseWrapperCount(size_t delta) { atomicSubtract(&m_wrapperCount, static_cast<long>(delta)); }
|
| + size_t wrapperCount() { return acquireLoad(&m_wrapperCount); }
|
| + size_t wrapperCountAtLastGC() { return acquireLoad(&m_wrapperCountAtLastGC); }
|
| + void increaseCollectedWrapperCount(size_t delta) { atomicAdd(&m_collectedWrapperCount, static_cast<long>(delta)); }
|
| + size_t collectedWrapperCount() { return acquireLoad(&m_collectedWrapperCount); }
|
| + size_t partitionAllocSizeAtLastGC() { return acquireLoad(&m_partitionAllocSizeAtLastGC); }
|
| +
|
| + void setEstimatedMarkingTimePerByte(double estimatedMarkingTimePerByte) { m_estimatedMarkingTimePerByte = estimatedMarkingTimePerByte; }
|
| + double estimatedMarkingTimePerByte() const { return m_estimatedMarkingTimePerByte; }
|
| + void setShutdownCalled(bool shutdownCalled) { m_shutdownCalled = shutdownCalled; }
|
| + bool shutdownCalled() const { return m_shutdownCalled; }
|
| + HeapDoesNotContainCache* heapDoesNotContainCache() const { return m_heapDoesNotContainCache.get(); }
|
| + RegionTree* regionTree() const { return m_regionTree; }
|
| + void setRegionTree(RegionTree* tree) { m_regionTree = tree; }
|
| +
|
| + double estimatedMarkingTime();
|
| + void reportMemoryUsageHistogram();
|
| + void reportMemoryUsageForTracing();
|
| +
|
| +#if ENABLE(ASSERT)
|
| + void incrementGcGeneration() {
|
| + if (++m_gcGeneration == 0)
|
| + m_gcGeneration = 1;
|
| + }
|
| + uint16_t gcGeneration() { return m_gcGeneration; }
|
| +#endif
|
| +
|
| + void flushHeapDoesNotContainCache();
|
| + OrphanedPagePool* orphanedPagePool() { return m_orphanedPagePool.get(); }
|
| +
|
| + // Reset counters that track live and allocated-since-last-GC sizes.
|
| + void resetHeapCounters();
|
| +
|
| bool isMainThread() const { return this == mainThreadState(); }
|
| #if ENABLE(ASSERT)
|
| bool checkThread() const { return m_thread == currentThread(); }
|
| @@ -368,6 +447,7 @@ public:
|
|
|
| // A region of PersistentNodes allocated on the given thread.
|
| PersistentRegion* persistentRegion() const { return m_persistentRegion.get(); }
|
| + XThreadPersistentRegion* xThreadPersistentRegion() const { return m_xThreadPersistentRegion.get(); }
|
| // A region of PersistentNodes not owned by any particular thread.
|
| static CrossThreadPersistentRegion& crossThreadPersistentRegion();
|
|
|
| @@ -510,6 +590,9 @@ public:
|
| size_t threadStackSize();
|
| #endif
|
|
|
| + void setIsolated(bool isolated) { m_isolated = isolated; }
|
| + bool isolated() { return m_isolated; }
|
| +
|
| private:
|
| enum SnapshotType {
|
| HeapSnapshot,
|
| @@ -596,6 +679,7 @@ private:
|
| friend class SafePointScope;
|
|
|
| static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
|
| + static WTF::ThreadSpecific<ThreadState*>* s_threadSpecificTerminating;
|
| static uintptr_t s_mainThreadStackStart;
|
| static uintptr_t s_mainThreadUnderestimatedStackSize;
|
| static SafePointBarrier* s_safePointBarrier;
|
| @@ -610,7 +694,9 @@ private:
|
| static uint8_t s_mainThreadStateStorage[];
|
|
|
| ThreadIdentifier m_thread;
|
| + bool m_isolated;
|
| OwnPtr<PersistentRegion> m_persistentRegion;
|
| + OwnPtr<XThreadPersistentRegion> m_xThreadPersistentRegion;
|
| BlinkGC::StackState m_stackState;
|
| #if OS(WIN) && COMPILER(MSVC)
|
| size_t m_threadStackSize;
|
| @@ -659,6 +745,29 @@ private:
|
| static const int likelyToBePromptlyFreedArraySize = (1 << 8);
|
| static const int likelyToBePromptlyFreedArrayMask = likelyToBePromptlyFreedArraySize - 1;
|
| OwnPtr<int[]> m_likelyToBePromptlyFreed;
|
| +
|
| + OwnPtr<CallbackStack> m_markingStack;
|
| + OwnPtr<CallbackStack> m_postMarkingCallbackStack;
|
| + OwnPtr<CallbackStack> m_globalWeakCallbackStack;
|
| + OwnPtr<CallbackStack> m_ephemeronStack;
|
| + OwnPtr<FreePagePool> m_freePagePool;
|
| + size_t m_allocatedSpace;
|
| + size_t m_allocatedObjectSize;
|
| + size_t m_objectSizeAtLastGC;
|
| + size_t m_markedObjectSize;
|
| + size_t m_markedObjectSizeAtLastCompleteSweep;
|
| + size_t m_wrapperCount;
|
| + size_t m_wrapperCountAtLastGC;
|
| + size_t m_collectedWrapperCount;
|
| + size_t m_partitionAllocSizeAtLastGC;
|
| + double m_estimatedMarkingTimePerByte;
|
| +#if ENABLE(ASSERT)
|
| + uint16_t m_gcGeneration;
|
| +#endif
|
| + OwnPtr<HeapDoesNotContainCache> m_heapDoesNotContainCache;
|
| + bool m_shutdownCalled;
|
| + OwnPtr<OrphanedPagePool> m_orphanedPagePool;
|
| + RegionTree* m_regionTree;
|
| };
|
|
|
| template<ThreadAffinity affinity> class ThreadStateFor;
|
|
|