| 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 "src/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
| 8 #include "src/compiler/typer.h" | 8 #include "src/compiler/typer.h" |
| 9 #include "test/unittests/compiler/graph-unittest.h" | 9 #include "test/unittests/compiler/graph-unittest.h" |
| 10 #include "test/unittests/compiler/node-test-utils.h" | 10 #include "test/unittests/compiler/node-test-utils.h" |
| 11 #include "testing/gmock-support.h" | 11 #include "testing/gmock-support.h" |
| 12 | 12 |
| 13 using testing::BitEq; |
| 13 using testing::Capture; | 14 using testing::Capture; |
| 14 | 15 |
| 15 namespace v8 { | 16 namespace v8 { |
| 16 namespace internal { | 17 namespace internal { |
| 17 namespace compiler { | 18 namespace compiler { |
| 18 | 19 |
| 19 class JSBuiltinReducerTest : public TypedGraphTest { | 20 class JSBuiltinReducerTest : public TypedGraphTest { |
| 20 public: | 21 public: |
| 21 JSBuiltinReducerTest() : javascript_(zone()) {} | 22 JSBuiltinReducerTest() : javascript_(zone()) {} |
| 22 | 23 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), | 77 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), |
| 77 fun, UndefinedConstant(), p0); | 78 fun, UndefinedConstant(), p0); |
| 78 Reduction r = Reduce(call); | 79 Reduction r = Reduce(call); |
| 79 | 80 |
| 80 if (t0->Is(Type::Unsigned32())) { | 81 if (t0->Is(Type::Unsigned32())) { |
| 81 ASSERT_TRUE(r.Changed()); | 82 ASSERT_TRUE(r.Changed()); |
| 82 EXPECT_THAT(r.replacement(), p0); | 83 EXPECT_THAT(r.replacement(), p0); |
| 83 } else { | 84 } else { |
| 84 Capture<Node*> branch; | 85 Capture<Node*> branch; |
| 85 ASSERT_TRUE(r.Changed()); | 86 ASSERT_TRUE(r.Changed()); |
| 86 EXPECT_THAT(r.replacement(), | 87 EXPECT_THAT( |
| 87 IsSelect(kMachNone, IsNumberLessThan(IsNumberConstant(0), p0), | 88 r.replacement(), |
| 88 p0, IsNumberSubtract(IsNumberConstant(0), p0))); | 89 IsSelect(kMachNone, |
| 90 IsNumberLessThan(IsNumberConstant(BitEq(0.0)), p0), p0, |
| 91 IsNumberSubtract(IsNumberConstant(BitEq(0.0)), p0))); |
| 89 } | 92 } |
| 90 } | 93 } |
| 91 } | 94 } |
| 92 | 95 |
| 93 | 96 |
| 94 // ----------------------------------------------------------------------------- | 97 // ----------------------------------------------------------------------------- |
| 95 // Math.sqrt | 98 // Math.sqrt |
| 96 | 99 |
| 97 | 100 |
| 98 TEST_F(JSBuiltinReducerTest, MathSqrt) { | 101 TEST_F(JSBuiltinReducerTest, MathSqrt) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), | 294 graph()->NewNode(javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), |
| 292 fun, UndefinedConstant(), p0); | 295 fun, UndefinedConstant(), p0); |
| 293 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags); | 296 Reduction r = Reduce(call, MachineOperatorBuilder::Flag::kNoFlags); |
| 294 | 297 |
| 295 ASSERT_FALSE(r.Changed()); | 298 ASSERT_FALSE(r.Changed()); |
| 296 } | 299 } |
| 297 } | 300 } |
| 298 } // namespace compiler | 301 } // namespace compiler |
| 299 } // namespace internal | 302 } // namespace internal |
| 300 } // namespace v8 | 303 } // namespace v8 |
| OLD | NEW |