Bug 1623957 - Part 10: Replace mozilla::Conditional with std::conditional. r=jwalden
authorAndré Bargull <andre.bargull@gmail.com>
Sat, 21 Mar 2020 14:25:21 +0000
changeset 520011 49efd8881aab338d6f6801629226c78ffc9ad702
parent 520010 83191a5d4366cb754560e195cbfa4827a5a17e91
child 520012 1079682d79674503220a89867e11308f88f90609
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 10: Replace mozilla::Conditional with std::conditional. r=jwalden Differential Revision: https://phabricator.services.mozilla.com/D67658
js/public/RootingAPI.h
js/src/vm/SharedMem.h
js/src/vm/Stack.h
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -1033,19 +1033,18 @@ namespace detail {
  * in (selected via MapTypeToRootKind), so no additional storage is
  * required here. Non-pointer types, however, share the same list, so the
  * function to call for tracing is stored adjacent to the struct. Since C++
  * cannot templatize on storage class, this is implemented via the wrapper
  * class DispatchWrapper.
  */
 template <typename T>
 using MaybeWrapped =
-    typename mozilla::Conditional<MapTypeToRootKind<T>::kind ==
-                                      JS::RootKind::Traceable,
-                                  js::DispatchWrapper<T>, T>::Type;
+    std::conditional_t<MapTypeToRootKind<T>::kind == JS::RootKind::Traceable,
+                       js::DispatchWrapper<T>, T>;
 
 // Dummy types to make it easier to understand template overload preference
 // ordering.
 struct FallbackOverload {};
 struct PreferredOverload : FallbackOverload {};
 using OverloadSelector = PreferredOverload;
 
 } /* namespace detail */
--- a/js/src/vm/SharedMem.h
+++ b/js/src/vm/SharedMem.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=2 et sw=2 tw=80:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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 };
@@ -75,19 +73,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<std::is_void_v<std::remove_pointer_t<U>>,
-                                     char, std::remove_pointer_t<U>>) ==
+            sizeof(std::conditional_t<std::is_void_v<std::remove_pointer_t<U>>,
+                                      char, std::remove_pointer_t<U>>) ==
         0);
     if (sharedness_ == IsUnshared) {
       return SharedMem<U>::unshared(unwrap());
     }
 #endif
     return SharedMem<U>::shared(unwrap());
   }
 
@@ -121,19 +118,18 @@ class SharedMem {
 
   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<std::is_void_v<std::remove_pointer_t<T>>,
-                                     char, std::remove_pointer_t<T>>) ==
+            sizeof(std::conditional_t<std::is_void_v<std::remove_pointer_t<T>>,
+                                      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 {
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/Atomics.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Variant.h"
 
 #include <algorithm>
+#include <type_traits>
 
 #include "gc/Rooting.h"
 #include "jit/JSJitFrameIter.h"
 #include "js/RootingAPI.h"
 #include "js/TypeDecls.h"
 #include "js/UniquePtr.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/JSFunction.h"
@@ -853,18 +854,18 @@ class AnyConstructArgs : public JS::Call
   MutableHandleValue newTarget() const = delete;
   MutableHandleValue rval() const = delete;
 };
 
 namespace detail {
 
 /** Function call/construct args of statically-unknown count. */
 template <MaybeConstruct Construct>
-class GenericArgsBase : public mozilla::Conditional<Construct, AnyConstructArgs,
-                                                    AnyInvokeArgs>::Type {
+class GenericArgsBase
+    : public std::conditional_t<Construct, AnyConstructArgs, AnyInvokeArgs> {
  protected:
   RootedValueVector v_;
 
   explicit GenericArgsBase(JSContext* cx) : v_(cx) {}
 
  public:
   bool init(JSContext* cx, unsigned argc) {
     if (argc > ARGS_LENGTH_MAX) {
@@ -886,18 +887,18 @@ class GenericArgsBase : public mozilla::
       this->CallArgs::setThis(MagicValue(JS_IS_CONSTRUCTING));
     }
     return true;
   }
 };
 
 /** Function call/construct args of statically-known count. */
 template <MaybeConstruct Construct, size_t N>
-class FixedArgsBase : public mozilla::Conditional<Construct, AnyConstructArgs,
-                                                  AnyInvokeArgs>::Type {
+class FixedArgsBase
+    : public std::conditional_t<Construct, AnyConstructArgs, AnyInvokeArgs> {
   static_assert(N <= ARGS_LENGTH_MAX, "o/~ too many args o/~");
 
  protected:
   JS::AutoValueArray<2 + N + uint32_t(Construct)> v_;
 
   explicit FixedArgsBase(JSContext* cx) : v_(cx) {
     *static_cast<JS::CallArgs*>(this) = CallArgsFromVp(N, v_.begin());
     this->constructing_ = Construct;