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

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: add assert 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
Index: Source/platform/heap/ThreadState.h
diff --git a/Source/platform/heap/ThreadState.h b/Source/platform/heap/ThreadState.h
index a2428428e52eb5fb9229509dee82db3436e9dfc5..df370839fbdda7327f5e9594c4e5fb1b98488e16 100644
--- a/Source/platform/heap/ThreadState.h
+++ b/Source/platform/heap/ThreadState.h
@@ -638,6 +638,19 @@ private:
void snapshotFreeList();
#endif
+ // By entering a no-gc allowed scope, conservative GCs will not
+ // be forced 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.
+ template<typename U, typename V> friend class AllocateObjectTrait;
+ void enterNoGCAllowedScope() { m_noGCAllowedCount++; }
haraken 2015/02/23 08:24:23 enterGCForbiddenScope ? (for consistency with Swee
sof 2015/02/23 10:29:02 Switched naming to align with that.
+ void leaveNoGCAllowedScope()
+ {
+ ASSERT(m_noGCAllowedCount > 0);
+ m_noGCAllowedCount--;
+ }
+
static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
static uintptr_t s_mainThreadStackStart;
static uintptr_t s_mainThreadUnderestimatedStackSize;
@@ -665,6 +678,7 @@ private:
bool m_didV8GCAfterLastGC;
bool m_sweepForbidden;
size_t m_noAllocationCount;
+ size_t m_noGCAllowedCount;
size_t m_allocatedObjectSizeBeforeGC;
BaseHeap* m_heaps[NumberOfHeaps];

Powered by Google App Engine
This is Rietveld 408576698