| 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
| 6 #include "src/compiler/change-lowering.h" | 6 #include "src/compiler/change-lowering.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/node-properties-inl.h" | 8 #include "src/compiler/node-properties-inl.h" |
| 9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
| 10 #include "test/unittests/compiler/compiler-test-utils.h" | 10 #include "test/unittests/compiler/compiler-test-utils.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // ----------------------------------------------------------------------------- | 106 // ----------------------------------------------------------------------------- |
| 107 // Common. | 107 // Common. |
| 108 | 108 |
| 109 | 109 |
| 110 class ChangeLoweringCommonTest | 110 class ChangeLoweringCommonTest |
| 111 : public ChangeLoweringTest, | 111 : public ChangeLoweringTest, |
| 112 public ::testing::WithParamInterface<MachineType> { | 112 public ::testing::WithParamInterface<MachineType> { |
| 113 public: | 113 public: |
| 114 virtual ~ChangeLoweringCommonTest() {} | 114 virtual ~ChangeLoweringCommonTest() {} |
| 115 | 115 |
| 116 virtual MachineType WordRepresentation() const FINAL OVERRIDE { | 116 virtual MachineType WordRepresentation() const FINAL { return GetParam(); } |
| 117 return GetParam(); | |
| 118 } | |
| 119 }; | 117 }; |
| 120 | 118 |
| 121 | 119 |
| 122 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { | 120 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { |
| 123 Node* val = Parameter(0); | 121 Node* val = Parameter(0); |
| 124 Node* node = graph()->NewNode(simplified()->ChangeBitToBool(), val); | 122 Node* node = graph()->NewNode(simplified()->ChangeBitToBool(), val); |
| 125 Reduction reduction = Reduce(node); | 123 Reduction reduction = Reduce(node); |
| 126 ASSERT_TRUE(reduction.Changed()); | 124 ASSERT_TRUE(reduction.Changed()); |
| 127 EXPECT_THAT(reduction.replacement(), | 125 EXPECT_THAT(reduction.replacement(), |
| 128 IsSelect(static_cast<MachineType>(kTypeBool | kRepTagged), val, | 126 IsSelect(static_cast<MachineType>(kTypeBool | kRepTagged), val, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 ::testing::Values(kRepWord32, kRepWord64)); | 170 ::testing::Values(kRepWord32, kRepWord64)); |
| 173 | 171 |
| 174 | 172 |
| 175 // ----------------------------------------------------------------------------- | 173 // ----------------------------------------------------------------------------- |
| 176 // 32-bit | 174 // 32-bit |
| 177 | 175 |
| 178 | 176 |
| 179 class ChangeLowering32Test : public ChangeLoweringTest { | 177 class ChangeLowering32Test : public ChangeLoweringTest { |
| 180 public: | 178 public: |
| 181 virtual ~ChangeLowering32Test() {} | 179 virtual ~ChangeLowering32Test() {} |
| 182 virtual MachineType WordRepresentation() const FINAL OVERRIDE { | 180 virtual MachineType WordRepresentation() const FINAL { return kRepWord32; } |
| 183 return kRepWord32; | |
| 184 } | |
| 185 }; | 181 }; |
| 186 | 182 |
| 187 | 183 |
| 188 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { | 184 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { |
| 189 Node* val = Parameter(0); | 185 Node* val = Parameter(0); |
| 190 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); | 186 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); |
| 191 NodeProperties::SetBounds(val, Bounds(Type::None(), Type::Signed32())); | 187 NodeProperties::SetBounds(val, Bounds(Type::None(), Type::Signed32())); |
| 192 Reduction reduction = Reduce(node); | 188 Reduction reduction = Reduce(node); |
| 193 ASSERT_TRUE(reduction.Changed()); | 189 ASSERT_TRUE(reduction.Changed()); |
| 194 | 190 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 328 } |
| 333 | 329 |
| 334 | 330 |
| 335 // ----------------------------------------------------------------------------- | 331 // ----------------------------------------------------------------------------- |
| 336 // 64-bit | 332 // 64-bit |
| 337 | 333 |
| 338 | 334 |
| 339 class ChangeLowering64Test : public ChangeLoweringTest { | 335 class ChangeLowering64Test : public ChangeLoweringTest { |
| 340 public: | 336 public: |
| 341 virtual ~ChangeLowering64Test() {} | 337 virtual ~ChangeLowering64Test() {} |
| 342 virtual MachineType WordRepresentation() const FINAL OVERRIDE { | 338 virtual MachineType WordRepresentation() const FINAL { return kRepWord64; } |
| 343 return kRepWord64; | |
| 344 } | |
| 345 }; | 339 }; |
| 346 | 340 |
| 347 | 341 |
| 348 TARGET_TEST_F(ChangeLowering64Test, ChangeInt32ToTagged) { | 342 TARGET_TEST_F(ChangeLowering64Test, ChangeInt32ToTagged) { |
| 349 Node* val = Parameter(0); | 343 Node* val = Parameter(0); |
| 350 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); | 344 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); |
| 351 Reduction reduction = Reduce(node); | 345 Reduction reduction = Reduce(node); |
| 352 ASSERT_TRUE(reduction.Changed()); | 346 ASSERT_TRUE(reduction.Changed()); |
| 353 | 347 |
| 354 EXPECT_THAT(reduction.replacement(), | 348 EXPECT_THAT(reduction.replacement(), |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 IsIfTrue(AllOf(CaptureEq(&branch), | 455 IsIfTrue(AllOf(CaptureEq(&branch), |
| 462 IsBranch(IsUint32LessThanOrEqual( | 456 IsBranch(IsUint32LessThanOrEqual( |
| 463 val, IsInt32Constant(SmiMaxValue())), | 457 val, IsInt32Constant(SmiMaxValue())), |
| 464 graph()->start()))), | 458 graph()->start()))), |
| 465 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 459 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
| 466 } | 460 } |
| 467 | 461 |
| 468 } // namespace compiler | 462 } // namespace compiler |
| 469 } // namespace internal | 463 } // namespace internal |
| 470 } // namespace v8 | 464 } // namespace v8 |
| OLD | NEW |