1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
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}
---
.../heap_hash_table_backing.h | 80 ++++++++++---------
1 file changed, 41 insertions(+), 39 deletions(-)
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 31e7888b07f6..2c0583f660cc 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 @@ struct TraceInCollectionTrait<kNoWeakHandling,
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>
--
2.26.2
|