| 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/graph-unittest.h" | 5 #include "src/compiler/graph-unittest.h" |
| 6 | 6 |
| 7 #include <ostream> // NOLINT(readability/streams) | 7 #include <ostream> // NOLINT(readability/streams) |
| 8 | 8 |
| 9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
| 10 | 10 |
| 11 using testing::_; | 11 using testing::_; |
| 12 using testing::MakeMatcher; | 12 using testing::MakeMatcher; |
| 13 using testing::MatcherInterface; | 13 using testing::MatcherInterface; |
| 14 using testing::MatchResultListener; | 14 using testing::MatchResultListener; |
| 15 using testing::StringMatchResultListener; | 15 using testing::StringMatchResultListener; |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 // TODO(bmeurer): Find a new home for these functions. | 20 // TODO(bmeurer): Find a new home for these functions. |
| 21 template <typename T> | 21 template <typename T> |
| 22 inline std::ostream& operator<<(std::ostream& os, | 22 inline std::ostream& operator<<(std::ostream& os, const Unique<T>& value) { |
| 23 const PrintableUnique<T>& value) { | 23 return os << *value.handle(); |
| 24 return os << value.string(); | |
| 25 } | 24 } |
| 26 inline std::ostream& operator<<(std::ostream& os, | 25 inline std::ostream& operator<<(std::ostream& os, |
| 27 const ExternalReference& value) { | 26 const ExternalReference& value) { |
| 28 OStringStream ost; | 27 OStringStream ost; |
| 29 compiler::StaticParameterTraits<ExternalReference>::PrintTo(ost, value); | 28 compiler::StaticParameterTraits<ExternalReference>::PrintTo(ost, value); |
| 30 return os << ost.c_str(); | 29 return os << ost.c_str(); |
| 31 } | 30 } |
| 32 | 31 |
| 33 namespace compiler { | 32 namespace compiler { |
| 34 | 33 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 58 Node* GraphTest::Int64Constant(int64_t value) { | 57 Node* GraphTest::Int64Constant(int64_t value) { |
| 59 return graph()->NewNode(common()->Int64Constant(value)); | 58 return graph()->NewNode(common()->Int64Constant(value)); |
| 60 } | 59 } |
| 61 | 60 |
| 62 | 61 |
| 63 Node* GraphTest::NumberConstant(double value) { | 62 Node* GraphTest::NumberConstant(double value) { |
| 64 return graph()->NewNode(common()->NumberConstant(value)); | 63 return graph()->NewNode(common()->NumberConstant(value)); |
| 65 } | 64 } |
| 66 | 65 |
| 67 | 66 |
| 68 Node* GraphTest::HeapConstant(const PrintableUnique<HeapObject>& value) { | 67 Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) { |
| 69 return graph()->NewNode(common()->HeapConstant(value)); | 68 return graph()->NewNode(common()->HeapConstant(value)); |
| 70 } | 69 } |
| 71 | 70 |
| 72 | 71 |
| 73 Node* GraphTest::FalseConstant() { | 72 Node* GraphTest::FalseConstant() { |
| 74 return HeapConstant(PrintableUnique<HeapObject>::CreateImmovable( | 73 return HeapConstant( |
| 75 zone(), factory()->false_value())); | 74 Unique<HeapObject>::CreateImmovable(factory()->false_value())); |
| 76 } | 75 } |
| 77 | 76 |
| 78 | 77 |
| 79 Node* GraphTest::TrueConstant() { | 78 Node* GraphTest::TrueConstant() { |
| 80 return HeapConstant(PrintableUnique<HeapObject>::CreateImmovable( | 79 return HeapConstant( |
| 81 zone(), factory()->true_value())); | 80 Unique<HeapObject>::CreateImmovable(factory()->true_value())); |
| 82 } | 81 } |
| 83 | 82 |
| 84 | 83 |
| 85 Matcher<Node*> GraphTest::IsFalseConstant() { | 84 Matcher<Node*> GraphTest::IsFalseConstant() { |
| 86 return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( | 85 return IsHeapConstant( |
| 87 zone(), factory()->false_value())); | 86 Unique<HeapObject>::CreateImmovable(factory()->false_value())); |
| 88 } | 87 } |
| 89 | 88 |
| 90 | 89 |
| 91 Matcher<Node*> GraphTest::IsTrueConstant() { | 90 Matcher<Node*> GraphTest::IsTrueConstant() { |
| 92 return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( | 91 return IsHeapConstant( |
| 93 zone(), factory()->true_value())); | 92 Unique<HeapObject>::CreateImmovable(factory()->true_value())); |
| 94 } | 93 } |
| 95 | 94 |
| 96 namespace { | 95 namespace { |
| 97 | 96 |
| 98 template <typename T> | 97 template <typename T> |
| 99 bool PrintMatchAndExplain(const T& value, const char* value_name, | 98 bool PrintMatchAndExplain(const T& value, const char* value_name, |
| 100 const Matcher<T>& value_matcher, | 99 const Matcher<T>& value_matcher, |
| 101 MatchResultListener* listener) { | 100 MatchResultListener* listener) { |
| 102 StringMatchResultListener value_listener; | 101 StringMatchResultListener value_listener; |
| 103 if (!value_matcher.MatchAndExplain(value, &value_listener)) { | 102 if (!value_matcher.MatchAndExplain(value, &value_listener)) { |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 | 632 |
| 634 | 633 |
| 635 Matcher<Node*> IsExternalConstant( | 634 Matcher<Node*> IsExternalConstant( |
| 636 const Matcher<ExternalReference>& value_matcher) { | 635 const Matcher<ExternalReference>& value_matcher) { |
| 637 return MakeMatcher(new IsConstantMatcher<ExternalReference>( | 636 return MakeMatcher(new IsConstantMatcher<ExternalReference>( |
| 638 IrOpcode::kExternalConstant, value_matcher)); | 637 IrOpcode::kExternalConstant, value_matcher)); |
| 639 } | 638 } |
| 640 | 639 |
| 641 | 640 |
| 642 Matcher<Node*> IsHeapConstant( | 641 Matcher<Node*> IsHeapConstant( |
| 643 const Matcher<PrintableUnique<HeapObject> >& value_matcher) { | 642 const Matcher<Unique<HeapObject> >& value_matcher) { |
| 644 return MakeMatcher(new IsConstantMatcher<PrintableUnique<HeapObject> >( | 643 return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >( |
| 645 IrOpcode::kHeapConstant, value_matcher)); | 644 IrOpcode::kHeapConstant, value_matcher)); |
| 646 } | 645 } |
| 647 | 646 |
| 648 | 647 |
| 649 Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) { | 648 Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) { |
| 650 return MakeMatcher( | 649 return MakeMatcher( |
| 651 new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher)); | 650 new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher)); |
| 652 } | 651 } |
| 653 | 652 |
| 654 | 653 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 IS_UNOP_MATCHER(ChangeInt32ToInt64) | 748 IS_UNOP_MATCHER(ChangeInt32ToInt64) |
| 750 IS_UNOP_MATCHER(ChangeUint32ToFloat64) | 749 IS_UNOP_MATCHER(ChangeUint32ToFloat64) |
| 751 IS_UNOP_MATCHER(ChangeUint32ToUint64) | 750 IS_UNOP_MATCHER(ChangeUint32ToUint64) |
| 752 IS_UNOP_MATCHER(TruncateFloat64ToInt32) | 751 IS_UNOP_MATCHER(TruncateFloat64ToInt32) |
| 753 IS_UNOP_MATCHER(TruncateInt64ToInt32) | 752 IS_UNOP_MATCHER(TruncateInt64ToInt32) |
| 754 #undef IS_UNOP_MATCHER | 753 #undef IS_UNOP_MATCHER |
| 755 | 754 |
| 756 } // namespace compiler | 755 } // namespace compiler |
| 757 } // namespace internal | 756 } // namespace internal |
| 758 } // namespace v8 | 757 } // namespace v8 |
| OLD | NEW |