From 73d16d9ad83f09e3434d82c5af82960e74cb9153 Mon Sep 17 00:00:00 2001 From: Matt Gardner Date: Mon, 25 Feb 2019 17:32:00 -0800 Subject: [PATCH] Remove obsolete MSVC 10.0 workaround for std::floor MSVC 14.x and 15.x handle -0 correctly unless /fp:fast is used. /fp:precise is the default. bug: v8:3477, v8:8912 Change-Id: I242a1dfd845f750cab7c56f13107612259d44d23 Reviewed-on: https://chromium-review.googlesource.com/c/1487414 Reviewed-by: Sigurd Schneider Reviewed-by: Yang Guo Commit-Queue: Yang Guo Cr-Commit-Position: refs/heads/master@{#59849} --- src/compiler/machine-operator-reducer.cc | 2 +- src/objects/js-objects.cc | 2 +- src/utils.h | 8 -------- .../compiler/machine-operator-reducer-unittest.cc | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc index eb6db4e633..a2fa6a5bb7 100644 --- a/src/compiler/machine-operator-reducer.cc +++ b/src/compiler/machine-operator-reducer.cc @@ -1461,7 +1461,7 @@ Reduction MachineOperatorReducer::ReduceFloat64RoundDown(Node* node) { DCHECK_EQ(IrOpcode::kFloat64RoundDown, node->opcode()); Float64Matcher m(node->InputAt(0)); if (m.HasValue()) { - return ReplaceFloat64(Floor(m.Value())); + return ReplaceFloat64(std::floor(m.Value())); } return NoChange(); } diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc index 455276b3e4..439b4b1c5e 100644 --- a/src/objects/js-objects.cc +++ b/src/objects/js-objects.cc @@ -5575,7 +5575,7 @@ double JSDate::CurrentTimeValue(Isolate* isolate) { // the number in a Date object representing a particular instant in // time is milliseconds. Therefore, we floor the result of getting // the OS time. - return Floor(V8::GetCurrentPlatform()->CurrentClockTimeMillis()); + return std::floor(V8::GetCurrentPlatform()->CurrentClockTimeMillis()); } // static diff --git a/src/utils.h b/src/utils.h index 01a8fc7b07..adceb8d930 100644 --- a/src/utils.h +++ b/src/utils.h @@ -220,14 +220,6 @@ T Nabs(T a) { return a < 0 ? a : -a; } -// Floor(-0.0) == 0.0 -inline double Floor(double x) { -#if V8_CC_MSVC - if (x == 0) return x; // Fix for issue 3477. -#endif - return std::floor(x); -} - inline double Modulo(double x, double y) { #if defined(V8_OS_WIN) // Workaround MS fmod bugs. ECMA-262 says: diff --git a/test/unittests/compiler/machine-operator-reducer-unittest.cc b/test/unittests/compiler/machine-operator-reducer-unittest.cc index 7782636408..e7ff126702 100644 --- a/test/unittests/compiler/machine-operator-reducer-unittest.cc +++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc @@ -2227,7 +2227,7 @@ TEST_F(MachineOperatorReducerTest, Float64RoundDownWithConstant) { Reduction r = Reduce(graph()->NewNode( machine()->Float64RoundDown().placeholder(), Float64Constant(x))); ASSERT_TRUE(r.Changed()); - EXPECT_THAT(r.replacement(), IsFloat64Constant(Floor(x))); + EXPECT_THAT(r.replacement(), IsFloat64Constant(std::floor(x))); } }