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

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