Bug 1623957 - Part 14: Replace mozilla::IsPointer with std::is_pointer. r=jwalden
authorAndré Bargull <andre.bargull@gmail.com>
Sat, 21 Mar 2020 14:27:24 +0000
changeset 520015 5e7a6d158bc84f9b9094231afa25c58cf901486e
parent 520014 4d6099637f6c1a37482f3453bf7b8959280be648
child 520016 150ae4897b766cbc8a893c71bc12ac5a8c42a404
push id110801
push usershindli@mozilla.com
push dateSat, 21 Mar 2020 15:31:45 +0000
treeherderautoland@61a44ad12b15 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1623957, 1308236
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1623957 - Part 14: Replace mozilla::IsPointer with std::is_pointer. r=jwalden Also reenable the `static_assert` which was disabled for some reason in bug 1308236. (Bug 1308236 doesn't contain any information why this assertion had to be disabled.) Differential Revision: https://phabricator.services.mozilla.com/D67662
js/public/GCPolicyAPI.h
js/public/RootingAPI.h
js/src/vm/SharedMem.h
--- a/js/public/GCPolicyAPI.h
+++ b/js/public/GCPolicyAPI.h
@@ -49,28 +49,30 @@
 // referent type T.
 
 #ifndef GCPolicyAPI_h
 #define GCPolicyAPI_h
 
 #include "mozilla/Maybe.h"
 #include "mozilla/UniquePtr.h"
 
+#include <type_traits>
+
 #include "js/GCTypeMacros.h"  // JS_FOR_EACH_PUBLIC_GC_POINTER_TYPE
 #include "js/TraceKind.h"
 #include "js/TracingAPI.h"
 #include "js/TypeDecls.h"
 
 namespace JS {
 
 // Defines a policy for container types with non-GC, i.e. C storage. This
 // policy dispatches to the underlying struct for GC interactions.
 template <typename T>
 struct StructGCPolicy {
-  static_assert(!mozilla::IsPointer<T>::value,
+  static_assert(!std::is_pointer_v<T>,
                 "Pointer type not allowed for StructGCPolicy");
 
   static void trace(JSTracer* trc, T* tp, const char* name) { tp->trace(trc); }
 
   static void sweep(T* tp) { return tp->sweep(); }
 
   static bool needsSweep(T* tp) { return tp->needsSweep(); }
 
@@ -96,17 +98,17 @@ struct IgnoreGCPolicy {
 };
 template <>
 struct GCPolicy<uint32_t> : public IgnoreGCPolicy<uint32_t> {};
 template <>
 struct GCPolicy<uint64_t> : public IgnoreGCPolicy<uint64_t> {};
 
 template <typename T>
 struct GCPointerPolicy {
-  static_assert(mozilla::IsPointer<T>::value,
+  static_assert(std::is_pointer_v<T>,
                 "Non-pointer type not allowed for GCPointerPolicy");
 
   static void trace(JSTracer* trc, T* vp, const char* name) {
     // It's not safe to trace unbarriered pointers except as part of root
     // marking.
     UnsafeTraceRoot(trc, vp, name);
   }
   static bool needsSweep(T* vp) {
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -6,17 +6,16 @@
 
 #ifndef js_RootingAPI_h
 #define js_RootingAPI_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/GuardObjects.h"
 #include "mozilla/LinkedList.h"
-#include "mozilla/TypeTraits.h"
 
 #include <type_traits>
 #include <utility>
 
 #include "jspubtd.h"
 
 #include "js/ComparisonOperators.h"  // JS::detail::DefineComparisonOps
 #include "js/GCAnnotations.h"
@@ -588,17 +587,17 @@ class MOZ_NONHEAP_CLASS Handle : public 
       Handle<S> handle,
       std::enable_if_t<std::is_convertible_v<S, T>, int> dummy = 0) {
     static_assert(sizeof(Handle<T>) == sizeof(T*),
                   "Handle must be binary compatible with T*.");
     ptr = reinterpret_cast<const T*>(handle.address());
   }
 
   MOZ_IMPLICIT Handle(decltype(nullptr)) {
-    static_assert(mozilla::IsPointer<T>::value,
+    static_assert(std::is_pointer_v<T>,
                   "nullptr_t overload not valid for non-pointer types");
     static void* const ConstNullValue = nullptr;
     ptr = reinterpret_cast<const T*>(&ConstNullValue);
   }
 
   MOZ_IMPLICIT Handle(MutableHandle<T> handle) { ptr = handle.address(); }
 
   /*
--- a/js/src/vm/SharedMem.h
+++ b/js/src/vm/SharedMem.h
@@ -6,18 +6,17 @@
 
 #ifndef vm_SharedMem_h
 #define vm_SharedMem_h
 
 #include <type_traits>
 
 template <typename T>
 class SharedMem {
-  // static_assert(mozilla::IsPointer<T>::value,
-  //               "SharedMem encapsulates pointer types");
+  static_assert(std::is_pointer_v<T>, "SharedMem encapsulates pointer types");
 
   enum Sharedness { IsUnshared, IsShared };
 
   T ptr_;
 #ifdef DEBUG
   Sharedness sharedness_;
 #endif