chromium/chromium-84-TraceInCollectionTrait-fix-template-specialization.patch

115 lines
5.3 KiB
Diff
Raw Normal View History

2020-07-15 16:13:12 +00:00
From bc9a96ef9eeab89276d67929f4a8a7d88f5dbc02 Mon Sep 17 00:00:00 2001
From: Stephan Hartmann <stha09@googlemail.com>
Date: Wed, 27 May 2020 13:37:25 +0000
Subject: [PATCH] GCC: fix template specialization in TraceInCollectionTrait
GCC complains that explicit specialization in non-namespace scope
is happening for TraceImpl. Move TraceImpl implementations into
different nested classes and select implementation using
std::conditional.
Bug: 819294
Change-Id: I8feea5f2aa6e1f87daad61f496d6b53b1bbc49ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217887
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772215}
---
diff --git a/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h b/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h
index 31e7888..2c0583f 100644
--- a/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h
+++ b/third_party/blink/renderer/platform/heap/collection_support/heap_hash_table_backing.h
@@ -241,50 +241,52 @@
static void Trace(blink::Visitor* visitor,
const KeyValuePair<Key, Value>& self) {
- TraceImpl(visitor, self);
+ TraceImpl::Trace(visitor, self);
}
private:
- template <bool = EphemeronHelper::is_ephemeron>
- static void TraceImpl(blink::Visitor* visitor,
- const KeyValuePair<Key, Value>& self);
-
- // Strongification of ephemerons, i.e., Weak/Strong and Strong/Weak.
- template <>
- static void TraceImpl<true>(blink::Visitor* visitor,
- const KeyValuePair<Key, Value>& self) {
+ struct TraceImplEphemerons {
// Strongification of ephemerons, i.e., Weak/Strong and Strong/Weak.
- // The helper ensures that helper.key always refers to the weak part and
- // helper.value always refers to the dependent part.
- // We distinguish ephemeron from Weak/Weak and Strong/Strong to allow users
- // to override visitation behavior. An example is creating a heap snapshot,
- // where it is useful to annotate values as being kept alive from keys
- // rather than the table.
- EphemeronHelper helper(&self.key, &self.value);
- // Strongify the weak part.
- blink::TraceCollectionIfEnabled<
- kNoWeakHandling, typename EphemeronHelper::KeyType,
- typename EphemeronHelper::KeyTraits>::Trace(visitor, helper.key);
- // Strongify the dependent part.
- visitor->TraceEphemeron(
- *helper.key, helper.value,
- blink::TraceCollectionIfEnabled<
- kNoWeakHandling, typename EphemeronHelper::ValueType,
- typename EphemeronHelper::ValueTraits>::Trace);
- }
+ static void Trace(blink::Visitor* visitor,
+ const KeyValuePair<Key, Value>& self) {
+ // Strongification of ephemerons, i.e., Weak/Strong and Strong/Weak.
+ // The helper ensures that helper.key always refers to the weak part and
+ // helper.value always refers to the dependent part.
+ // We distinguish ephemeron from Weak/Weak and Strong/Strong to allow
+ // users to override visitation behavior. An example is creating a heap
+ // snapshot, where it is useful to annotate values as being kept alive
+ // from keys rather than the table.
+ EphemeronHelper helper(&self.key, &self.value);
+ // Strongify the weak part.
+ blink::TraceCollectionIfEnabled<
+ kNoWeakHandling, typename EphemeronHelper::KeyType,
+ typename EphemeronHelper::KeyTraits>::Trace(visitor, helper.key);
+ // Strongify the dependent part.
+ visitor->TraceEphemeron(
+ *helper.key, helper.value,
+ blink::TraceCollectionIfEnabled<
+ kNoWeakHandling, typename EphemeronHelper::ValueType,
+ typename EphemeronHelper::ValueTraits>::Trace);
+ }
+ };
- template <>
- static void TraceImpl<false>(blink::Visitor* visitor,
- const KeyValuePair<Key, Value>& self) {
- // Strongification of non-ephemeron KVP, i.e., Strong/Strong or Weak/Weak.
- // Order does not matter here.
- blink::TraceCollectionIfEnabled<
- kNoWeakHandling, Key, typename Traits::KeyTraits>::Trace(visitor,
- &self.key);
- blink::TraceCollectionIfEnabled<
- kNoWeakHandling, Value,
- typename Traits::ValueTraits>::Trace(visitor, &self.value);
- }
+ struct TraceImplDefault {
+ static void Trace(blink::Visitor* visitor,
+ const KeyValuePair<Key, Value>& self) {
+ // Strongification of non-ephemeron KVP, i.e., Strong/Strong or Weak/Weak.
+ // Order does not matter here.
+ blink::TraceCollectionIfEnabled<
+ kNoWeakHandling, Key, typename Traits::KeyTraits>::Trace(visitor,
+ &self.key);
+ blink::TraceCollectionIfEnabled<
+ kNoWeakHandling, Value,
+ typename Traits::ValueTraits>::Trace(visitor, &self.value);
+ }
+ };
+
+ using TraceImpl = typename std::conditional<EphemeronHelper::is_ephemeron,
+ TraceImplEphemerons,
+ TraceImplDefault>::type;
};
template <typename Key, typename Value, typename Traits>