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

Unified Diff: third_party/WebKit/Source/platform/heap/TraceTraits.h

Issue 1407143003: Oilpan: Add more static/runtime ASSERTs about ShouldBeTraced (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/TraceTraits.h
diff --git a/third_party/WebKit/Source/platform/heap/TraceTraits.h b/third_party/WebKit/Source/platform/heap/TraceTraits.h
index 285c6d7ccd5d59a48bdfc414fcbdf91c5f3e3f4d..110b7d5466f4816e9440a26e33b1a677e5487360 100644
--- a/third_party/WebKit/Source/platform/heap/TraceTraits.h
+++ b/third_party/WebKit/Source/platform/heap/TraceTraits.h
@@ -101,7 +101,10 @@ struct TraceIfEnabled;
template<typename T>
struct TraceIfEnabled<T, false> {
template<typename VisitorDispatcher>
- static void trace(VisitorDispatcher, T&) { }
+ static void trace(VisitorDispatcher, T&)
+ {
+ static_assert(!WTF::NeedsTracing<T>::value, "T should not be traced");
+ }
};
template<typename T>
@@ -109,6 +112,7 @@ struct TraceIfEnabled<T, true> {
template<typename VisitorDispatcher>
static void trace(VisitorDispatcher visitor, T& t)
{
+ static_assert(WTF::NeedsTracing<T>::value || WTF::IsWeak<T>::value, "T should be traced");
visitor->trace(t);
}
};
@@ -118,7 +122,11 @@ template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldW
template<WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Traits>
struct TraceCollectionIfEnabled<false, WTF::NoWeakHandlingInCollections, strongify, T, Traits> {
template<typename VisitorDispatcher>
- static bool trace(VisitorDispatcher, T&) { return false; }
+ static bool trace(VisitorDispatcher, T&)
+ {
+ static_assert(!WTF::NeedsTracingTrait<Traits>::value, "Traits should not be traced");
+ return false;
+ }
};
template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Traits>
@@ -126,6 +134,7 @@ struct TraceCollectionIfEnabled {
template<typename VisitorDispatcher>
static bool trace(VisitorDispatcher visitor, T& t)
{
+ static_assert(WTF::NeedsTracingTrait<Traits>::value || weakHandlingFlag == WTF::WeakHandlingInCollections, "Traits should be traced");
return WTF::TraceInCollectionTrait<weakHandlingFlag, strongify, T, Traits>::trace(visitor, t);
}
};
@@ -159,6 +168,7 @@ template<typename T> class TraceTrait<const T> : public TraceTrait<T> { };
template<typename T>
void TraceTrait<T>::trace(Visitor* visitor, void* self)
{
+ static_assert(WTF::NeedsTracing<T>::value || WTF::IsWeak<T>::value, "T should be traced");
if (visitor->markingMode() == Visitor::GlobalMarking) {
// Switch to inlined global marking dispatch.
static_cast<T*>(self)->trace(InlinedGlobalMarkingVisitor(visitor));
@@ -170,6 +180,7 @@ void TraceTrait<T>::trace(Visitor* visitor, void* self)
template<typename T>
void TraceTrait<T>::trace(InlinedGlobalMarkingVisitor visitor, void* self)
{
+ static_assert(WTF::NeedsTracing<T>::value || WTF::IsWeak<T>::value, "T should be traced");
sof 2015/10/19 06:33:18 What is this assert for (in this context)? NeedsTr
static_cast<T*>(self)->trace(visitor);
}
@@ -338,6 +349,7 @@ struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, T, Traits>
template<typename VisitorDispatcher>
static bool trace(VisitorDispatcher visitor, T& t)
{
+ ASSERT(NeedsTracingTrait<Traits>::value);
visitor->trace(t);
return false;
}
@@ -419,6 +431,7 @@ struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, blink::Hea
{
static_assert(strongify == WTF::WeakPointersActStrong, "An on-stack HeapHashTable needs to be visited strongly.");
+ ASSERT(NeedsTracingTrait<Traits>::value || Traits::weakHandlingFlag == WeakHandlingInCollections);
Value* array = reinterpret_cast<Value*>(self);
blink::HeapObjectHeader* header = blink::HeapObjectHeader::fromPayload(self);
ASSERT(header->checkHeader());
@@ -549,6 +562,7 @@ struct TraceInCollectionTrait<NoWeakHandlingInCollections, strongify, ListHashSe
template<typename VisitorDispatcher>
static bool trace(VisitorDispatcher visitor, Node* node)
{
+ ASSERT(NeedsTracingTrait<Traits>::value);
traceListHashSetValue(visitor, node->m_value);
// Just mark the node without tracing because we already traced the
// contents, and there is no need to trace the next and prev fields
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698