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

Side by Side 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, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 template< 620 template<
621 typename ValueArg, 621 typename ValueArg,
622 typename HashFunctions = typename DefaultHash<ValueArg>::Hash, 622 typename HashFunctions = typename DefaultHash<ValueArg>::Hash,
623 typename Traits = HashTraits<ValueArg>> 623 typename Traits = HashTraits<ValueArg>>
624 class PersistentHeapHashCountedSet : public PersistentHeapCollectionBase<HeapHas hCountedSet<ValueArg, HashFunctions, Traits>> { }; 624 class PersistentHeapHashCountedSet : public PersistentHeapCollectionBase<HeapHas hCountedSet<ValueArg, HashFunctions, Traits>> { };
625 625
626 template<typename T, size_t inlineCapacity = 0> 626 template<typename T, size_t inlineCapacity = 0>
627 class PersistentHeapVector : public PersistentHeapCollectionBase<HeapVector<T, i nlineCapacity>> { 627 class PersistentHeapVector : public PersistentHeapCollectionBase<HeapVector<T, i nlineCapacity>> {
628 public: 628 public:
629 PersistentHeapVector() { } 629 PersistentHeapVector()
630 {
631 initializeUnusedSlots();
632 }
630 633
631 explicit PersistentHeapVector(size_t size) 634 explicit PersistentHeapVector(size_t size)
632 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(size) 635 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(size)
633 { 636 {
637 initializeUnusedSlots();
638 }
639
640 PersistentHeapVector(const PersistentHeapVector& other)
641 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(other)
642 {
643 initializeUnusedSlots();
634 } 644 }
635 645
636 template<size_t otherCapacity> 646 template<size_t otherCapacity>
637 PersistentHeapVector(const HeapVector<T, otherCapacity>& other) 647 PersistentHeapVector(const HeapVector<T, otherCapacity>& other)
638 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(other) 648 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(other)
639 { 649 {
650 initializeUnusedSlots();
651 }
652
653 private:
654 void initializeUnusedSlots()
655 {
656 // The PersistentHeapVector is allocated off heap along with its
657 // inline buffer (if any.) Maintain the invariant that unused
658 // slots are cleared for the off-heap inline buffer also.
659 size_t unusedSlots = this->capacity() - this->size();
660 if (unusedSlots)
661 this->clearUnusedSlots(this->end(), this->end() + unusedSlots);
640 } 662 }
641 }; 663 };
642 664
643 template<typename T, size_t inlineCapacity = 0> 665 template<typename T, size_t inlineCapacity = 0>
644 class PersistentHeapDeque : public PersistentHeapCollectionBase<HeapDeque<T, inl ineCapacity>> { 666 class PersistentHeapDeque : public PersistentHeapCollectionBase<HeapDeque<T, inl ineCapacity>> {
645 public: 667 public:
646 PersistentHeapDeque() { } 668 PersistentHeapDeque() { }
647 669
648 template<size_t otherCapacity> 670 template<size_t otherCapacity>
649 PersistentHeapDeque(const HeapDeque<T, otherCapacity>& other) 671 PersistentHeapDeque(const HeapDeque<T, otherCapacity>& other)
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent. 1518 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent.
1497 static T* unwrap(const StorageType& value) { return value.get(); } 1519 static T* unwrap(const StorageType& value) { return value.get(); }
1498 }; 1520 };
1499 1521
1500 template<typename T> 1522 template<typename T>
1501 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; 1523 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
1502 1524
1503 } // namespace WTF 1525 } // namespace WTF
1504 1526
1505 #endif 1527 #endif
OLDNEW
« 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