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

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

Issue 1410223006: Zero-initialize persistent heap vector inline backing buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for unit test, handle ANNOTATE_CONTIGUOUS_CONTAINER's non-support of inline buffers 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 | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/Handle.h
diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h
index f8bb60f77477339e150fa20f0ccf977f1a182acd..7c713d3347d1b2ebc9f23508f4c3640ea2c064a9 100644
--- a/third_party/WebKit/Source/platform/heap/Handle.h
+++ b/third_party/WebKit/Source/platform/heap/Handle.h
@@ -626,17 +626,39 @@ class PersistentHeapHashCountedSet : public PersistentHeapCollectionBase<HeapHas
template<typename T, size_t inlineCapacity = 0>
class PersistentHeapVector : public PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>> {
public:
- PersistentHeapVector() { }
+ PersistentHeapVector()
+ {
+ initializeUnusedSlots();
+ }
explicit PersistentHeapVector(size_t size)
: PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(size)
{
+ initializeUnusedSlots();
+ }
+
+ PersistentHeapVector(const PersistentHeapVector& other)
+ : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(other)
+ {
+ initializeUnusedSlots();
}
template<size_t otherCapacity>
PersistentHeapVector(const HeapVector<T, otherCapacity>& other)
: PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(other)
{
+ initializeUnusedSlots();
+ }
+
+private:
+ void initializeUnusedSlots()
+ {
+ // The PersistentHeapVector is allocated off heap along with its
+ // inline buffer (if any.) Maintain the invariant that unused
+ // slots are cleared for the off-heap inline buffer also.
+ size_t unusedSlots = this->capacity() - this->size();
+ if (unusedSlots)
+ this->clearUnusedSlots(this->end(), this->end() + unusedSlots);
}
};
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698