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

Unified Diff: Source/wtf/Vector.h

Issue 1088973006: Oilpan: Correct static_asserts about VectorTraits::canInitializeWithMemset (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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
« Source/platform/heap/Heap.h ('K') | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Vector.h
diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h
index b2881deb9cbbad3655e48ad5e3a717fa35d2e099..6a52675cb750dba0308bb88990634058930791e2 100644
--- a/Source/wtf/Vector.h
+++ b/Source/wtf/Vector.h
@@ -90,8 +90,6 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
struct VectorUnusedSlotClearer<true, T> {
static void clear(T* begin, T* end)
{
- // We clear out unused slots so that the visitor and the finalizer
- // do not visit them (or at least it does not matter if they do).
memset(begin, 0, sizeof(T) * (end - begin));
}
@@ -344,6 +342,10 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
void clearUnusedSlots(T* from, T* to)
{
+ // If the vector backing is garbage-collected and needs tracing
+ // or finalizing, we clear out the unused slots so that the visitor
+ // or the finalizer does not cause a problem when visiting the
+ // unused slots.
VectorUnusedSlotClearer<Allocator::isGarbageCollected && (VectorTraits<T>::needsDestruction || ShouldBeTraced<VectorTraits<T>>::value), T>::clear(from, to);
}
@@ -635,12 +637,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
Vector()
{
- // Unused slots are initialized to zero so that the visitor and the
- // finalizer can visit them safely. canInitializeWithMemset tells us
- // that the class does not expect matching constructor and
- // destructor calls as long as the memory is zeroed.
- static_assert(!Allocator::isGarbageCollected || !VectorTraits<T>::needsDestruction || VectorTraits<T>::canInitializeWithMemset, "class has problems with finalizers called on cleared memory");
- static_assert(!WTF::IsPolymorphic<T>::value || !VectorTraits<T>::canInitializeWithMemset, "cannot initialize with memset if there is a vtable");
+ static_assert(!WTF::IsPolymorphic<T>::value || !VectorTraits<T>::canInitializeWithMemset, "Cannot initialize with memset if there is a vtable");
ANNOTATE_NEW_BUFFER(begin(), capacity(), 0);
m_size = 0;
}
@@ -648,11 +645,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
explicit Vector(size_t size)
: Base(size)
{
- // Unused slots are initialized to zero so that the visitor and the
- // finalizer can visit them safely. canInitializeWithMemset tells us
- // that the class does not expect matching constructor and
- // destructor calls as long as the memory is zeroed.
- static_assert(!Allocator::isGarbageCollected || !VectorTraits<T>::needsDestruction || VectorTraits<T>::canInitializeWithMemset, "class has problems with finalizers called on cleared memory");
+ static_assert(!WTF::IsPolymorphic<T>::value || !VectorTraits<T>::canInitializeWithMemset, "Cannot initialize with memset if there is a vtable");
ANNOTATE_NEW_BUFFER(begin(), capacity(), size);
m_size = size;
TypeOperations::initialize(begin(), end());
« Source/platform/heap/Heap.h ('K') | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698