chromium/third_party/blink/renderer/platform/heap/member.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_MEMBER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_MEMBER_H_

#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/heap/thread_state_storage.h"
#include "third_party/blink/renderer/platform/heap/write_barrier.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/construct_traits.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/hash_traits.h"
#include "third_party/blink/renderer/platform/wtf/type_traits.h"
#include "v8/include/cppgc/member.h"  // IWYU pragma: export

namespace blink {

Member;

WeakMember;

UntracedMember;

namespace subtle {
UncompressedMember;
}

template <typename T>
inline bool IsHashTableDeletedValue(const Member<T>& m) {}

constexpr auto kMemberDeletedValue =;

ThreadingTrait<blink::Member<T>>;

ThreadingTrait<blink::WeakMember<T>>;

ThreadingTrait<blink::UntracedMember<T>>;

template <typename T>
inline void swap(Member<T>& a, Member<T>& b) {}

static constexpr bool kBlinkMemberGCHasDebugChecks =;

// We should never bloat the Member<> wrapper.
// NOTE: The Member<void*> works as we never use this Member in a trace method.
static_assert;

}  // namespace blink

namespace WTF {

IsTraceable<blink::Member<T>>;

IsWeak<blink::WeakMember<T>>;

IsTraceable<blink::WeakMember<T>>;

// Peeker type that allows for using all kinds of Member, Persistent, and T*
// interchangeably. This is necessary for collection methods that are called
// directly with any of those types.
template <typename T>
class ValuePeeker final {};

// Default hash for hash tables with Member<>-derived elements.
template <typename T, typename MemberType>
struct BaseMemberHashTraits : SimpleClassHashTraits<MemberType> {};

// Custom HashTraits<Member<Type>> can inherit this type.
template <typename T>
struct MemberHashTraits : BaseMemberHashTraits<T, blink::Member<T>> {};
HashTraits<blink::Member<T>>;

// Custom HashTraits<WeakMember<Type>> can inherit this type.
template <typename T>
struct WeakMemberHashTraits : BaseMemberHashTraits<T, blink::WeakMember<T>> {};
HashTraits<blink::WeakMember<T>>;

// Custom HashTraits<UntracedMember<Type>> can inherit this type.
template <typename T>
struct UntracedMemberHashTraits
    : BaseMemberHashTraits<T, blink::UntracedMember<T>> {};
HashTraits<blink::UntracedMember<T>>;

template <typename T>
class MemberConstructTraits {};

ConstructTraits<blink::Member<T>, Traits, Allocator>;

ConstructTraits<blink::WeakMember<T>, Traits, Allocator>;

}  // namespace WTF

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_MEMBER_H_