From: Benedikt Meurer Date: Thu, 15 Jan 2015 15:09:50 +0000 (+0100) Subject: [turbofan] Make Factory::NewNumber() always return the minus_zero_value. X-Git-Tag: upstream/4.7.83~4960 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55b3e268b2895e2c09230d39669a75b6ab4e7e4d;p=platform%2Fupstream%2Fv8.git [turbofan] Make Factory::NewNumber() always return the minus_zero_value. TEST=unittests R=mstarzinger@chromium.org, dcarney@chromium.org Review URL: https://codereview.chromium.org/838263006 Cr-Commit-Position: refs/heads/master@{#26080} --- diff --git a/src/factory.cc b/src/factory.cc index 9688305..320e14f 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -1018,7 +1018,7 @@ Handle Factory::NewNumber(double value, // We need to distinguish the minus zero value and this cannot be // done after conversion to int. Doing this by comparing bit // patterns is faster than using fpclassify() et al. - if (IsMinusZero(value)) return NewHeapNumber(-0.0, IMMUTABLE, pretenure); + if (IsMinusZero(value)) return minus_zero_value(); int int_value = FastD2IChecked(value); if (value == int_value && Smi::IsValid(int_value)) { diff --git a/test/unittests/factory-unittest.cc b/test/unittests/factory-unittest.cc new file mode 100644 index 0000000..472f364 --- /dev/null +++ b/test/unittests/factory-unittest.cc @@ -0,0 +1,21 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/factory.h" +#include "src/handles-inl.h" +#include "test/unittests/test-utils.h" + +namespace v8 { +namespace internal { + +typedef TestWithIsolate FactoryTest; + + +TEST_F(FactoryTest, NewNumberWithMinusZero) { + Handle minus_zero_value = factory()->minus_zero_value(); + EXPECT_TRUE(minus_zero_value.is_identical_to(factory()->NewNumber(-0.0))); +} + +} // namespace internal +} // namespace v8 diff --git a/test/unittests/unittests.gyp b/test/unittests/unittests.gyp index fe4a127..357d644 100644 --- a/test/unittests/unittests.gyp +++ b/test/unittests/unittests.gyp @@ -67,6 +67,7 @@ 'compiler/simplified-operator-unittest.cc', 'compiler/value-numbering-reducer-unittest.cc', 'compiler/zone-pool-unittest.cc', + 'factory-unittest.cc', 'libplatform/default-platform-unittest.cc', 'libplatform/task-queue-unittest.cc', 'libplatform/worker-thread-unittest.cc',