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

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

Issue 1166793002: Oilpan: add assert to verify eager finalization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.h
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
index 19d1bf2237e774052e1ba69a4502efb15b2fdfd0..63625d0e4d0ce8e272a4cfddb5e8d649f04f52cc 100644
--- a/Source/platform/heap/Heap.h
+++ b/Source/platform/heap/Heap.h
@@ -1128,9 +1128,40 @@ inline bool Heap::isNormalHeapIndex(int index)
}
#if ENABLE_LAZY_SWEEPING
-#define EAGERLY_FINALIZE() typedef int IsEagerlyFinalizedMarker
+#define DECLARE_EAGER_FINALIZATION_OPERATOR_NEW() \
+public: \
+ GC_PLUGIN_IGNORE("491488") \
+ void* operator new(size_t size) \
+ { \
+ return allocateObject(size, true); \
+ }
#define EAGERLY_FINALIZE_WILL_BE_REMOVED()
+#if ENABLE(ASSERT)
+class VerifyEagerFinalization {
+public:
+ ~VerifyEagerFinalization()
+ {
+ // If this assert triggers, the class annotated as eagerly
+ // finalized ended up not being allocated on the heap
+ // set aside for eager finalization. The reason is most
+ // likely that the effective 'operator new' overload for
+ // this class' leftmost base is for a class that is not
+ // eagerly finalized. Declaring and defining an 'operator new'
+ // for this class is what's required -- consider using
+ // DECLARE_EAGER_FINALIZATION_OPERATOR_NEW().
+ ASSERT(ThreadState::current()->isEagerlySweeping());
haraken 2015/06/03 03:52:35 Instead of introducing isEagerlySweeping(), you mi
sof 2015/06/03 11:35:16 That gets us there also and with less noise; done.
+ }
+};
+#define EAGERLY_FINALIZE() \
+private: \
+ VerifyEagerFinalization m_verifyEagerFinalization; \
+public: \
+ typedef int IsEagerlyFinalizedMarker
+#else
+#define EAGERLY_FINALIZE() typedef int IsEagerlyFinalizedMarker
+#endif
#else
+#define DECLARE_EAGER_FINALIZATION_OPERATOR_NEW()
#define EAGERLY_FINALIZE()
// TODO(Oilpan): define in terms of Oilpan's EAGERLY_FINALIZE() once lazy
// sweeping is enabled non-Oilpan.
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698