Bug 1447442 - Part 10: Remove ifdefs for unsupported compiler versions. r=jorendorff
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 13 Apr 2018 02:26:01 -0700
changeset 413338 8bae4384ab4c8824ae137685023a5c35fb7032b6
parent 413337 0d6754739bf9d7733f194877f1aa3ea5d734732d
child 413339 109933956ea91fad2b5722c2161715cb408b3178
push id33843
push usernerli@mozilla.com
push dateSat, 14 Apr 2018 09:49:25 +0000
treeherdermozilla-central@37b8862d354e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1447442
milestone61.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 1447442 - Part 10: Remove ifdefs for unsupported compiler versions. r=jorendorff
js/public/HashTable.h
js/src/jslibmath.h
js/src/jsmath.cpp
js/src/jsmath.h
js/src/jsnum.h
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -1767,25 +1767,20 @@ class HashTable : private AllocPolicy
     }
 
     MOZ_ALWAYS_INLINE AddPtr lookupForAdd(const Lookup& l) const
     {
         mozilla::ReentrancyGuard g(*this);
         if (!EnsureHash<HashPolicy>(l))
             return AddPtr();
         HashNumber keyHash = prepareHash(l);
-        // Calling constructor in return statement here avoid excess copying
-        // when build with Visual Studio 2015 and 2017, but it triggers a bug in
-        // gcc which is fixed in gcc-6. See bug 1385181.
-#if MOZ_IS_GCC && __GNUC__ < 6
-        AddPtr p(lookup(l, keyHash, sCollisionBit), *this, keyHash);
-        return p;
-#else
+        // Directly call the constructor in the return statement to avoid
+        // excess copying when building with Visual Studio 2017.
+        // See bug 1385181.
         return AddPtr(lookup(l, keyHash, sCollisionBit), *this, keyHash);
-#endif
     }
 
     template <typename... Args>
     MOZ_MUST_USE bool add(AddPtr& p, Args&&... args)
     {
         mozilla::ReentrancyGuard g(*this);
         MOZ_ASSERT(table);
         MOZ_ASSERT_IF(p.isValid(), p.table_ == this);
--- a/js/src/jslibmath.h
+++ b/js/src/jslibmath.h
@@ -6,33 +6,19 @@
 
 #ifndef jslibmath_h
 #define jslibmath_h
 
 #include "mozilla/FloatingPoint.h"
 
 #include <math.h>
 
-#include "jsnum.h"
-
+#include "js/Value.h"
 #include "vm/JSContext.h"
 
-/*
- * Use system provided math routines.
- */
-
-/* The right copysign function is not always named the same thing. */
-#ifdef __GNUC__
-#define js_copysign __builtin_copysign
-#elif defined _WIN32
-#define js_copysign _copysign
-#else
-#define js_copysign copysign
-#endif
-
 namespace js {
 
 inline double
 NumberDiv(double a, double b)
 {
     AutoUnsafeCallWithABI unsafe;
     if (b == 0) {
         if (a == 0 || mozilla::IsNaN(a))
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -12,16 +12,17 @@
 
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Unused.h"
 #include "mozilla/WrappingOperations.h"
 
 #include <algorithm>  // for std::max
+#include <cmath>
 #include <fcntl.h>
 #ifdef XP_UNIX
 # include <unistd.h>
 #endif
 
 #include "fdlibm.h"
 #include "jsapi.h"
 #include "jslibmath.h"
@@ -847,34 +848,34 @@ js::math_round_impl(double x)
     if (NumberIsInt32(x, &ignored))
         return x;
 
     /* Some numbers are so big that adding 0.5 would give the wrong number. */
     if (ExponentComponent(x) >= int_fast16_t(FloatingPoint<double>::kExponentShift))
         return x;
 
     double add = (x >= 0) ? GetBiggestNumberLessThan(0.5) : 0.5;
-    return js_copysign(fdlibm::floor(x + add), x);
+    return std::copysign(fdlibm::floor(x + add), x);
 }
 
 float
 js::math_roundf_impl(float x)
 {
     AutoUnsafeCallWithABI unsafe;
 
     int32_t ignored;
     if (NumberIsInt32(x, &ignored))
         return x;
 
     /* Some numbers are so big that adding 0.5 would give the wrong number. */
     if (ExponentComponent(x) >= int_fast16_t(FloatingPoint<float>::kExponentShift))
         return x;
 
     float add = (x >= 0) ? GetBiggestNumberLessThan(0.5f) : 0.5f;
-    return js_copysign(fdlibm::floorf(x + add), x);
+    return std::copysign(fdlibm::floorf(x + add), x);
 }
 
 bool /* ES5 15.8.2.15. */
 js::math_round(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     if (args.length() == 0) {
--- a/js/src/jsmath.h
+++ b/js/src/jsmath.h
@@ -4,17 +4,16 @@
  * 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 jsmath_h
 #define jsmath_h
 
 #include "mozilla/MemoryReporting.h"
 
-#include <cmath>
 #include <stdint.h>
 
 #include "NamespaceImports.h"
 
 namespace js {
 
 struct Class;
 class GlobalObject;
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -2,30 +2,31 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * 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 jsnum_h
 #define jsnum_h
 
+#include "mozilla/Compiler.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/Range.h"
 
 #include "NamespaceImports.h"
 
 #include "js/Conversions.h"
 
 #include "vm/StringType.h"
 
 
 // This macro is should be `one' if current compiler supports builtin functions
 // like __builtin_sadd_overflow.
-#if __GNUC__ >= 5
-    // GCC 5 and above supports these functions.
+#if MOZ_IS_GCC
+    // GCC supports these functions.
     #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) 1
 #else
     // For CLANG, we use its own function to check for this.
     #ifdef __has_builtin
         #define BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(x) __has_builtin(x)
     #endif
 #endif
 #ifndef BUILTIN_CHECKED_ARITHMETIC_SUPPORTED