Revert of Remove obsolete V8_INFINITY macro. (patchset #3 id:40001 of https://coderev...
authormachenbach <machenbach@chromium.org>
Sat, 20 Dec 2014 13:17:20 +0000 (05:17 -0800)
committerCommit bot <commit-bot@chromium.org>
Sat, 20 Dec 2014 13:17:35 +0000 (13:17 +0000)
Reason for revert:
Speculative revert. This seems to block the current roll: https://codereview.chromium.org/819653003/

I retried several times, also with a new roll. The error is internal - but that doesn't make much of a difference.

Original issue's description:
> Remove obsolete V8_INFINITY macro.
>
> Use std::numeric_limits consistently.
>
> R=svenpanne@chromium.org
>
> Committed: https://crrev.com/31c66e2d53569c4e229d55483d28208491e73612
> Cr-Commit-Position: refs/heads/master@{#25897}

TBR=svenpanne@chromium.org,bmeurer@chromium.org
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/813813003

Cr-Commit-Position: refs/heads/master@{#25912}

37 files changed:
src/arm/code-stubs-arm.cc
src/arm/lithium-codegen-arm.cc
src/assembler.cc
src/compiler/js-builtin-reducer.cc
src/compiler/typer.cc
src/conversions-inl.h
src/globals.h
src/heap/heap.cc
src/hydrogen-instructions.cc
src/mips/code-stubs-mips.cc
src/mips/lithium-codegen-mips.cc
src/mips/simulator-mips.cc
src/mips64/code-stubs-mips64.cc
src/mips64/lithium-codegen-mips64.cc
src/mips64/simulator-mips64.cc
src/ppc/code-stubs-ppc.cc
src/ppc/lithium-codegen-ppc.cc
src/strtod.cc
src/types.cc
test/cctest/compiler/codegen-tester.cc
test/cctest/compiler/function-tester.h
test/cctest/compiler/test-branch-combine.cc
test/cctest/compiler/test-js-constant-cache.cc
test/cctest/compiler/test-machine-operator-reducer.cc
test/cctest/compiler/test-run-jsops.cc
test/cctest/compiler/test-run-machops.cc
test/cctest/compiler/test-typer.cc
test/cctest/compiler/value-helper.h
test/cctest/test-assembler-arm64.cc
test/cctest/test-checks.cc
test/cctest/test-double.cc
test/cctest/test-strtod.cc
test/cctest/test-types.cc
test/cctest/types-fuzz.h
test/unittests/compiler/js-builtin-reducer-unittest.cc
test/unittests/compiler/machine-operator-reducer-unittest.cc
test/unittests/compiler/simplified-operator-reducer-unittest.cc

index 6aa5f30..ef286bb 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #if V8_TARGET_ARCH_ARM
@@ -784,8 +782,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
 
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13).
-      __ vmov(double_scratch, -std::numeric_limits<double>::infinity(),
-              scratch);
+      __ vmov(double_scratch, -V8_INFINITY, scratch);
       __ VFPCompareAndSetFlags(double_base, double_scratch);
       __ vneg(double_result, double_scratch, eq);
       __ b(eq, &done);
@@ -802,8 +799,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
 
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13).
-      __ vmov(double_scratch, -std::numeric_limits<double>::infinity(),
-              scratch);
+      __ vmov(double_scratch, -V8_INFINITY, scratch);
       __ VFPCompareAndSetFlags(double_base, double_scratch);
       __ vmov(double_result, kDoubleRegZero, eq);
       __ b(eq, &done);
index 0402405..9d9591b 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #include "src/arm/lithium-codegen-arm.h"
@@ -3882,7 +3880,7 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
   // Math.pow(-Infinity, 0.5) == Infinity
   // Math.sqrt(-Infinity) == NaN
   Label done;
-  __ vmov(temp, -std::numeric_limits<double>::infinity(), scratch0());
+  __ vmov(temp, -V8_INFINITY, scratch0());
   __ VFPCompareAndSetFlags(input, temp);
   __ vneg(result, temp, eq);
   __ b(&done, eq);
index 958b400..c73b470 100644 (file)
@@ -35,8 +35,6 @@
 #include "src/assembler.h"
 
 #include <cmath>
-#include <limits>
-
 #include "src/api.h"
 #include "src/base/cpu.h"
 #include "src/base/functional.h"
@@ -888,7 +886,7 @@ void ExternalReference::SetUp() {
   double_constants.minus_one_half = -0.5;
   double_constants.canonical_non_hole_nan = base::OS::nan_value();
   double_constants.the_hole_nan = bit_cast<double>(kHoleNanInt64);
-  double_constants.negative_infinity = -std::numeric_limits<double>::infinity();
+  double_constants.negative_infinity = -V8_INFINITY;
   double_constants.uint32_bias =
     static_cast<double>(static_cast<uint32_t>(0xFFFFFFFF)) + 1;
 
@@ -912,7 +910,7 @@ void ExternalReference::InitializeMathExpData() {
     math_exp_constants_array[0] = -708.39641853226408;
     // Input values larger than this always return +Infinity.
     math_exp_constants_array[1] = 709.78271289338397;
-    math_exp_constants_array[2] = std::numeric_limits<double>::infinity();
+    math_exp_constants_array[2] = V8_INFINITY;
     // The rest is black magic. Do not attempt to understand it. It is
     // loosely based on the "expd" function published at:
     // http://herumi.blogspot.com/2011/08/fast-double-precision-exponential.html
@@ -1415,7 +1413,7 @@ double power_helper(double x, double y) {
     return power_double_int(x, y_int);  // Returns 1 if exponent is 0.
   }
   if (y == 0.5) {
-    return (std::isinf(x)) ? std::numeric_limits<double>::infinity()
+    return (std::isinf(x)) ? V8_INFINITY
                            : fast_sqrt(x + 0.0);  // Convert -0 to +0.
   }
   if (y == -0.5) {
@@ -1452,8 +1450,7 @@ double power_double_double(double x, double y) {
   if ((x == 0.0 || std::isinf(x)) && std::isfinite(y)) {
     double f;
     if (std::modf(y, &f) != 0.0) {
-      return ((x == 0.0) ^ (y > 0)) ? std::numeric_limits<double>::infinity()
-                                    : 0.0;
+      return ((x == 0.0) ^ (y > 0)) ? V8_INFINITY : 0;
     }
   }
 
index 27b7749..263b0fe 100644 (file)
@@ -2,12 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "src/compiler/js-builtin-reducer.h"
-
-#include <limits>
-
 #include "src/compiler/diamond.h"
 #include "src/compiler/graph-inl.h"
+#include "src/compiler/js-builtin-reducer.h"
 #include "src/compiler/js-graph.h"
 #include "src/compiler/node-matchers.h"
 #include "src/compiler/node-properties-inl.h"
@@ -141,8 +138,7 @@ Reduction JSBuiltinReducer::ReduceMathMax(Node* node) {
   JSCallReduction r(node);
   if (r.InputsMatchZero()) {
     // Math.max() -> -Infinity
-    return Replace(
-        jsgraph()->Constant(-std::numeric_limits<double>::infinity()));
+    return Replace(jsgraph()->Constant(-V8_INFINITY));
   }
   if (r.InputsMatchOne(Type::Number())) {
     // Math.max(a:number) -> a
index 887b55b..58e6c37 100644 (file)
@@ -2,10 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "src/compiler/typer.h"
-
-#include <limits>
-
 #include "src/bootstrapper.h"
 #include "src/compiler/graph-inl.h"
 #include "src/compiler/graph-reducer.h"
@@ -14,6 +10,7 @@
 #include "src/compiler/node-properties-inl.h"
 #include "src/compiler/node-properties.h"
 #include "src/compiler/simplified-operator.h"
+#include "src/compiler/typer.h"
 
 namespace v8 {
 namespace internal {
@@ -163,10 +160,8 @@ Typer::Typer(Graph* graph, MaybeHandle<Context> context)
 
   Handle<Object> zero = f->NewNumber(0);
   Handle<Object> one = f->NewNumber(1);
-  Handle<Object> infinity =
-      f->NewNumber(+std::numeric_limits<double>::infinity());
-  Handle<Object> minusinfinity =
-      f->NewNumber(-std::numeric_limits<double>::infinity());
+  Handle<Object> infinity = f->NewNumber(+V8_INFINITY);
+  Handle<Object> minusinfinity = f->NewNumber(-V8_INFINITY);
 
   Type* number = Type::Number();
   Type* signed32 = Type::Signed32();
@@ -943,7 +938,7 @@ Type* Typer::Visitor::JSShiftRightLogicalTyper(Type* lhs, Type* rhs, Typer* t) {
 // Any -0 is converted to 0.
 static double array_min(double a[], size_t n) {
   DCHECK(n != 0);
-  double x = +std::numeric_limits<double>::infinity();
+  double x = +V8_INFINITY;
   for (size_t i = 0; i < n; ++i) {
     if (!std::isnan(a[i])) {
       x = std::min(a[i], x);
@@ -959,7 +954,7 @@ static double array_min(double a[], size_t n) {
 // Any -0 is converted to 0.
 static double array_max(double a[], size_t n) {
   DCHECK(n != 0);
-  double x = -std::numeric_limits<double>::infinity();
+  double x = -V8_INFINITY;
   for (size_t i = 0; i < n; ++i) {
     if (!std::isnan(a[i])) {
       x = std::max(a[i], x);
@@ -1074,11 +1069,9 @@ Type* Typer::Visitor::JSMultiplyRanger(Type::RangeType* lhs,
   // "results" above is nan, the actual result may still be, so we have to do a
   // different check:
   bool maybe_nan = (lhs->Maybe(t->singleton_zero) &&
-                    (rmin == -std::numeric_limits<double>::infinity() ||
-                     rmax == +std::numeric_limits<double>::infinity())) ||
+                    (rmin == -V8_INFINITY || rmax == +V8_INFINITY)) ||
                    (rhs->Maybe(t->singleton_zero) &&
-                    (lmin == -std::numeric_limits<double>::infinity() ||
-                     lmax == +std::numeric_limits<double>::infinity()));
+                    (lmin == -V8_INFINITY || lmax == +V8_INFINITY));
   if (maybe_nan) return t->weakint;  // Giving up.
   bool maybe_minuszero = (lhs->Maybe(t->singleton_zero) && rmin < 0) ||
                          (rhs->Maybe(t->singleton_zero) && lmin < 0);
@@ -1107,11 +1100,10 @@ Type* Typer::Visitor::JSDivideTyper(Type* lhs, Type* rhs, Typer* t) {
   if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN();
   // Division is tricky, so all we do is try ruling out nan.
   // TODO(neis): try ruling out -0 as well?
-  bool maybe_nan = lhs->Maybe(Type::NaN()) || rhs->Maybe(t->zeroish) ||
-                   ((lhs->Min() == -std::numeric_limits<double>::infinity() ||
-                     lhs->Max() == +std::numeric_limits<double>::infinity()) &&
-                    (rhs->Min() == -std::numeric_limits<double>::infinity() ||
-                     rhs->Max() == +std::numeric_limits<double>::infinity()));
+  bool maybe_nan =
+      lhs->Maybe(Type::NaN()) || rhs->Maybe(t->zeroish) ||
+      ((lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) &&
+       (rhs->Min() == -V8_INFINITY || rhs->Max() == +V8_INFINITY));
   return maybe_nan ? Type::Number() : Type::OrderedNumber();
 }
 
@@ -1156,8 +1148,7 @@ Type* Typer::Visitor::JSModulusTyper(Type* lhs, Type* rhs, Typer* t) {
   if (lhs->Is(Type::NaN()) || rhs->Is(Type::NaN())) return Type::NaN();
 
   if (lhs->Maybe(Type::NaN()) || rhs->Maybe(t->zeroish) ||
-      lhs->Min() == -std::numeric_limits<double>::infinity() ||
-      lhs->Max() == +std::numeric_limits<double>::infinity()) {
+      lhs->Min() == -V8_INFINITY || lhs->Max() == +V8_INFINITY) {
     // Result maybe NaN.
     return Type::Number();
   }
index e091650..ae87dc4 100644 (file)
@@ -5,9 +5,11 @@
 #ifndef V8_CONVERSIONS_INL_H_
 #define V8_CONVERSIONS_INL_H_
 
+#include <float.h>         // Required for DBL_MAX and on Win32 for finite()
+#include <limits.h>        // Required for INT_MAX etc.
+#include <stdarg.h>
 #include <cmath>
-#include <cstdarg>
-#include <limits>
+#include "src/globals.h"       // Required for V8_INFINITY
 
 // ----------------------------------------------------------------------------
 // Extra POSIX/ANSI functions for Win32/MSVC.
@@ -481,8 +483,7 @@ double InternalStringToDouble(UnicodeCache* unicode_cache,
     }
 
     DCHECK(buffer_pos == 0);
-    return (sign == NEGATIVE) ? -std::numeric_limits<double>::infinity()
-                              : std::numeric_limits<double>::infinity();
+    return (sign == NEGATIVE) ? -V8_INFINITY : V8_INFINITY;
   }
 
   bool leading_zero = false;
@@ -642,7 +643,7 @@ double InternalStringToDouble(UnicodeCache* unicode_cache,
       }
     }
 
-    const int max_exponent = std::numeric_limits<int>::max() / 2;
+    const int max_exponent = INT_MAX / 2;
     DCHECK(-max_exponent / 2 <= exponent && exponent <= max_exponent / 2);
     int num = 0;
     do {
index 3262ebd..933c6e2 100644 (file)
 #include "src/base/logging.h"
 #include "src/base/macros.h"
 
+// Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
+// warning flag and certain versions of GCC due to a bug:
+// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
+// For now, we use the more involved template-based version from <limits>, but
+// only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
+#if V8_CC_GNU && V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0)
+# include <limits>  // NOLINT
+# define V8_INFINITY std::numeric_limits<double>::infinity()
+#elif V8_LIBC_MSVCRT
+# define V8_INFINITY HUGE_VAL
+#else
+# define V8_INFINITY INFINITY
+#endif
+
 #if V8_TARGET_ARCH_IA32 || (V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_32_BIT) || \
     V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS ||     \
     V8_TARGET_ARCH_MIPS64
index e106079..56e9614 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #include "src/accessors.h"
@@ -2910,8 +2908,7 @@ void Heap::CreateInitialObjects() {
 
   set_nan_value(
       *factory->NewHeapNumber(base::OS::nan_value(), IMMUTABLE, TENURED));
-  set_infinity_value(*factory->NewHeapNumber(
-      std::numeric_limits<double>::infinity(), IMMUTABLE, TENURED));
+  set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, IMMUTABLE, TENURED));
 
   // The hole has not been created yet, but we want to put something
   // predictable in the gaps in the string table, so lets make that Smi zero.
index d07a338..0e6a03d 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #include "src/base/bits.h"
@@ -4357,8 +4355,7 @@ HInstruction* HDiv::New(
       } else {
         int sign = Double(c_left->DoubleValue()).Sign() *
                    Double(c_right->DoubleValue()).Sign();  // Right could be -0.
-        return H_CONSTANT_DOUBLE(sign *
-                                 std::numeric_limits<double>::infinity());
+        return H_CONSTANT_DOUBLE(sign * V8_INFINITY);
       }
     }
   }
index 6d7892d..97eed74 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #if V8_TARGET_ARCH_MIPS
@@ -857,7 +855,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
       // double_scratch can be overwritten in the delay slot.
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13).
-      __ Move(double_scratch, std::numeric_limits<double>::infinity());
+      __ Move(double_scratch, static_cast<double>(-V8_INFINITY));
       __ BranchF(USE_DELAY_SLOT, &done, NULL, eq, double_base, double_scratch);
       __ neg_d(double_result, double_scratch);
 
@@ -877,7 +875,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
       // double_scratch can be overwritten in the delay slot.
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13).
-      __ Move(double_scratch, std::numeric_limits<double>::infinity());
+      __ Move(double_scratch, static_cast<double>(-V8_INFINITY));
       __ BranchF(USE_DELAY_SLOT, &done, NULL, eq, double_base, double_scratch);
       __ Move(double_result, kDoubleRegZero);
 
index 0045489..cdc68c8 100644 (file)
@@ -25,8 +25,6 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #include "src/base/bits.h"
@@ -3844,7 +3842,7 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
   // Math.pow(-Infinity, 0.5) == Infinity
   // Math.sqrt(-Infinity) == NaN
   Label done;
-  __ Move(temp, std::numeric_limits<double>::infinity());
+  __ Move(temp, static_cast<double>(-V8_INFINITY));
   __ BranchF(USE_DELAY_SLOT, &done, NULL, eq, temp, input);
   // Set up Infinity in the delay slot.
   // result is overwritten if the branch is not taken.
index 9320fba..fabca67 100644 (file)
@@ -1288,8 +1288,7 @@ bool Simulator::set_fcsr_round_error(double original, double rounded) {
     set_fcsr_bit(kFCSRInexactFlagBit, true);
   }
 
-  if (rounded < std::numeric_limits<double>::min() &&
-      rounded > -std::numeric_limits<double>::min() && rounded != 0) {
+  if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) {
     set_fcsr_bit(kFCSRUnderflowFlagBit, true);
     ret = true;
   }
index 892ae2a..6bbd1a3 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #if V8_TARGET_ARCH_MIPS64
@@ -853,7 +851,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
       // double_scratch can be overwritten in the delay slot.
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13).
-      __ Move(double_scratch, std::numeric_limits<double>::infinity());
+      __ Move(double_scratch, static_cast<double>(-V8_INFINITY));
       __ BranchF(USE_DELAY_SLOT, &done, NULL, eq, double_base, double_scratch);
       __ neg_d(double_result, double_scratch);
 
@@ -873,7 +871,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
       // double_scratch can be overwritten in the delay slot.
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13).
-      __ Move(double_scratch, std::numeric_limits<double>::infinity());
+      __ Move(double_scratch, static_cast<double>(-V8_INFINITY));
       __ BranchF(USE_DELAY_SLOT, &done, NULL, eq, double_base, double_scratch);
       __ Move(double_result, kDoubleRegZero);
 
index 9df5cca..a817a28 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #include "src/code-factory.h"
@@ -3876,7 +3874,7 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
   // Math.pow(-Infinity, 0.5) == Infinity
   // Math.sqrt(-Infinity) == NaN
   Label done;
-  __ Move(temp, std::numeric_limits<double>::infinity());
+  __ Move(temp, static_cast<double>(-V8_INFINITY));
   __ BranchF(USE_DELAY_SLOT, &done, NULL, eq, temp, input);
   // Set up Infinity in the delay slot.
   // result is overwritten if the branch is not taken.
index 86b1d8e..9899d47 100644 (file)
@@ -1204,8 +1204,7 @@ bool Simulator::set_fcsr_round_error(double original, double rounded) {
     set_fcsr_bit(kFCSRInexactFlagBit, true);
   }
 
-  if (rounded < std::numeric_limits<double>::min() &&
-      rounded > -std::numeric_limits<double>::min() && rounded != 0) {
+  if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) {
     set_fcsr_bit(kFCSRUnderflowFlagBit, true);
     ret = true;
   }
@@ -1237,8 +1236,7 @@ bool Simulator::set_fcsr_round64_error(double original, double rounded) {
     set_fcsr_bit(kFCSRInexactFlagBit, true);
   }
 
-  if (rounded < std::numeric_limits<double>::min() &&
-      rounded > -std::numeric_limits<double>::min() && rounded != 0) {
+  if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) {
     set_fcsr_bit(kFCSRUnderflowFlagBit, true);
     ret = true;
   }
index a83a85c..3e84a21 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #if V8_TARGET_ARCH_PPC
@@ -800,8 +798,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
 
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, 0.5) == Infinity (ECMA spec, 15.8.2.13).
-      __ LoadDoubleLiteral(double_scratch,
-                           -std::numeric_limits<double>::infinity(), scratch);
+      __ LoadDoubleLiteral(double_scratch, -V8_INFINITY, scratch);
       __ fcmpu(double_base, double_scratch);
       __ bne(&not_minus_inf1);
       __ fneg(double_result, double_scratch);
@@ -820,8 +817,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
 
       // Calculates square root of base.  Check for the special case of
       // Math.pow(-Infinity, -0.5) == 0 (ECMA spec, 15.8.2.13).
-      __ LoadDoubleLiteral(double_scratch,
-                           -std::numeric_limits<double>::infinity(), scratch);
+      __ LoadDoubleLiteral(double_scratch, -V8_INFINITY, scratch);
       __ fcmpu(double_base, double_scratch);
       __ bne(&not_minus_inf2);
       __ fmr(double_result, kDoubleRegZero);
index 2ab53e5..7b6052c 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/v8.h"
 
 #include "src/base/bits.h"
@@ -4038,8 +4036,7 @@ void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
   // Math.sqrt(-Infinity) == NaN
   Label skip, done;
 
-  __ LoadDoubleLiteral(temp, -std::numeric_limits<double>::infinity(),
-                       scratch0());
+  __ LoadDoubleLiteral(temp, -V8_INFINITY, scratch0());
   __ fcmpu(input, temp);
   __ bne(&skip);
   __ fneg(result, temp);
index 4f06b39..2b48af3 100644 (file)
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <stdarg.h>
 #include <cmath>
-#include <cstdarg>
-#include <limits>
 
 #include "src/v8.h"
 
@@ -353,7 +352,7 @@ static bool DiyFpStrtod(Vector<const char> buffer,
 static double BignumStrtod(Vector<const char> buffer,
                            int exponent,
                            double guess) {
-  if (guess == std::numeric_limits<double>::infinity()) {
+  if (guess == V8_INFINITY) {
     return guess;
   }
 
@@ -409,9 +408,7 @@ double Strtod(Vector<const char> buffer, int exponent) {
                                      kMaxSignificantDecimalDigits),
                   significant_exponent);
   }
-  if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) {
-    return std::numeric_limits<double>::infinity();
-  }
+  if (exponent + trimmed.length() - 1 >= kMaxDecimalPower) return V8_INFINITY;
   if (exponent + trimmed.length() <= kMinDecimalPower) return 0.0;
 
   double guess;
index fe29d9d..c4f1bae 100644 (file)
@@ -2,10 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "src/types.h"
-
 #include <iomanip>
-#include <limits>
+
+#include "src/types.h"
 
 #include "src/ostreams.h"
 #include "src/types-inl.h"
@@ -82,7 +81,7 @@ double TypeImpl<Config>::Min() {
   DCHECK(this->Is(Number()));
   if (this->IsBitset()) return BitsetType::Min(this->AsBitset());
   if (this->IsUnion()) {
-    double min = +std::numeric_limits<double>::infinity();
+    double min = +V8_INFINITY;
     for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
       min = std::min(min, this->AsUnion()->Get(i)->Min());
     }
@@ -100,7 +99,7 @@ double TypeImpl<Config>::Max() {
   DCHECK(this->Is(Number()));
   if (this->IsBitset()) return BitsetType::Max(this->AsBitset());
   if (this->IsUnion()) {
-    double max = -std::numeric_limits<double>::infinity();
+    double max = -V8_INFINITY;
     for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) {
       max = std::max(max, this->AsUnion()->Get(i)->Max());
     }
@@ -288,7 +287,7 @@ TypeImpl<Config>::BitsetType::Lub(double value) {
 template <class Config>
 const typename TypeImpl<Config>::BitsetType::BitsetMin
     TypeImpl<Config>::BitsetType::BitsetMins31[] = {
-        {kOtherNumber, -std::numeric_limits<double>::infinity()},
+        {kOtherNumber, -V8_INFINITY},
         {kOtherSigned32, kMinInt},
         {kNegativeSignedSmall, -0x40000000},
         {kUnsignedSmall, 0},
@@ -302,7 +301,7 @@ const typename TypeImpl<Config>::BitsetType::BitsetMin
 template <class Config>
 const typename TypeImpl<Config>::BitsetType::BitsetMin
     TypeImpl<Config>::BitsetType::BitsetMins32[] = {
-        {kOtherNumber, -std::numeric_limits<double>::infinity()},
+        {kOtherNumber, -V8_INFINITY},
         {kNegativeSignedSmall, kMinInt},
         {kUnsignedSmall, 0},
         {kOtherUnsigned32, 0x80000000},
@@ -354,7 +353,7 @@ double TypeImpl<Config>::BitsetType::Max(bitset bits) {
   const BitsetMin* mins = BitsetMins();
   bool mz = SEMANTIC(bits & kMinusZero);
   if (BitsetType::Is(mins[BitsetMinsSize()-1].bits, bits)) {
-    return +std::numeric_limits<double>::infinity();
+    return +V8_INFINITY;
   }
   for (size_t i = BitsetMinsSize()-1; i-- > 0; ) {
     if (Is(SEMANTIC(mins[i].bits), bits)) {
index caffbb7..5311001 100644 (file)
@@ -142,7 +142,7 @@ TEST(CompareWrapper) {
 
   // Check NaN handling.
   double nan = v8::base::OS::nan_value();
-  double inf = std::numeric_limits<double>::infinity();
+  double inf = V8_INFINITY;
   CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, 0.0));
   CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, 1.0));
   CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, inf));
index a93dfc6..7e16eea 100644 (file)
@@ -137,9 +137,7 @@ class FunctionTester : public InitializedHandleScope {
 
   Handle<Object> infinity() { return isolate->factory()->infinity_value(); }
 
-  Handle<Object> minus_infinity() {
-    return Val(-std::numeric_limits<double>::infinity());
-  }
+  Handle<Object> minus_infinity() { return Val(-V8_INFINITY); }
 
   Handle<Object> nan() { return isolate->factory()->nan_value(); }
 
index 48694a8..cd3472d 100644 (file)
@@ -414,7 +414,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_inverse_branch_false) {
 
 
 TEST(BranchCombineFloat64Compares) {
-  double inf = std::numeric_limits<double>::infinity();
+  double inf = V8_INFINITY;
   double nan = v8::base::OS::nan_value();
   double inputs[] = {0.0, 1.0, -1.0, -inf, inf, nan};
 
index a7f2664..8588f66 100644 (file)
@@ -446,12 +446,23 @@ TEST(JSGraph_GetCachedNodes_together) {
   JSConstantCacheTester T;
 
   Node* constants[] = {
-      T.TrueConstant(), T.UndefinedConstant(), T.TheHoleConstant(),
-      T.TrueConstant(), T.FalseConstant(), T.NullConstant(), T.ZeroConstant(),
-      T.OneConstant(), T.NaNConstant(), T.Int32Constant(0), T.Int32Constant(1),
-      T.Int64Constant(-2), T.Int64Constant(-4), T.Float64Constant(0.9),
-      T.Float64Constant(std::numeric_limits<double>::infinity()),
-      T.Constant(0.99), T.Constant(1.11),
+      T.TrueConstant(),
+      T.UndefinedConstant(),
+      T.TheHoleConstant(),
+      T.TrueConstant(),
+      T.FalseConstant(),
+      T.NullConstant(),
+      T.ZeroConstant(),
+      T.OneConstant(),
+      T.NaNConstant(),
+      T.Int32Constant(0),
+      T.Int32Constant(1),
+      T.Int64Constant(-2),
+      T.Int64Constant(-4),
+      T.Float64Constant(0.9),
+      T.Float64Constant(V8_INFINITY),
+      T.Constant(0.99),
+      T.Constant(1.11),
       T.ExternalConstant(ExternalReference::address_of_one_half())};
 
   NodeVector nodes(T.main_zone());
index a333b1b..b538fb7 100644 (file)
@@ -795,7 +795,7 @@ TEST(ReduceFloat64Mul) {
     }
   }
 
-  double inf = std::numeric_limits<double>::infinity();
+  double inf = V8_INFINITY;
   R.CheckPutConstantOnRight(-inf);
   R.CheckPutConstantOnRight(-0.1);
   R.CheckPutConstantOnRight(0.1);
index 9e423d5..eb39760 100644 (file)
@@ -57,8 +57,8 @@ TEST(BinopDivide) {
 
   T.CheckCall(2, 8, 4);
   T.CheckCall(2.1, 8.4, 4);
-  T.CheckCall(std::numeric_limits<double>::infinity(), 8, 0);
-  T.CheckCall(-std::numeric_limits<double>::infinity(), -8, 0);
+  T.CheckCall(V8_INFINITY, 8, 0);
+  T.CheckCall(-V8_INFINITY, -8, 0);
   T.CheckCall(T.infinity(), T.Val(8), T.Val("0"));
   T.CheckCall(T.minus_infinity(), T.Val("-8"), T.Val(0.0));
   T.CheckCall(T.Val(1.5), T.Val("3"), T.Val("2"));
index deec63c..974d4ce 100644 (file)
@@ -2910,7 +2910,7 @@ TEST(RunFloat64Binop) {
                            m.machine()->Float64Mul(), m.machine()->Float64Div(),
                            m.machine()->Float64Mod(), NULL};
 
-  double inf = std::numeric_limits<double>::infinity();
+  double inf = V8_INFINITY;
   const Operator* inputs[] = {
       m.common()->Float64Constant(0),     m.common()->Float64Constant(1),
       m.common()->Float64Constant(1),     m.common()->Float64Constant(0),
@@ -3864,7 +3864,7 @@ static int Float64CompareHelper(RawMachineAssemblerTester<int32_t>* m,
 
 
 TEST(RunFloat64Compare) {
-  double inf = std::numeric_limits<double>::infinity();
+  double inf = V8_INFINITY;
   // All pairs (a1, a2) are of the form a1 < a2.
   double inputs[] = {0.0,  1.0,  -1.0, 0.22, -1.22, 0.22,
                      -inf, 0.22, 0.22, inf,  -inf,  inf};
index 56a8567..2b9d91a 100644 (file)
@@ -32,8 +32,8 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders {
     integers.push_back(0);
     integers.push_back(-1);
     integers.push_back(+1);
-    integers.push_back(-std::numeric_limits<double>::infinity());
-    integers.push_back(+std::numeric_limits<double>::infinity());
+    integers.push_back(-V8_INFINITY);
+    integers.push_back(+V8_INFINITY);
     for (int i = 0; i < 5; ++i) {
       double x = rng_->NextInt();
       integers.push_back(x);
@@ -99,12 +99,9 @@ class TyperTester : public HandleAndZoneScope, public GraphAndBuilders {
       case 1: return max;
       default: break;
     }
-    if (min == +std::numeric_limits<double>::infinity())
-      return +std::numeric_limits<double>::infinity();
-    if (max == -std::numeric_limits<double>::infinity())
-      return -std::numeric_limits<double>::infinity();
-    if (min == -std::numeric_limits<double>::infinity() &&
-        max == +std::numeric_limits<double>::infinity()) {
+    if (min == +V8_INFINITY) return +V8_INFINITY;
+    if (max == -V8_INFINITY) return -V8_INFINITY;
+    if (min == -V8_INFINITY && max == +V8_INFINITY) {
       return rng_->NextInt() * static_cast<double>(rng_->NextInt());
     }
     double result = nearbyint(min + (max - min) * rng_->NextDouble());
index a08a6e2..218a773 100644 (file)
@@ -102,13 +102,14 @@ class ValueHelper {
   static std::vector<double> float64_vector() {
     static const double nan = v8::base::OS::nan_value();
     static const double values[] = {
-        0.125, 0.25, 0.375, 0.5, 1.25, -1.75, 2, 5.125, 6.25, 0.0, -0.0,
-        982983.25, 888, 2147483647.0, -999.75, 3.1e7, -2e66, 3e-88,
-        -2147483648.0, std::numeric_limits<double>::infinity(),
-        -std::numeric_limits<double>::infinity(), nan, 2147483647.375,
-        2147483647.75, 2147483648.0, 2147483648.25, 2147483649.25,
-        -2147483647.0, -2147483647.125, -2147483647.875, -2147483648.25,
-        -2147483649.5};
+        0.125,           0.25,            0.375,          0.5,
+        1.25,            -1.75,           2,              5.125,
+        6.25,            0.0,             -0.0,           982983.25,
+        888,             2147483647.0,    -999.75,        3.1e7,
+        -2e66,           3e-88,           -2147483648.0,  V8_INFINITY,
+        -V8_INFINITY,    nan,             2147483647.375, 2147483647.75,
+        2147483648.0,    2147483648.25,   2147483649.25,  -2147483647.0,
+        -2147483647.125, -2147483647.875, -2147483648.25, -2147483649.5};
     return std::vector<double>(&values[0], &values[arraysize(values)]);
   }
 
@@ -134,11 +135,9 @@ class ValueHelper {
 
   static const std::vector<double> nan_vector(size_t limit = 0) {
     static const double nan = v8::base::OS::nan_value();
-    static const double values[] = {
-        -nan, -std::numeric_limits<double>::infinity() * -0.0,
-        -std::numeric_limits<double>::infinity() * 0.0,
-        std::numeric_limits<double>::infinity() * -0.0,
-        std::numeric_limits<double>::infinity() * 0.0, nan};
+    static const double values[] = {-nan,               -V8_INFINITY * -0.0,
+                                    -V8_INFINITY * 0.0, V8_INFINITY * -0.0,
+                                    V8_INFINITY * 0.0,  nan};
     return std::vector<double>(&values[0], &values[arraysize(values)]);
   }
 
index a270902..108152e 100644 (file)
@@ -5858,11 +5858,10 @@ TEST(fmax_fmin_d) {
                        snan_processed, snan_processed);
 
   // Iterate over all combinations of inputs.
-  double inputs[] = {
-      std::numeric_limits<double>::max(), std::numeric_limits<double>::min(),
-      1.0, 0.0, -std::numeric_limits<double>::max(),
-      -std::numeric_limits<double>::min(), -1.0, -0.0, kFP64PositiveInfinity,
-      kFP64NegativeInfinity, kFP64QuietNaN, kFP64SignallingNaN};
+  double inputs[] = { DBL_MAX, DBL_MIN, 1.0, 0.0,
+                      -DBL_MAX, -DBL_MIN, -1.0, -0.0,
+                      kFP64PositiveInfinity, kFP64NegativeInfinity,
+                      kFP64QuietNaN, kFP64SignallingNaN };
 
   const int count = sizeof(inputs) / sizeof(inputs[0]);
 
@@ -5944,11 +5943,10 @@ TEST(fmax_fmin_s) {
                       snan_processed, snan_processed);
 
   // Iterate over all combinations of inputs.
-  float inputs[] = {
-      std::numeric_limits<float>::max(), std::numeric_limits<float>::min(), 1.0,
-      0.0, -std::numeric_limits<float>::max(),
-      -std::numeric_limits<float>::min(), -1.0, -0.0, kFP32PositiveInfinity,
-      kFP32NegativeInfinity, kFP32QuietNaN, kFP32SignallingNaN};
+  float inputs[] = { FLT_MAX, FLT_MIN, 1.0, 0.0,
+                     -FLT_MAX, -FLT_MIN, -1.0, -0.0,
+                     kFP32PositiveInfinity, kFP32NegativeInfinity,
+                     kFP32QuietNaN, kFP32SignallingNaN };
 
   const int count = sizeof(inputs) / sizeof(inputs[0]);
 
@@ -6744,8 +6742,8 @@ TEST(fcvt_ds) {
   __ Fmov(s24, kFP32NegativeInfinity);
   __ Fmov(s25, 0.0);
   __ Fmov(s26, -0.0);
-  __ Fmov(s27, std::numeric_limits<float>::max());
-  __ Fmov(s28, std::numeric_limits<float>::min());
+  __ Fmov(s27, FLT_MAX);
+  __ Fmov(s28, FLT_MIN);
   __ Fmov(s29, rawbits_to_float(0x7fc12345));   // Quiet NaN.
   __ Fmov(s30, rawbits_to_float(0x7f812345));   // Signalling NaN.
 
@@ -6779,8 +6777,8 @@ TEST(fcvt_ds) {
   CHECK_EQUAL_FP64(kFP64NegativeInfinity, d8);
   CHECK_EQUAL_FP64(0.0f, d9);
   CHECK_EQUAL_FP64(-0.0f, d10);
-  CHECK_EQUAL_FP64(std::numeric_limits<float>::max(), d11);
-  CHECK_EQUAL_FP64(std::numeric_limits<float>::min(), d12);
+  CHECK_EQUAL_FP64(FLT_MAX, d11);
+  CHECK_EQUAL_FP64(FLT_MIN, d12);
 
   // Check that the NaN payload is preserved according to ARM64 conversion
   // rules:
@@ -6804,86 +6802,83 @@ TEST(fcvt_sd) {
   //
   // Note that this test only checks ties-to-even rounding, because that is all
   // that the simulator supports.
-  struct {
-    double in;
-    float expected;
-  } test[] = {
-      // Check some simple conversions.
-      {0.0, 0.0f},
-      {1.0, 1.0f},
-      {1.5, 1.5f},
-      {2.0, 2.0f},
-      {std::numeric_limits<float>::max(), std::numeric_limits<float>::max()},
-      //  - The smallest normalized float.
-      {pow(2.0, -126), powf(2, -126)},
-      //  - Normal floats that need (ties-to-even) rounding.
-      //    For normalized numbers:
-      //         bit 29 (0x0000000020000000) is the lowest-order bit which will
-      //                                     fit in the float's mantissa.
-      {rawbits_to_double(0x3ff0000000000000), rawbits_to_float(0x3f800000)},
-      {rawbits_to_double(0x3ff0000000000001), rawbits_to_float(0x3f800000)},
-      {rawbits_to_double(0x3ff0000010000000), rawbits_to_float(0x3f800000)},
-      {rawbits_to_double(0x3ff0000010000001), rawbits_to_float(0x3f800001)},
-      {rawbits_to_double(0x3ff0000020000000), rawbits_to_float(0x3f800001)},
-      {rawbits_to_double(0x3ff0000020000001), rawbits_to_float(0x3f800001)},
-      {rawbits_to_double(0x3ff0000030000000), rawbits_to_float(0x3f800002)},
-      {rawbits_to_double(0x3ff0000030000001), rawbits_to_float(0x3f800002)},
-      {rawbits_to_double(0x3ff0000040000000), rawbits_to_float(0x3f800002)},
-      {rawbits_to_double(0x3ff0000040000001), rawbits_to_float(0x3f800002)},
-      {rawbits_to_double(0x3ff0000050000000), rawbits_to_float(0x3f800002)},
-      {rawbits_to_double(0x3ff0000050000001), rawbits_to_float(0x3f800003)},
-      {rawbits_to_double(0x3ff0000060000000), rawbits_to_float(0x3f800003)},
-      //  - A mantissa that overflows into the exponent during rounding.
-      {rawbits_to_double(0x3feffffff0000000), rawbits_to_float(0x3f800000)},
-      //  - The largest double that rounds to a normal float.
-      {rawbits_to_double(0x47efffffefffffff), rawbits_to_float(0x7f7fffff)},
-
-      // Doubles that are too big for a float.
-      {kFP64PositiveInfinity, kFP32PositiveInfinity},
-      {std::numeric_limits<double>::max(), kFP32PositiveInfinity},
-      //  - The smallest exponent that's too big for a float.
-      {pow(2.0, 128), kFP32PositiveInfinity},
-      //  - This exponent is in range, but the value rounds to infinity.
-      {rawbits_to_double(0x47effffff0000000), kFP32PositiveInfinity},
-
-      // Doubles that are too small for a float.
-      //  - The smallest (subnormal) double.
-      {std::numeric_limits<double>::min(), 0.0},
-      //  - The largest double which is too small for a subnormal float.
-      {rawbits_to_double(0x3690000000000000), rawbits_to_float(0x00000000)},
-
-      // Normal doubles that become subnormal floats.
-      //  - The largest subnormal float.
-      {rawbits_to_double(0x380fffffc0000000), rawbits_to_float(0x007fffff)},
-      //  - The smallest subnormal float.
-      {rawbits_to_double(0x36a0000000000000), rawbits_to_float(0x00000001)},
-      //  - Subnormal floats that need (ties-to-even) rounding.
-      //    For these subnormals:
-      //         bit 34 (0x0000000400000000) is the lowest-order bit which will
-      //                                     fit in the float's mantissa.
-      {rawbits_to_double(0x37c159e000000000), rawbits_to_float(0x00045678)},
-      {rawbits_to_double(0x37c159e000000001), rawbits_to_float(0x00045678)},
-      {rawbits_to_double(0x37c159e200000000), rawbits_to_float(0x00045678)},
-      {rawbits_to_double(0x37c159e200000001), rawbits_to_float(0x00045679)},
-      {rawbits_to_double(0x37c159e400000000), rawbits_to_float(0x00045679)},
-      {rawbits_to_double(0x37c159e400000001), rawbits_to_float(0x00045679)},
-      {rawbits_to_double(0x37c159e600000000), rawbits_to_float(0x0004567a)},
-      {rawbits_to_double(0x37c159e600000001), rawbits_to_float(0x0004567a)},
-      {rawbits_to_double(0x37c159e800000000), rawbits_to_float(0x0004567a)},
-      {rawbits_to_double(0x37c159e800000001), rawbits_to_float(0x0004567a)},
-      {rawbits_to_double(0x37c159ea00000000), rawbits_to_float(0x0004567a)},
-      {rawbits_to_double(0x37c159ea00000001), rawbits_to_float(0x0004567b)},
-      {rawbits_to_double(0x37c159ec00000000), rawbits_to_float(0x0004567b)},
-      //  - The smallest double which rounds up to become a subnormal float.
-      {rawbits_to_double(0x3690000000000001), rawbits_to_float(0x00000001)},
-
-      // Check NaN payload preservation.
-      {rawbits_to_double(0x7ff82468a0000000), rawbits_to_float(0x7fc12345)},
-      {rawbits_to_double(0x7ff82468bfffffff), rawbits_to_float(0x7fc12345)},
-      //  - Signalling NaNs become quiet NaNs.
-      {rawbits_to_double(0x7ff02468a0000000), rawbits_to_float(0x7fc12345)},
-      {rawbits_to_double(0x7ff02468bfffffff), rawbits_to_float(0x7fc12345)},
-      {rawbits_to_double(0x7ff000001fffffff), rawbits_to_float(0x7fc00000)},
+  struct {double in; float expected;} test[] = {
+    // Check some simple conversions.
+    {0.0, 0.0f},
+    {1.0, 1.0f},
+    {1.5, 1.5f},
+    {2.0, 2.0f},
+    {FLT_MAX, FLT_MAX},
+    //  - The smallest normalized float.
+    {pow(2.0, -126), powf(2, -126)},
+    //  - Normal floats that need (ties-to-even) rounding.
+    //    For normalized numbers:
+    //         bit 29 (0x0000000020000000) is the lowest-order bit which will
+    //                                     fit in the float's mantissa.
+    {rawbits_to_double(0x3ff0000000000000), rawbits_to_float(0x3f800000)},
+    {rawbits_to_double(0x3ff0000000000001), rawbits_to_float(0x3f800000)},
+    {rawbits_to_double(0x3ff0000010000000), rawbits_to_float(0x3f800000)},
+    {rawbits_to_double(0x3ff0000010000001), rawbits_to_float(0x3f800001)},
+    {rawbits_to_double(0x3ff0000020000000), rawbits_to_float(0x3f800001)},
+    {rawbits_to_double(0x3ff0000020000001), rawbits_to_float(0x3f800001)},
+    {rawbits_to_double(0x3ff0000030000000), rawbits_to_float(0x3f800002)},
+    {rawbits_to_double(0x3ff0000030000001), rawbits_to_float(0x3f800002)},
+    {rawbits_to_double(0x3ff0000040000000), rawbits_to_float(0x3f800002)},
+    {rawbits_to_double(0x3ff0000040000001), rawbits_to_float(0x3f800002)},
+    {rawbits_to_double(0x3ff0000050000000), rawbits_to_float(0x3f800002)},
+    {rawbits_to_double(0x3ff0000050000001), rawbits_to_float(0x3f800003)},
+    {rawbits_to_double(0x3ff0000060000000), rawbits_to_float(0x3f800003)},
+    //  - A mantissa that overflows into the exponent during rounding.
+    {rawbits_to_double(0x3feffffff0000000), rawbits_to_float(0x3f800000)},
+    //  - The largest double that rounds to a normal float.
+    {rawbits_to_double(0x47efffffefffffff), rawbits_to_float(0x7f7fffff)},
+
+    // Doubles that are too big for a float.
+    {kFP64PositiveInfinity, kFP32PositiveInfinity},
+    {DBL_MAX, kFP32PositiveInfinity},
+    //  - The smallest exponent that's too big for a float.
+    {pow(2.0, 128), kFP32PositiveInfinity},
+    //  - This exponent is in range, but the value rounds to infinity.
+    {rawbits_to_double(0x47effffff0000000), kFP32PositiveInfinity},
+
+    // Doubles that are too small for a float.
+    //  - The smallest (subnormal) double.
+    {DBL_MIN, 0.0},
+    //  - The largest double which is too small for a subnormal float.
+    {rawbits_to_double(0x3690000000000000), rawbits_to_float(0x00000000)},
+
+    // Normal doubles that become subnormal floats.
+    //  - The largest subnormal float.
+    {rawbits_to_double(0x380fffffc0000000), rawbits_to_float(0x007fffff)},
+    //  - The smallest subnormal float.
+    {rawbits_to_double(0x36a0000000000000), rawbits_to_float(0x00000001)},
+    //  - Subnormal floats that need (ties-to-even) rounding.
+    //    For these subnormals:
+    //         bit 34 (0x0000000400000000) is the lowest-order bit which will
+    //                                     fit in the float's mantissa.
+    {rawbits_to_double(0x37c159e000000000), rawbits_to_float(0x00045678)},
+    {rawbits_to_double(0x37c159e000000001), rawbits_to_float(0x00045678)},
+    {rawbits_to_double(0x37c159e200000000), rawbits_to_float(0x00045678)},
+    {rawbits_to_double(0x37c159e200000001), rawbits_to_float(0x00045679)},
+    {rawbits_to_double(0x37c159e400000000), rawbits_to_float(0x00045679)},
+    {rawbits_to_double(0x37c159e400000001), rawbits_to_float(0x00045679)},
+    {rawbits_to_double(0x37c159e600000000), rawbits_to_float(0x0004567a)},
+    {rawbits_to_double(0x37c159e600000001), rawbits_to_float(0x0004567a)},
+    {rawbits_to_double(0x37c159e800000000), rawbits_to_float(0x0004567a)},
+    {rawbits_to_double(0x37c159e800000001), rawbits_to_float(0x0004567a)},
+    {rawbits_to_double(0x37c159ea00000000), rawbits_to_float(0x0004567a)},
+    {rawbits_to_double(0x37c159ea00000001), rawbits_to_float(0x0004567b)},
+    {rawbits_to_double(0x37c159ec00000000), rawbits_to_float(0x0004567b)},
+    //  - The smallest double which rounds up to become a subnormal float.
+    {rawbits_to_double(0x3690000000000001), rawbits_to_float(0x00000001)},
+
+    // Check NaN payload preservation.
+    {rawbits_to_double(0x7ff82468a0000000), rawbits_to_float(0x7fc12345)},
+    {rawbits_to_double(0x7ff82468bfffffff), rawbits_to_float(0x7fc12345)},
+    //  - Signalling NaNs become quiet NaNs.
+    {rawbits_to_double(0x7ff02468a0000000), rawbits_to_float(0x7fc12345)},
+    {rawbits_to_double(0x7ff02468bfffffff), rawbits_to_float(0x7fc12345)},
+    {rawbits_to_double(0x7ff000001fffffff), rawbits_to_float(0x7fc00000)},
   };
   int count = sizeof(test) / sizeof(test[0]);
 
index ac68b21..79e87dd 100644 (file)
@@ -16,7 +16,7 @@ TEST(CheckEqualsZeroAndMinusZero) {
 
 
 TEST(CheckEqualsReflexivity) {
-  double inf = std::numeric_limits<double>::infinity();
+  double inf = V8_INFINITY;
   double nan = v8::base::OS::nan_value();
   double constants[] = {-nan, -inf, -3.1415, -1.0,   -0.1, -0.0,
                         0.0,  0.1,  1.0,     3.1415, inf,  nan};
index 3ff263d..16dcb37 100644 (file)
@@ -103,8 +103,8 @@ TEST(IsDenormal) {
 
 
 TEST(IsSpecial) {
-  CHECK(Double(std::numeric_limits<double>::infinity()).IsSpecial());
-  CHECK(Double(-std::numeric_limits<double>::infinity()).IsSpecial());
+  CHECK(Double(V8_INFINITY).IsSpecial());
+  CHECK(Double(-V8_INFINITY).IsSpecial());
   CHECK(Double(v8::base::OS::nan_value()).IsSpecial());
   uint64_t bits = V8_2PART_UINT64_C(0xFFF12345, 00000000);
   CHECK(Double(bits).IsSpecial());
@@ -126,8 +126,8 @@ TEST(IsSpecial) {
 
 
 TEST(IsInfinite) {
-  CHECK(Double(std::numeric_limits<double>::infinity()).IsInfinite());
-  CHECK(Double(-std::numeric_limits<double>::infinity()).IsInfinite());
+  CHECK(Double(V8_INFINITY).IsInfinite());
+  CHECK(Double(-V8_INFINITY).IsInfinite());
   CHECK(!Double(v8::base::OS::nan_value()).IsInfinite());
   CHECK(!Double(0.0).IsInfinite());
   CHECK(!Double(-0.0).IsInfinite());
@@ -140,8 +140,8 @@ TEST(IsInfinite) {
 
 TEST(Sign) {
   CHECK_EQ(1, Double(1.0).Sign());
-  CHECK_EQ(1, Double(std::numeric_limits<double>::infinity()).Sign());
-  CHECK_EQ(-1, Double(-std::numeric_limits<double>::infinity()).Sign());
+  CHECK_EQ(1, Double(V8_INFINITY).Sign());
+  CHECK_EQ(-1, Double(-V8_INFINITY).Sign());
   CHECK_EQ(1, Double(0.0).Sign());
   CHECK_EQ(-1, Double(-0.0).Sign());
   uint64_t min_double64 = V8_2PART_UINT64_C(0x00000000, 00000001);
@@ -225,8 +225,7 @@ TEST(NextDouble) {
   CHECK_EQ(-0.0, d1.value());
   CHECK_EQ(0.0, d2.value());
   CHECK_EQ(4e-324, d2.NextDouble());
-  CHECK_EQ(-1.7976931348623157e308,
-           Double(-std::numeric_limits<double>::infinity()).NextDouble());
-  CHECK_EQ(std::numeric_limits<double>::infinity(),
+  CHECK_EQ(-1.7976931348623157e308, Double(-V8_INFINITY).NextDouble());
+  CHECK_EQ(V8_INFINITY,
            Double(V8_2PART_UINT64_C(0x7fefffff, ffffffff)).NextDouble());
 }
index 77a3dc4..7c11186 100644 (file)
@@ -200,42 +200,36 @@ TEST(Strtod) {
   CHECK_EQ(0.0, StrtodChar("0000000010000", -329));
   CHECK_EQ(0.0, StrtodChar("0000000090000", -329));
 
-  // It would be more readable to put the literals (and not
-  // std::numeric_limits<double>::infinity()) on the
+  // It would be more readable to put the literals (and not V8_INFINITY) on the
   // left side (i.e. CHECK_EQ(1e309, StrtodChar("1", 309))), but then Gcc
   // complains that the floating constant exceeds range of 'double'.
-  CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("1", 309));
+  CHECK_EQ(V8_INFINITY, StrtodChar("1", 309));
   CHECK_EQ(1e308, StrtodChar("1", 308));
   CHECK_EQ(1234e305, StrtodChar("1234", 305));
   CHECK_EQ(1234e304, StrtodChar("1234", 304));
-  CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("18", 307));
+  CHECK_EQ(V8_INFINITY, StrtodChar("18", 307));
   CHECK_EQ(17e307, StrtodChar("17", 307));
-  CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("0000001", 309));
+  CHECK_EQ(V8_INFINITY, StrtodChar("0000001", 309));
   CHECK_EQ(1e308, StrtodChar("00000001", 308));
   CHECK_EQ(1234e305, StrtodChar("00000001234", 305));
   CHECK_EQ(1234e304, StrtodChar("000000001234", 304));
-  CHECK_EQ(std::numeric_limits<double>::infinity(),
-           StrtodChar("0000000018", 307));
+  CHECK_EQ(V8_INFINITY, StrtodChar("0000000018", 307));
   CHECK_EQ(17e307, StrtodChar("0000000017", 307));
-  CHECK_EQ(std::numeric_limits<double>::infinity(), StrtodChar("1000000", 303));
+  CHECK_EQ(V8_INFINITY, StrtodChar("1000000", 303));
   CHECK_EQ(1e308, StrtodChar("100000", 303));
   CHECK_EQ(1234e305, StrtodChar("123400000", 300));
   CHECK_EQ(1234e304, StrtodChar("123400000", 299));
-  CHECK_EQ(std::numeric_limits<double>::infinity(),
-           StrtodChar("180000000", 300));
+  CHECK_EQ(V8_INFINITY, StrtodChar("180000000", 300));
   CHECK_EQ(17e307, StrtodChar("170000000", 300));
-  CHECK_EQ(std::numeric_limits<double>::infinity(),
-           StrtodChar("00000001000000", 303));
+  CHECK_EQ(V8_INFINITY, StrtodChar("00000001000000", 303));
   CHECK_EQ(1e308, StrtodChar("000000000000100000", 303));
   CHECK_EQ(1234e305, StrtodChar("00000000123400000", 300));
   CHECK_EQ(1234e304, StrtodChar("0000000123400000", 299));
-  CHECK_EQ(std::numeric_limits<double>::infinity(),
-           StrtodChar("00000000180000000", 300));
+  CHECK_EQ(V8_INFINITY, StrtodChar("00000000180000000", 300));
   CHECK_EQ(17e307, StrtodChar("00000000170000000", 300));
   CHECK_EQ(1.7976931348623157E+308, StrtodChar("17976931348623157", 292));
   CHECK_EQ(1.7976931348623158E+308, StrtodChar("17976931348623158", 292));
-  CHECK_EQ(std::numeric_limits<double>::infinity(),
-           StrtodChar("17976931348623159", 292));
+  CHECK_EQ(V8_INFINITY, StrtodChar("17976931348623159", 292));
 
   // The following number is the result of 89255.0/1e22. Both floating-point
   // numbers can be accurately represented with doubles. However on Linux,x86
@@ -413,7 +407,7 @@ static bool CheckDouble(Vector<const char> buffer,
     d.NormalizedBoundaries(&lower_boundary, &upper_boundary);
     return CompareBignumToDiyFp(input_digits, exponent, lower_boundary) <= 0;
   }
-  if (to_check == std::numeric_limits<double>::infinity()) {
+  if (to_check == V8_INFINITY) {
     const double kMaxDouble = 1.7976931348623157e308;
     // Check that the buffer*10^exponent >= boundary between kMaxDouble and inf.
     Double d(kMaxDouble);
index 4fc32e9..ebef527 100644 (file)
@@ -339,14 +339,10 @@ struct Tests : Rep {
     CHECK(!T.Constant(fac->NewNumber(10e60))->Is(T.Integral32));
     CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero));
     CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN));
-    CHECK(T.Constant(fac->NewNumber(std::numeric_limits<double>::infinity()))
-              ->Is(T.PlainNumber));
-    CHECK(!T.Constant(fac->NewNumber(std::numeric_limits<double>::infinity()))
-               ->Is(T.Integral32));
-    CHECK(T.Constant(fac->NewNumber(-std::numeric_limits<double>::infinity()))
-              ->Is(T.PlainNumber));
-    CHECK(!T.Constant(fac->NewNumber(-std::numeric_limits<double>::infinity()))
-               ->Is(T.Integral32));
+    CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.PlainNumber));
+    CHECK(!T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.Integral32));
+    CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.PlainNumber));
+    CHECK(!T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.Integral32));
   }
 
   void Range() {
index 3fe4782..4eac64c 100644 (file)
@@ -87,10 +87,8 @@ class Types {
       types.push_back(Type::Constant(*it, region));
     }
 
-    integers.push_back(isolate->factory()->NewNumber(
-        -std::numeric_limits<double>::infinity()));
-    integers.push_back(isolate->factory()->NewNumber(
-        +std::numeric_limits<double>::infinity()));
+    integers.push_back(isolate->factory()->NewNumber(-V8_INFINITY));
+    integers.push_back(isolate->factory()->NewNumber(+V8_INFINITY));
     integers.push_back(isolate->factory()->NewNumber(-rng_->NextInt(10)));
     integers.push_back(isolate->factory()->NewNumber(+rng_->NextInt(10)));
     for (int i = 0; i < 10; ++i) {
@@ -100,10 +98,8 @@ class Types {
       if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x));
     }
 
-    Integer = Type::Range(
-        isolate->factory()->NewNumber(-std::numeric_limits<double>::infinity()),
-        isolate->factory()->NewNumber(+std::numeric_limits<double>::infinity()),
-        region);
+    Integer = Type::Range(isolate->factory()->NewNumber(-V8_INFINITY),
+                          isolate->factory()->NewNumber(+V8_INFINITY), region);
 
     NumberArray = Type::Array(Number, region);
     StringArray = Type::Array(String, region);
index 8c6a4d9..0747f0c 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/compiler/js-builtin-reducer.h"
 #include "src/compiler/js-graph.h"
 #include "src/compiler/node-properties-inl.h"
@@ -134,8 +132,7 @@ TEST_F(JSBuiltinReducerTest, MathMax0) {
   Reduction r = Reduce(call);
 
   ASSERT_TRUE(r.Changed());
-  EXPECT_THAT(r.replacement(),
-              IsNumberConstant(-std::numeric_limits<double>::infinity()));
+  EXPECT_THAT(r.replacement(), IsNumberConstant(-V8_INFINITY));
 }
 
 
index 1f34a06..6a8a4d3 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/base/bits.h"
 #include "src/base/division-by-constant.h"
 #include "src/compiler/js-graph.h"
@@ -112,24 +110,26 @@ const float kFloat32Values[] = {
 
 
 const double kFloat64Values[] = {
-    -std::numeric_limits<double>::infinity(), -4.23878e+275, -5.82632e+265,
-    -6.60355e+220, -6.26172e+212, -2.56222e+211, -4.82408e+201, -1.84106e+157,
-    -1.63662e+127, -1.55772e+100, -1.67813e+72, -2.3382e+55, -3.179e+30,
-    -1.441e+09, -1.0647e+09, -7.99361e+08, -5.77375e+08, -2.20984e+08, -32757,
-    -13171, -9970, -3984, -107, -105, -92, -77, -61, -0.000208163, -1.86685e-06,
-    -1.17296e-10, -9.26358e-11, -5.08004e-60, -1.74753e-65, -1.06561e-71,
-    -5.67879e-79, -5.78459e-130, -2.90989e-171, -7.15489e-243, -3.76242e-252,
-    -1.05639e-263, -4.40497e-267, -2.19666e-273, -4.9998e-276, -5.59821e-278,
-    -2.03855e-282, -5.99335e-283, -7.17554e-284, -3.11744e-309, -0.0, 0.0,
-    2.22507e-308, 1.30127e-270, 7.62898e-260, 4.00313e-249, 3.16829e-233,
-    1.85244e-228, 2.03544e-129, 1.35126e-110, 1.01182e-106, 5.26333e-94,
-    1.35292e-90, 2.85394e-83, 1.78323e-77, 5.4967e-57, 1.03207e-25, 4.57401e-25,
-    1.58738e-05, 2, 125, 2310, 9636, 14802, 17168, 28945, 29305, 4.81336e+07,
-    1.41207e+08, 4.65962e+08, 1.40499e+09, 2.12648e+09, 8.80006e+30, 1.4446e+45,
-    1.12164e+54, 2.48188e+89, 6.71121e+102, 3.074e+112, 4.9699e+152,
-    5.58383e+166, 4.30654e+172, 7.08824e+185, 9.6586e+214, 2.028e+223,
-    6.63277e+243, 1.56192e+261, 1.23202e+269, 5.72883e+289, 8.5798e+290,
-    1.40256e+294, 1.79769e+308, std::numeric_limits<double>::infinity()};
+    -V8_INFINITY,  -4.23878e+275, -5.82632e+265, -6.60355e+220, -6.26172e+212,
+    -2.56222e+211, -4.82408e+201, -1.84106e+157, -1.63662e+127, -1.55772e+100,
+    -1.67813e+72,  -2.3382e+55,   -3.179e+30,    -1.441e+09,    -1.0647e+09,
+    -7.99361e+08,  -5.77375e+08,  -2.20984e+08,  -32757,        -13171,
+    -9970,         -3984,         -107,          -105,          -92,
+    -77,           -61,           -0.000208163,  -1.86685e-06,  -1.17296e-10,
+    -9.26358e-11,  -5.08004e-60,  -1.74753e-65,  -1.06561e-71,  -5.67879e-79,
+    -5.78459e-130, -2.90989e-171, -7.15489e-243, -3.76242e-252, -1.05639e-263,
+    -4.40497e-267, -2.19666e-273, -4.9998e-276,  -5.59821e-278, -2.03855e-282,
+    -5.99335e-283, -7.17554e-284, -3.11744e-309, -0.0,          0.0,
+    2.22507e-308,  1.30127e-270,  7.62898e-260,  4.00313e-249,  3.16829e-233,
+    1.85244e-228,  2.03544e-129,  1.35126e-110,  1.01182e-106,  5.26333e-94,
+    1.35292e-90,   2.85394e-83,   1.78323e-77,   5.4967e-57,    1.03207e-25,
+    4.57401e-25,   1.58738e-05,   2,             125,           2310,
+    9636,          14802,         17168,         28945,         29305,
+    4.81336e+07,   1.41207e+08,   4.65962e+08,   1.40499e+09,   2.12648e+09,
+    8.80006e+30,   1.4446e+45,    1.12164e+54,   2.48188e+89,   6.71121e+102,
+    3.074e+112,    4.9699e+152,   5.58383e+166,  4.30654e+172,  7.08824e+185,
+    9.6586e+214,   2.028e+223,    6.63277e+243,  1.56192e+261,  1.23202e+269,
+    5.72883e+289,  8.5798e+290,   1.40256e+294,  1.79769e+308,  V8_INFINITY};
 
 
 const int32_t kInt32Values[] = {
index c94d588..8a42f7d 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <limits>
-
 #include "src/compiler/js-graph.h"
 #include "src/compiler/simplified-operator.h"
 #include "src/compiler/simplified-operator-reducer.h"
@@ -52,25 +50,26 @@ class SimplifiedOperatorReducerTestWithParam
 namespace {
 
 static const double kFloat64Values[] = {
-    -std::numeric_limits<double>::infinity(), -6.52696e+290, -1.05768e+290,
-    -5.34203e+268, -1.01997e+268, -8.22758e+266, -1.58402e+261, -5.15246e+241,
-    -5.92107e+226, -1.21477e+226, -1.67913e+188, -1.6257e+184, -2.60043e+170,
-    -2.52941e+168, -3.06033e+116, -4.56201e+52, -3.56788e+50, -9.9066e+38,
-    -3.07261e+31, -2.1271e+09, -1.91489e+09, -1.73053e+09, -9.30675e+08, -26030,
-    -20453, -15790, -11699, -111, -97, -78, -63, -58, -1.53858e-06,
-    -2.98914e-12, -1.14741e-39, -8.20347e-57, -1.48932e-59, -3.17692e-66,
-    -8.93103e-81, -3.91337e-83, -6.0489e-92, -8.83291e-113, -4.28266e-117,
-    -1.92058e-178, -2.0567e-192, -1.68167e-194, -1.51841e-214, -3.98738e-234,
-    -7.31851e-242, -2.21875e-253, -1.11612e-293, -0.0, 0.0, 2.22507e-308,
-    1.06526e-307, 4.16643e-227, 6.76624e-223, 2.0432e-197, 3.16254e-184,
-    1.37315e-173, 2.88603e-172, 1.54155e-99, 4.42923e-81, 1.40539e-73,
-    5.4462e-73, 1.24064e-58, 3.11167e-58, 2.75826e-39, 0.143815, 58, 67, 601,
-    7941, 11644, 13697, 25680, 29882, 1.32165e+08, 1.62439e+08, 4.16837e+08,
-    9.59097e+08, 1.32491e+09, 1.8728e+09, 1.0672e+17, 2.69606e+46, 1.98285e+79,
-    1.0098e+82, 7.93064e+88, 3.67444e+121, 9.36506e+123, 7.27954e+162,
-    3.05316e+168, 1.16171e+175, 1.64771e+189, 1.1622e+202, 2.00748e+239,
-    2.51778e+244, 3.90282e+306, 1.79769e+308,
-    std::numeric_limits<double>::infinity()};
+    -V8_INFINITY,  -6.52696e+290, -1.05768e+290, -5.34203e+268, -1.01997e+268,
+    -8.22758e+266, -1.58402e+261, -5.15246e+241, -5.92107e+226, -1.21477e+226,
+    -1.67913e+188, -1.6257e+184,  -2.60043e+170, -2.52941e+168, -3.06033e+116,
+    -4.56201e+52,  -3.56788e+50,  -9.9066e+38,   -3.07261e+31,  -2.1271e+09,
+    -1.91489e+09,  -1.73053e+09,  -9.30675e+08,  -26030,        -20453,
+    -15790,        -11699,        -111,          -97,           -78,
+    -63,           -58,           -1.53858e-06,  -2.98914e-12,  -1.14741e-39,
+    -8.20347e-57,  -1.48932e-59,  -3.17692e-66,  -8.93103e-81,  -3.91337e-83,
+    -6.0489e-92,   -8.83291e-113, -4.28266e-117, -1.92058e-178, -2.0567e-192,
+    -1.68167e-194, -1.51841e-214, -3.98738e-234, -7.31851e-242, -2.21875e-253,
+    -1.11612e-293, -0.0,          0.0,           2.22507e-308,  1.06526e-307,
+    4.16643e-227,  6.76624e-223,  2.0432e-197,   3.16254e-184,  1.37315e-173,
+    2.88603e-172,  1.54155e-99,   4.42923e-81,   1.40539e-73,   5.4462e-73,
+    1.24064e-58,   3.11167e-58,   2.75826e-39,   0.143815,      58,
+    67,            601,           7941,          11644,         13697,
+    25680,         29882,         1.32165e+08,   1.62439e+08,   4.16837e+08,
+    9.59097e+08,   1.32491e+09,   1.8728e+09,    1.0672e+17,    2.69606e+46,
+    1.98285e+79,   1.0098e+82,    7.93064e+88,   3.67444e+121,  9.36506e+123,
+    7.27954e+162,  3.05316e+168,  1.16171e+175,  1.64771e+189,  1.1622e+202,
+    2.00748e+239,  2.51778e+244,  3.90282e+306,  1.79769e+308,  V8_INFINITY};
 
 
 static const int32_t kInt32Values[] = {