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 dd5f2218dfcf8884e7577a843c209b61c1b96b63..fd6b792d1213261630714c01399b97fff51b042e 100644 |
--- a/third_party/WebKit/Source/platform/heap/ThreadState.h |
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.h |
@@ -320,6 +320,23 @@ class PLATFORM_EXPORT ThreadState { |
ThreadState* const thread_state_; |
}; |
+ // Per-thread lock that's held while a GC runs; can be |
+ // used by non-attached threads to safely coordinate access |
+ // to the heap while it is in a non-GCing state. |
hongchan
2017/06/01 16:08:55
From what I understand, this should not be abused
|
+ class GCLockScope final { |
+ STACK_ALLOCATED(); |
+ |
+ public: |
+ explicit GCLockScope(ThreadState* thread_state) |
+ : thread_state_(thread_state) { |
+ thread_state_->active_gc_mutex_.lock(); |
+ } |
+ ~GCLockScope() { thread_state_->active_gc_mutex_.unlock(); } |
+ |
+ private: |
+ ThreadState* const thread_state_; |
+ }; |
+ |
void FlushHeapDoesNotContainCacheIfNeeded(); |
// Safepoint related functionality. |
@@ -629,6 +646,7 @@ class PLATFORM_EXPORT ThreadState { |
void ReportMemoryToV8(); |
friend class SafePointScope; |
+ friend class GCLockScope; |
static WTF::ThreadSpecific<ThreadState*>* thread_specific_; |
@@ -656,6 +674,7 @@ class PLATFORM_EXPORT ThreadState { |
size_t mixins_being_constructed_count_; |
double accumulated_sweeping_time_; |
bool object_resurrection_forbidden_; |
+ Mutex active_gc_mutex_; |
BaseArena* arenas_[BlinkGC::kNumberOfArenas]; |
int vector_backing_arena_index_; |