Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: Source/platform/heap/ThreadState.h

Issue 946163003: Prevent GCs when constructing GC mixin objects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Improve naming + optimize allocateOnHeapIndex() usage Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.h
diff --git a/Source/platform/heap/ThreadState.h b/Source/platform/heap/ThreadState.h
index a2428428e52eb5fb9229509dee82db3436e9dfc5..b4e5f992ccf35ae039fb7537f02e975ad355b861 100644
--- a/Source/platform/heap/ThreadState.h
+++ b/Source/platform/heap/ThreadState.h
@@ -638,6 +638,20 @@ private:
void snapshotFreeList();
#endif
+ // By entering a gc-forbidden scope, conservative GCs will not
+ // be allowed while handling an out-of-line allocation request.
+ // Intended used when constructing subclasses of GC mixins, where
+ // the object being constructed cannot be safely traced & marked
+ // fully should a GC be allowed while its subclasses are being
+ // constructed.
+ template<typename U, typename V> friend class AllocateObjectTrait;
+ void enterGCForbiddenScope() { m_gcForbiddenCount++; }
+ void leaveGCForbiddenScope()
+ {
+ ASSERT(m_gcForbiddenCount > 0);
+ m_gcForbiddenCount--;
+ }
+
static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
static uintptr_t s_mainThreadStackStart;
static uintptr_t s_mainThreadUnderestimatedStackSize;
@@ -665,6 +679,7 @@ private:
bool m_didV8GCAfterLastGC;
bool m_sweepForbidden;
size_t m_noAllocationCount;
+ size_t m_gcForbiddenCount;
size_t m_allocatedObjectSizeBeforeGC;
BaseHeap* m_heaps[NumberOfHeaps];
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698