Bug 1623957 - Part 5: Replace mozilla::RemovePointer with std::remove_pointer. r=jwalden
authorAndré Bargull <andre.bargull@gmail.com>
Sat, 21 Mar 2020 14:19:34 +0000
changeset 520006 4e839607dda0e2d12a6f4297f5e57bf7f7b44da6
parent 520005 ee8e9c99d479d97d96d46fa03aac6ab38cf8a8bf
child 520007 680f4f1018e65fd996606e21aa81861df786c548
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
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 5: Replace mozilla::RemovePointer with std::remove_pointer. r=jwalden Differential Revision: https://phabricator.services.mozilla.com/D67652
js/src/gc/Marking.cpp
js/src/gc/Policy.h
js/src/gc/WeakMap-inl.h
js/src/vm/SharedMem.h
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -6,17 +6,16 @@
 
 #include "gc/Marking-inl.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/ReentrancyGuard.h"
 #include "mozilla/ScopeExit.h"
-#include "mozilla/TypeTraits.h"
 #include "mozilla/Unused.h"
 
 #include <algorithm>
 #include <type_traits>
 
 #include "jsfriendapi.h"
 
 #include "builtin/ModuleObject.h"
@@ -244,19 +243,18 @@ void js::CheckTracedThing(JSTracer* trc,
     MOZ_ASSERT_IF(!isClearEdgesTracer, CurrentThreadIsPerformingGC());
   }
 
   // It shouldn't be possible to trace into zones used by helper threads, except
   // for use of ClearEdgesTracer by GCManagedDeletePolicy on a helper thread.
   MOZ_ASSERT_IF(!isClearEdgesTracer, !zone->usedByHelperThread());
 
   MOZ_ASSERT(thing->isAligned());
-  MOZ_ASSERT(
-      MapTypeToTraceKind<typename mozilla::RemovePointer<T>::Type>::kind ==
-      thing->getTraceKind());
+  MOZ_ASSERT(MapTypeToTraceKind<std::remove_pointer_t<T>>::kind ==
+             thing->getTraceKind());
 
   if (isGcMarkingTracer) {
     GCMarker* gcMarker = GCMarker::fromTracer(trc);
     MOZ_ASSERT(zone->shouldMarkInZone());
 
     MOZ_ASSERT_IF(gcMarker->shouldCheckCompartments(),
                   zone->isCollectingFromAnyThread() || zone->isAtomsZone());
 
--- a/js/src/gc/Policy.h
+++ b/js/src/gc/Policy.h
@@ -4,27 +4,28 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* JS Garbage Collector. */
 
 #ifndef gc_Policy_h
 #define gc_Policy_h
 
-#include "mozilla/TypeTraits.h"
+#include <type_traits>
+
 #include "gc/Barrier.h"
 #include "gc/Marking.h"
 #include "js/GCPolicyAPI.h"
 
 namespace js {
 
 // Define the GCPolicy for all internal pointers.
 template <typename T>
 struct InternalGCPointerPolicy : public JS::GCPointerPolicy<T> {
-  using Type = typename mozilla::RemovePointer<T>::Type;
+  using Type = std::remove_pointer_t<T>;
 
 #define IS_BASE_OF_OR(_1, BaseType, _2, _3) \
   std::is_base_of<BaseType, Type>::value ||
   static_assert(
       JS_FOR_EACH_TRACEKIND(IS_BASE_OF_OR) false,
       "InternalGCPointerPolicy must only be used for GC thing pointers");
 #undef IS_BASE_OF_OR
 
--- a/js/src/gc/WeakMap-inl.h
+++ b/js/src/gc/WeakMap-inl.h
@@ -8,16 +8,17 @@
 #define gc_WeakMap_inl_h
 
 #include "gc/WeakMap.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Unused.h"
 
 #include <algorithm>
+#include <type_traits>
 
 #include "gc/Zone.h"
 #include "js/TraceKind.h"
 #include "vm/JSContext.h"
 
 namespace js {
 namespace gc {
 
@@ -81,17 +82,17 @@ inline JSObject* GetDelegate(gc::Cell* c
 
 } /* namespace detail */
 } /* namespace gc */
 
 template <class K, class V>
 WeakMap<K, V>::WeakMap(JSContext* cx, JSObject* memOf)
     : Base(cx->zone()), WeakMapBase(memOf, cx->zone()) {
   using ElemType = typename K::ElementType;
-  using NonPtrType = typename mozilla::RemovePointer<ElemType>::Type;
+  using NonPtrType = std::remove_pointer_t<ElemType>;
 
   // The object's TraceKind needs to be added to CC graph if this object is
   // used as a WeakMap key, otherwise the key is considered to be pointed from
   // somewhere unknown, and results in leaking the subgraph which contains the
   // key. See the comments in NoteWeakMapsTracer::trace for more details.
   static_assert(JS::IsCCTraceKind(NonPtrType::TraceKind),
                 "Object's TraceKind should be added to CC graph.");
 
--- a/js/src/vm/SharedMem.h
+++ b/js/src/vm/SharedMem.h
@@ -4,16 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_SharedMem_h
 #define vm_SharedMem_h
 
 #include "mozilla/TypeTraits.h"
 
+#include <type_traits>
+
 template <typename T>
 class SharedMem {
   // static_assert(mozilla::IsPointer<T>::value,
   //               "SharedMem encapsulates pointer types");
 
   enum Sharedness { IsUnshared, IsShared };
 
   T ptr_;
@@ -73,19 +75,18 @@ class SharedMem {
   // Reinterpret-cast the pointer to type U, preserving sharedness.
   // Eg, "obj->dataPointerEither().cast<uint8_t*>()" yields a
   // SharedMem<uint8_t*>.
   template <typename U>
   inline SharedMem<U> cast() const {
 #ifdef DEBUG
     MOZ_ASSERT(asValue() %
                    sizeof(mozilla::Conditional<
-                          mozilla::IsVoid<
-                              typename mozilla::RemovePointer<U>::Type>::value,
-                          char, typename mozilla::RemovePointer<U>::Type>) ==
+                          mozilla::IsVoid<std::remove_pointer_t<U>>::value,
+                          char, std::remove_pointer_t<U>>) ==
                0);
     if (sharedness_ == IsUnshared) {
       return SharedMem<U>::unshared(unwrap());
     }
 #endif
     return SharedMem<U>::shared(unwrap());
   }
 
@@ -117,21 +118,19 @@ class SharedMem {
     return result;
   }
 
   uintptr_t asValue() const { return reinterpret_cast<uintptr_t>(ptr_); }
 
   // Cast to char*, add nbytes, and cast back to T.  Simplifies code in a few
   // places.
   SharedMem addBytes(size_t nbytes) {
-    MOZ_ASSERT(nbytes %
-                   sizeof(mozilla::Conditional<
-                          mozilla::IsVoid<
-                              typename mozilla::RemovePointer<T>::Type>::value,
-                          char, typename mozilla::RemovePointer<T>::Type>) ==
+    MOZ_ASSERT(nbytes % sizeof(mozilla::Conditional<
+                               mozilla::IsVoid<std::remove_pointer_t<T>>::value,
+                               char, std::remove_pointer_t<T>>) ==
                0);
     return SharedMem(
         reinterpret_cast<T>(reinterpret_cast<char*>(ptr_) + nbytes), *this);
   }
 
   T unwrap() const { return ptr_; }
 
   T unwrapUnshared() const {