Index: third_party/WebKit/Source/platform/wtf/HashTraits.h |
diff --git a/third_party/WebKit/Source/platform/wtf/HashTraits.h b/third_party/WebKit/Source/platform/wtf/HashTraits.h |
index c0bbf579156f97c5b0933a5288c58b2ce73282a3..1e20d5ff5a9f5f693824a200d735b54eda2a6d0e 100644 |
--- a/third_party/WebKit/Source/platform/wtf/HashTraits.h |
+++ b/third_party/WebKit/Source/platform/wtf/HashTraits.h |
@@ -339,6 +339,73 @@ template <typename First, typename Second> |
struct HashTraits<std::pair<First, Second>> |
: public PairHashTraits<HashTraits<First>, HashTraits<Second>> {}; |
+template <typename FirstTraitsArg, |
+ typename SecondTraitsArg, |
+ typename ThirdTraitsArg> |
+struct TupleHashTraits |
+ : GenericHashTraits<std::tuple<typename FirstTraitsArg::TraitType, |
+ typename SecondTraitsArg::TraitType, |
+ typename ThirdTraitsArg::TraitType>> { |
+ typedef FirstTraitsArg FirstTraits; |
+ typedef SecondTraitsArg SecondTraits; |
+ typedef ThirdTraitsArg ThirdTraits; |
+ typedef std::tuple<typename FirstTraits::TraitType, |
+ typename SecondTraits::TraitType, |
+ typename ThirdTraits::TraitType> |
+ TraitType; |
+ typedef std::tuple<typename FirstTraits::EmptyValueType, |
+ typename SecondTraits::EmptyValueType, |
+ typename ThirdTraits::EmptyValueType> |
+ EmptyValueType; |
+ |
+ static const bool kEmptyValueIsZero = FirstTraits::kEmptyValueIsZero && |
+ SecondTraits::kEmptyValueIsZero && |
+ ThirdTraits::kEmptyValueIsZero; |
+ static EmptyValueType EmptyValue() { |
+ return std::make_tuple(FirstTraits::EmptyValue(), |
+ SecondTraits::EmptyValue(), |
+ ThirdTraits::EmptyValue()); |
+ } |
+ |
+ static const bool kHasIsEmptyValueFunction = |
+ FirstTraits::kHasIsEmptyValueFunction || |
+ SecondTraits::kHasIsEmptyValueFunction || |
+ ThirdTraits::kHasIsEmptyValueFunction; |
+ static bool IsEmptyValue(const TraitType& value) { |
+ return IsHashTraitsEmptyValue<FirstTraits>(std::get<0>(value)) && |
+ IsHashTraitsEmptyValue<SecondTraits>(std::get<1>(value)) && |
+ IsHashTraitsEmptyValue<ThirdTraits>(std::get<2>(value)); |
+ } |
+ |
+ static const unsigned kMinimumTableSize = FirstTraits::kMinimumTableSize; |
+ |
+ static void ConstructDeletedValue(TraitType& slot, bool zero_value) { |
+ FirstTraits::ConstructDeletedValue(std::get<0>(slot), zero_value); |
+ // For GC collections the memory for the backing is zeroed when it is |
+ // allocated, and the constructors may take advantage of that, |
+ // especially if a GC occurs during insertion of an entry into the |
+ // table. This slot is being marked deleted, but If the slot is reused |
+ // at a later point, the same assumptions around memory zeroing must |
+ // hold as they did at the initial allocation. Therefore we zero the |
+ // value part of the slot here for GC collections. |
+ if (zero_value) { |
+ memset(reinterpret_cast<void*>(&std::get<1>(slot)), 0, |
+ sizeof(std::get<1>(slot))); |
+ memset(reinterpret_cast<void*>(&std::get<2>(slot)), 0, |
+ sizeof(std::get<2>(slot))); |
+ } |
+ } |
+ static bool IsDeletedValue(const TraitType& value) { |
+ return FirstTraits::IsDeletedValue(std::get<0>(value)); |
+ } |
+}; |
+ |
+template <typename First, typename Second, typename Third> |
+struct HashTraits<std::tuple<First, Second, Third>> |
+ : public TupleHashTraits<HashTraits<First>, |
+ HashTraits<Second>, |
+ HashTraits<Third>> {}; |
+ |
template <typename KeyTypeArg, typename ValueTypeArg> |
struct KeyValuePair { |
typedef KeyTypeArg KeyType; |
@@ -423,6 +490,7 @@ struct NullableHashTraits : public HashTraits<T> { |
using WTF::HashTraits; |
using WTF::PairHashTraits; |
+using WTF::TupleHashTraits; |
using WTF::NullableHashTraits; |
using WTF::SimpleClassHashTraits; |