Commit 8a7d7d08 authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

heap: HeapHashMap: Use standard GC types

Bug: 1056170
Change-Id: If0f380fccf14c13a212f3101ad311f22d85f38a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616231
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarOmer Katz <omerkatz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841986}
parent a281de05
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_MAP_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_MAP_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_MAP_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_MAP_H_
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator_impl.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/hash_map.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h"
namespace blink { namespace blink {
...@@ -15,16 +17,30 @@ template <typename KeyArg, ...@@ -15,16 +17,30 @@ template <typename KeyArg,
typename HashArg = typename DefaultHash<KeyArg>::Hash, typename HashArg = typename DefaultHash<KeyArg>::Hash,
typename KeyTraitsArg = HashTraits<KeyArg>, typename KeyTraitsArg = HashTraits<KeyArg>,
typename MappedTraitsArg = HashTraits<MappedArg>> typename MappedTraitsArg = HashTraits<MappedArg>>
class HeapHashMap final : public HashMap<KeyArg, class HeapHashMap final : public GarbageCollected<HeapHashMap<KeyArg,
MappedArg,
HashArg,
KeyTraitsArg,
MappedTraitsArg>>,
public HashMap<KeyArg,
MappedArg, MappedArg,
HashArg, HashArg,
KeyTraitsArg, KeyTraitsArg,
MappedTraitsArg, MappedTraitsArg,
HeapAllocator> { HeapAllocator> {
IS_GARBAGE_COLLECTED_CONTAINER_TYPE();
DISALLOW_NEW(); DISALLOW_NEW();
static void CheckType() { public:
HeapHashMap() = default;
void Trace(Visitor* visitor) const {
CheckType();
HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg,
HeapAllocator>::Trace(visitor);
}
private:
static constexpr void CheckType() {
static_assert(std::is_trivially_destructible<HeapHashMap>::value, static_assert(std::is_trivially_destructible<HeapHashMap>::value,
"HeapHashMap must be trivially destructible."); "HeapHashMap must be trivially destructible.");
static_assert( static_assert(
...@@ -43,22 +59,8 @@ class HeapHashMap final : public HashMap<KeyArg, ...@@ -43,22 +59,8 @@ class HeapHashMap final : public HashMap<KeyArg,
"TraceWrapperV8Reference and " "TraceWrapperV8Reference and "
"non-traceable types as values."); "non-traceable types as values.");
} }
public:
template <typename>
static void* AllocateObject(size_t size) {
return ThreadHeap::Allocate<
HeapHashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>>(
size);
}
HeapHashMap() { CheckType(); }
}; };
template <typename T, typename U, typename V, typename W, typename X>
struct GCInfoTrait<HeapHashMap<T, U, V, W, X>>
: public GCInfoTrait<HashMap<T, U, V, W, X, HeapAllocator>> {};
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_MAP_H_ #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_MAP_H_
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