| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <limits> | |
| 6 | |
| 7 #include "src/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
| 8 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
| 10 #include "src/compiler/typer.h" | 8 #include "src/compiler/typer.h" |
| 11 #include "test/unittests/compiler/graph-unittest.h" | 9 #include "test/unittests/compiler/graph-unittest.h" |
| 12 #include "test/unittests/compiler/node-test-utils.h" | 10 #include "test/unittests/compiler/node-test-utils.h" |
| 13 #include "testing/gmock-support.h" | 11 #include "testing/gmock-support.h" |
| 14 | 12 |
| 15 using testing::Capture; | 13 using testing::Capture; |
| 16 | 14 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 TEST_F(JSBuiltinReducerTest, MathMax0) { | 125 TEST_F(JSBuiltinReducerTest, MathMax0) { |
| 128 Handle<JSFunction> f = MathFunction("max"); | 126 Handle<JSFunction> f = MathFunction("max"); |
| 129 | 127 |
| 130 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); | 128 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); |
| 131 Node* call = | 129 Node* call = |
| 132 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS), | 130 graph()->NewNode(javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS), |
| 133 fun, UndefinedConstant()); | 131 fun, UndefinedConstant()); |
| 134 Reduction r = Reduce(call); | 132 Reduction r = Reduce(call); |
| 135 | 133 |
| 136 ASSERT_TRUE(r.Changed()); | 134 ASSERT_TRUE(r.Changed()); |
| 137 EXPECT_THAT(r.replacement(), | 135 EXPECT_THAT(r.replacement(), IsNumberConstant(-V8_INFINITY)); |
| 138 IsNumberConstant(-std::numeric_limits<double>::infinity())); | |
| 139 } | 136 } |
| 140 | 137 |
| 141 | 138 |
| 142 TEST_F(JSBuiltinReducerTest, MathMax1) { | 139 TEST_F(JSBuiltinReducerTest, MathMax1) { |
| 143 Handle<JSFunction> f = MathFunction("max"); | 140 Handle<JSFunction> f = MathFunction("max"); |
| 144 | 141 |
| 145 TRACED_FOREACH(Type*, t0, kNumberTypes) { | 142 TRACED_FOREACH(Type*, t0, kNumberTypes) { |
| 146 Node* p0 = Parameter(t0, 0); | 143 Node* p0 = Parameter(t0, 0); |
| 147 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); | 144 Node* fun = HeapConstant(Unique<HeapObject>::CreateUninitialized(f)); |
| 148 Node* call = | 145 Node* call = |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), | 297 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), |
| 301 fun, UndefinedConstant(), p0); | 298 fun, UndefinedConstant(), p0); |
| 302 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags); | 299 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags); |
| 303 | 300 |
| 304 ASSERT_FALSE(r.Changed()); | 301 ASSERT_FALSE(r.Changed()); |
| 305 } | 302 } |
| 306 } | 303 } |
| 307 } // namespace compiler | 304 } // namespace compiler |
| 308 } // namespace internal | 305 } // namespace internal |
| 309 } // namespace v8 | 306 } // namespace v8 |
| OLD | NEW |