Commit 30dd4a76 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

heap: Cleanup strongification of WeakMember

Merge TraceNoWeakHandlingInCollectionHelper into regular
TraceInCollectionTrait.

Bug: 1019191
Change-Id: Ie958cd188bdb3cd917b7753fc1ce4803ce1fba49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899490Reviewed-by: default avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712520}
parent 15d76a57
......@@ -347,34 +347,6 @@ struct TraceKeyValuePairTraits {
namespace WTF {
// Helper used for tracing without weak handling in collections that support
// weak handling. It dispatches to |TraceInCollection| if the provided trait
// supports weak handling, and to |Trace| otherwise.
template <typename T,
typename Traits,
WTF::WeakHandlingFlag traitsWeakness = Traits::kWeakHandlingFlag>
struct TraceNoWeakHandlingInCollectionHelper;
template <typename T, typename Traits>
struct TraceNoWeakHandlingInCollectionHelper<blink::WeakMember<T>,
Traits,
kWeakHandling> {
static bool Trace(blink::Visitor* visitor, blink::WeakMember<T>& t) {
visitor->Trace(t.Get());
return false;
}
};
template <typename T, typename Traits>
struct TraceNoWeakHandlingInCollectionHelper<T, Traits, kNoWeakHandling> {
static bool Trace(blink::Visitor* visitor, T& t) {
static_assert(IsTraceableInCollectionTrait<Traits>::value,
"T should not be traced");
visitor->Trace(t);
return false;
}
};
// Catch-all for types that have a way to trace that don't have special
// handling for weakness in collections. This means that if this type
// contains WeakMember fields, they will simply be zeroed, but the entry
......@@ -386,7 +358,19 @@ struct TraceInCollectionTrait<kNoWeakHandling, T, Traits> {
static bool IsAlive(T& t) { return true; }
static bool Trace(blink::Visitor* visitor, T& t) {
return TraceNoWeakHandlingInCollectionHelper<T, Traits>::Trace(visitor, t);
static_assert(IsTraceableInCollectionTrait<Traits>::value,
"T should not be traced");
visitor->Trace(t);
return false;
}
};
template <typename T, typename Traits>
struct TraceInCollectionTrait<kNoWeakHandling, blink::WeakMember<T>, Traits> {
static bool Trace(blink::Visitor* visitor, blink::WeakMember<T>& t) {
// Extract raw pointer to avoid using the WeakMember<> overload in Visitor.
visitor->Trace(t.Get());
return false;
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment