Commit 4479c25d authored by Michael Lippautz's avatar Michael Lippautz Committed by Chromium LUCI CQ

heap: Adjust Persistent hashtraits for deleted values

Add the proper HashTrait to use the sentinel value for the library
version.

Bug: 1056170
Change-Id: I62e09904f46a7bb0f3f89d5687e8767d0b936b62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643281
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@{#846059}
parent 4bb7d1f5
......@@ -56,16 +56,17 @@ template <typename T>
struct VectorTraits<blink::CrossThreadWeakPersistent<T>>
: PersistentVectorTraitsBase<blink::CrossThreadWeakPersistent<T>> {};
template <typename T, typename H>
struct HandleHashTraits : SimpleClassHashTraits<H> {
STATIC_ONLY(HandleHashTraits);
template <typename T, typename PersistentType>
struct BasePersistentHashTraits : SimpleClassHashTraits<PersistentType> {
STATIC_ONLY(BasePersistentHashTraits);
// TODO: Implement proper const'ness for iterator types. Requires support
// in the marking Visitor.
using PeekInType = T*;
using IteratorGetType = H*;
using IteratorConstGetType = const H*;
using IteratorReferenceType = H&;
using IteratorConstReferenceType = const H&;
using IteratorGetType = PersistentType*;
using IteratorConstGetType = const PersistentType*;
using IteratorReferenceType = PersistentType&;
using IteratorConstReferenceType = const PersistentType&;
static IteratorReferenceType GetToReferenceConversion(IteratorGetType x) {
return *x;
}
......@@ -77,20 +78,36 @@ struct HandleHashTraits : SimpleClassHashTraits<H> {
using PeekOutType = T*;
template <typename U>
static void Store(const U& value, H& storage) {
static void Store(const U& value, PersistentType& storage) {
storage = value;
}
static PeekOutType Peek(const H& value) { return value; }
static PeekOutType Peek(const PersistentType& value) { return value; }
static void ConstructDeletedValue(PersistentType& slot, bool) {
#if BUILDFLAG(USE_V8_OILPAN)
slot = cppgc::kSentinelPointer;
#else // !USE_V8_OILPAN
slot = WTF::kHashTableDeletedValue;
#endif // !USE_V8_OILPAN
}
static bool IsDeletedValue(const PersistentType& value) {
#if BUILDFLAG(USE_V8_OILPAN)
return value.Get() == cppgc::kSentinelPointer;
#else // !USE_V8_OILPAN
return value.IsHashTableDeletedValue();
#endif // !USE_V8_OILPAN
}
};
template <typename T>
struct HashTraits<blink::Persistent<T>>
: HandleHashTraits<T, blink::Persistent<T>> {};
: BasePersistentHashTraits<T, blink::Persistent<T>> {};
template <typename T>
struct HashTraits<blink::CrossThreadPersistent<T>>
: HandleHashTraits<T, blink::CrossThreadPersistent<T>> {};
: BasePersistentHashTraits<T, blink::CrossThreadPersistent<T>> {};
template <typename T>
struct DefaultHash<blink::Persistent<T>> {
......
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