Chromium Code Reviews| Index: Source/platform/heap/ThreadState.h |
| diff --git a/Source/platform/heap/ThreadState.h b/Source/platform/heap/ThreadState.h |
| index 5269820c6417a1cff55af4d7d8237da95eed2fb1..110f7f39d6923edc44b9f2c01a2ed9b134908bfc 100644 |
| --- a/Source/platform/heap/ThreadState.h |
| +++ b/Source/platform/heap/ThreadState.h |
| @@ -49,6 +49,7 @@ class FinalizedHeapObjectHeader; |
| struct GCInfo; |
| class HeapContainsCache; |
| class HeapObjectHeader; |
| +class PageMemory; |
| class PersistentNode; |
| class Visitor; |
| class SafePointBarrier; |
| @@ -239,6 +240,7 @@ public: |
| static void init(); |
| static void shutdown(); |
| static void shutdownHeapIfNecessary(); |
| + bool isCleaningUp() { return m_isCleaningUp; } |
|
haraken
2014/07/09 05:17:49
isCleaningUp => isTerminating ?
We don't want to
wibling-chromium
2014/07/09 10:32:31
Done.
|
| static void attachMainThread(); |
| static void detachMainThread(); |
| @@ -507,6 +509,9 @@ public: |
| HeapStats& stats() { return m_stats; } |
| HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; } |
| + void setupHeapsForShutdown(); |
| + void visitLocalRoots(Visitor*); |
| + |
| private: |
| explicit ThreadState(); |
| ~ThreadState(); |
| @@ -612,7 +617,9 @@ public: |
| class SafePointAwareMutexLocker { |
| WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker); |
| public: |
| - explicit SafePointAwareMutexLocker(Mutex& mutex) : m_mutex(mutex), m_locked(false) |
| + explicit SafePointAwareMutexLocker(Mutex& mutex, ThreadState::StackState stackState = ThreadState::HeapPointersOnStack) |
| + : m_mutex(mutex) |
| + , m_locked(false) |
| { |
| ThreadState* state = ThreadState::current(); |
| do { |
| @@ -622,7 +629,7 @@ public: |
| // If another thread tries to do a GC at that time it might time out |
| // due to this thread not being at a safepoint and waiting on the lock. |
| if (!state->isSweepInProgress() && !state->isAtSafePoint()) { |
| - state->enterSafePoint(ThreadState::HeapPointersOnStack, this); |
| + state->enterSafePoint(stackState, this); |
| leaveSafePoint = true; |
| } |
| m_mutex.lock(); |
| @@ -657,6 +664,56 @@ private: |
| bool m_locked; |
| }; |
| +// Common header for heap pages. Needs to be defined before class Visitor. |
| +class BaseHeapPage { |
| +public: |
| + BaseHeapPage(PageMemory*, const GCInfo*, ThreadState*); |
| + virtual ~BaseHeapPage() { } |
| + |
| + // Check if the given address points to an object in this |
| + // heap page. If so, find the start of that object and mark it |
| + // using the given Visitor. Otherwise do nothing. The pointer must |
| + // be within the same aligned blinkPageSize as the this-pointer. |
| + // |
| + // This is used during conservative stack scanning to |
| + // conservatively mark all objects that could be referenced from |
| + // the stack. |
| + virtual void checkAndMarkPointer(Visitor*, Address) = 0; |
| + virtual bool contains(Address) = 0; |
| + |
| +#if ENABLE(GC_TRACING) |
| + virtual const GCInfo* findGCInfo(Address) = 0; |
| +#endif |
| + |
| + Address address() { return reinterpret_cast<Address>(this); } |
| + PageMemory* storage() const { return m_storage; } |
| + ThreadState* threadState() const { return m_threadState; } |
| + const GCInfo* gcInfo() { return m_gcInfo; } |
| + virtual bool isLargeObject() { return false; } |
| + virtual void markOrphaned() |
| + { |
| + m_threadState = 0; |
| + m_shuttingDown = false; |
| + m_traced = false; |
|
haraken
2014/07/09 05:17:48
Shall we also clear m_gcInfo here?
It looks a bit
wibling-chromium
2014/07/09 10:32:31
Sure, I don't have a strong feeling either way. Th
|
| + } |
| + bool orphaned() { return !m_threadState; } |
| + bool shuttingDown() { return m_shuttingDown; } |
| + void setShutdown() { m_shuttingDown = true; } |
|
haraken
2014/07/09 05:17:48
m_shuttingDown => m_terminating ?
wibling-chromium
2014/07/09 10:32:31
Done.
|
| + bool traced() { return m_traced; } |
| + void setTraced() { m_traced = true; } |
|
haraken
2014/07/09 05:17:48
m_traced => m_tracedAfterShutdown or m_tracedAfter
wibling-chromium
2014/07/09 10:32:31
Done. Changed it to m_tracedAfterOrphaned.
|
| + |
| +private: |
| + PageMemory* m_storage; |
| + const GCInfo* m_gcInfo; |
| + ThreadState* m_threadState; |
| + // Pointer sized integer to ensure proper alignment of the |
| + // HeapPage header. We use some of the bits to determine |
| + // whether the page is part of a shutting down thread or |
| + // if the page is traced after being shut down (orphaned). |
| + uintptr_t m_shuttingDown : 1; |
| + uintptr_t m_traced : 1; |
| +}; |
| + |
| } |
| #endif // ThreadState_h |