Bug 1623957 - Part 8: Replace mozilla::IsUnsigned with std::is_unsigned. r=jwalden
authorAndré Bargull <andre.bargull@gmail.com>
Sat, 21 Mar 2020 14:22:23 +0000
changeset 519992 2244abeb2f3602e8d4a8536b7e08660d3e3d7fa3
parent 519991 c6427d6143d941135fedc5276e1e576dccbb00dd
child 519993 83191a5d4366cb754560e195cbfa4827a5a17e91
push id37237
push useraiakab@mozilla.com
push dateSat, 21 Mar 2020 21:28:09 +0000
treeherdermozilla-central@a1bea41f99f4 [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 8: Replace mozilla::IsUnsigned with std::is_unsigned. r=jwalden Differential Revision: https://phabricator.services.mozilla.com/D67656
js/public/Conversions.h
js/src/jsapi-tests/tests.h
js/src/util/Memory.h
--- a/js/public/Conversions.h
+++ b/js/public/Conversions.h
@@ -14,16 +14,17 @@
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/WrappingOperations.h"
 
 #include <cmath>
 #include <stddef.h>  // size_t
 #include <stdint.h>  // {u,}int{8,16,32,64}_t
+#include <type_traits>
 
 #include "jspubtd.h"
 #include "jstypes.h"  // JS_PUBLIC_API
 
 #include "js/RootingAPI.h"
 #include "js/Value.h"
 
 namespace js {
@@ -282,17 +283,17 @@ inline JSObject* ToObject(JSContext* cx,
  *   UnsignedInteger value congruent to d2 % 2**(bit width of UnsignedInteger).
  *
  * The algorithm below is inspired by that found in
  * <https://trac.webkit.org/changeset/67825/webkit/trunk/JavaScriptCore/runtime/JSValue.cpp>
  * but has been generalized to all integer widths.
  */
 template <typename UnsignedInteger>
 inline UnsignedInteger ToUnsignedInteger(double d) {
-  static_assert(mozilla::IsUnsigned<UnsignedInteger>::value,
+  static_assert(std::is_unsigned_v<UnsignedInteger>,
                 "UnsignedInteger must be an unsigned type");
 
   uint64_t bits = mozilla::BitwiseCast<uint64_t>(d);
   unsigned DoubleExponentShift = mozilla::FloatingPoint<double>::kExponentShift;
 
   // Extract the exponent component.  (Be careful here!  It's not technically
   // the exponent in NaN, infinities, and subnormals.)
   int_fast16_t exp =
@@ -508,17 +509,17 @@ inline int32_t ToSignedInteger<int32_t>(
   return i;
 }
 
 #endif  // defined (__arm__) && MOZ_IS_GCC
 
 namespace detail {
 
 template <typename IntegerType,
-          bool IsUnsigned = mozilla::IsUnsigned<IntegerType>::value>
+          bool IsUnsigned = std::is_unsigned_v<IntegerType>>
 struct ToSignedOrUnsignedInteger;
 
 template <typename IntegerType>
 struct ToSignedOrUnsignedInteger<IntegerType, true> {
   static IntegerType compute(double d) {
     return ToUnsignedInteger<IntegerType>(d);
   }
 };
--- a/js/src/jsapi-tests/tests.h
+++ b/js/src/jsapi-tests/tests.h
@@ -10,16 +10,17 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/TypeTraits.h"
 
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <type_traits>
 
 #include "gc/GC.h"
 #include "js/AllocPolicy.h"
 #include "js/CharacterEncoding.h"
 #include "js/Equality.h"     // JS::SameValue
 #include "js/RegExpFlags.h"  // JS::RegExpFlags
 #include "js/Vector.h"
 #include "js/Warnings.h"  // JS::SetWarningReporter
@@ -196,17 +197,17 @@ class JSAPITest {
   // nullptr. It infers type U = long int. Use CHECK_NULL instead.
   template <typename T, typename U>
   bool checkEqual(const T& actual, const U& expected, const char* actualExpr,
                   const char* expectedExpr, const char* filename, int lineno) {
     static_assert(mozilla::IsSigned<T>::value == mozilla::IsSigned<U>::value,
                   "using CHECK_EQUAL with different-signed inputs triggers "
                   "compiler warnings");
     static_assert(
-        mozilla::IsUnsigned<T>::value == mozilla::IsUnsigned<U>::value,
+        std::is_unsigned_v<T> == std::is_unsigned_v<U>,
         "using CHECK_EQUAL with different-signed inputs triggers compiler "
         "warnings");
     return (actual == expected) ||
            fail(JSAPITestString("CHECK_EQUAL failed: expected (") +
                     expectedExpr + ") = " + toSource(expected) + ", got (" +
                     actualExpr + ") = " + toSource(actual),
                 filename, lineno);
   }
--- a/js/src/util/Memory.h
+++ b/js/src/util/Memory.h
@@ -4,46 +4,44 @@
  * 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 util_Memory_h
 #define util_Memory_h
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/TypeTraits.h"
 
 #include <stddef.h>
 #include <stdint.h>
 #include <string.h>
+#include <type_traits>
 
 static MOZ_ALWAYS_INLINE void* js_memcpy(void* dst_, const void* src_,
                                          size_t len) {
   char* dst = (char*)dst_;
   const char* src = (const char*)src_;
   MOZ_ASSERT_IF(dst >= src, (size_t)(dst - src) >= len);
   MOZ_ASSERT_IF(src >= dst, (size_t)(src - dst) >= len);
 
   return memcpy(dst, src, len);
 }
 
 namespace js {
 
 template <typename T, typename U>
 static constexpr U ComputeByteAlignment(T bytes, U alignment) {
-  static_assert(mozilla::IsUnsigned<U>::value,
-                "alignment amount must be unsigned");
+  static_assert(std::is_unsigned_v<U>, "alignment amount must be unsigned");
 
   return (alignment - (bytes % alignment)) % alignment;
 }
 
 template <typename T, typename U>
 static constexpr T AlignBytes(T bytes, U alignment) {
-  static_assert(mozilla::IsUnsigned<U>::value,
-                "alignment amount must be unsigned");
+  static_assert(std::is_unsigned_v<U>, "alignment amount must be unsigned");
 
   return bytes + ComputeByteAlignment(bytes, alignment);
 }
 
 /*****************************************************************************/
 
 // Placement-new elements of an array. This should optimize away for types with
 // trivial default initiation.