Commit 2e86afc0 authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

heap: HeapDeque: Use standard GC types

Bug: 1056170
Change-Id: Ibbde34d16df541c287f8542dec81e15d4664b05c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616203
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841733}
parent 481d846c
......@@ -6,41 +6,25 @@
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_DEQUE_H_
#include "third_party/blink/renderer/platform/heap/heap_allocator_impl.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/wtf/deque.h"
#include "third_party/blink/renderer/platform/wtf/type_traits.h"
namespace blink {
template <typename T>
class HeapDeque final : public Deque<T, 0, HeapAllocator> {
IS_GARBAGE_COLLECTED_CONTAINER_TYPE();
class HeapDeque final : public GarbageCollected<HeapDeque<T>>,
public Deque<T, 0, HeapAllocator> {
DISALLOW_NEW();
static void CheckType() {
static_assert(WTF::IsMemberType<T>::value,
"HeapDeque supports only Member.");
static_assert(std::is_trivially_destructible<HeapDeque>::value,
"HeapDeque must be trivially destructible.");
static_assert(WTF::IsTraceable<T>::value,
"For vectors without traceable elements, use Deque<> instead "
"of HeapDeque<>");
}
public:
template <typename>
static void* AllocateObject(size_t size) {
return ThreadHeap::Allocate<HeapDeque<T>>(size);
}
HeapDeque() { CheckType(); }
HeapDeque() = default;
explicit HeapDeque(wtf_size_t size) : Deque<T, 0, HeapAllocator>(size) {
CheckType();
}
HeapDeque(wtf_size_t size, const T& val)
: Deque<T, 0, HeapAllocator>(size, val) {
CheckType();
}
HeapDeque& operator=(const HeapDeque& other) {
......@@ -50,11 +34,23 @@ class HeapDeque final : public Deque<T, 0, HeapAllocator> {
}
HeapDeque(const HeapDeque<T>& other) : Deque<T, 0, HeapAllocator>(other) {}
};
template <typename T>
struct GCInfoTrait<HeapDeque<T>>
: public GCInfoTrait<Deque<T, 0, HeapAllocator>> {};
void Trace(Visitor* visitor) const {
CheckType();
Deque<T, 0, HeapAllocator>::Trace(visitor);
}
private:
static constexpr void CheckType() {
static_assert(WTF::IsMemberType<T>::value,
"HeapDeque supports only Member.");
static_assert(std::is_trivially_destructible<HeapDeque>::value,
"HeapDeque must be trivially destructible.");
static_assert(WTF::IsTraceable<T>::value,
"For vectors without traceable elements, use Deque<> instead "
"of HeapDeque<>");
}
};
} // namespace blink
......
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