| 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 "test/compiler-unittests/graph-unittest.h" | 5 #include "test/compiler-unittests/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::MakeMatcher; | 12 using testing::MakeMatcher; |
| 12 using testing::MatcherInterface; | 13 using testing::MatcherInterface; |
| 13 using testing::MatchResultListener; | 14 using testing::MatchResultListener; |
| 14 using testing::StringMatchResultListener; | 15 using testing::StringMatchResultListener; |
| 15 | 16 |
| 16 namespace v8 { | 17 namespace v8 { |
| 17 namespace internal { | 18 namespace internal { |
| 18 | 19 |
| 19 // TODO(bmeurer): Find a new home for these functions. | 20 // TODO(bmeurer): Find a new home for these functions. |
| 20 template <typename T> | 21 template <typename T> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 namespace compiler { | 33 namespace compiler { |
| 33 | 34 |
| 34 GraphTest::GraphTest(int num_parameters) : graph_(zone()) { | 35 GraphTest::GraphTest(int num_parameters) : graph_(zone()) { |
| 35 graph()->SetStart(graph()->NewNode(common()->Start(num_parameters))); | 36 graph()->SetStart(graph()->NewNode(common()->Start(num_parameters))); |
| 36 } | 37 } |
| 37 | 38 |
| 38 | 39 |
| 39 GraphTest::~GraphTest() {} | 40 GraphTest::~GraphTest() {} |
| 40 | 41 |
| 41 | 42 |
| 43 Matcher<Node*> GraphTest::IsAllocateHeapNumber( |
| 44 const Matcher<Node*>& effect_matcher, |
| 45 const Matcher<Node*>& control_matcher) { |
| 46 return IsCall( |
| 47 _, IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( |
| 48 zone(), CEntryStub(isolate(), 1).GetCode())), |
| 49 IsExternalConstant(ExternalReference( |
| 50 Runtime::FunctionForId(Runtime::kAllocateHeapNumber), isolate())), |
| 51 IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher, |
| 52 control_matcher); |
| 53 } |
| 54 |
| 55 |
| 42 namespace { | 56 namespace { |
| 43 | 57 |
| 44 template <typename T> | 58 template <typename T> |
| 45 bool PrintMatchAndExplain(const T& value, const char* value_name, | 59 bool PrintMatchAndExplain(const T& value, const char* value_name, |
| 46 const Matcher<T>& value_matcher, | 60 const Matcher<T>& value_matcher, |
| 47 MatchResultListener* listener) { | 61 MatchResultListener* listener) { |
| 48 StringMatchResultListener value_listener; | 62 StringMatchResultListener value_listener; |
| 49 if (!value_matcher.MatchAndExplain(value, &value_listener)) { | 63 if (!value_matcher.MatchAndExplain(value, &value_listener)) { |
| 50 *listener << "whose " << value_name << " " << value << " doesn't match"; | 64 *listener << "whose " << value_name << " " << value << " doesn't match"; |
| 51 if (value_listener.str() != "") { | 65 if (value_listener.str() != "") { |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher)); | 574 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher)); |
| 561 } | 575 } |
| 562 | 576 |
| 563 | 577 |
| 564 Matcher<Node*> IsControlEffect(const Matcher<Node*>& control_matcher) { | 578 Matcher<Node*> IsControlEffect(const Matcher<Node*>& control_matcher) { |
| 565 return MakeMatcher( | 579 return MakeMatcher( |
| 566 new IsControl1Matcher(IrOpcode::kControlEffect, control_matcher)); | 580 new IsControl1Matcher(IrOpcode::kControlEffect, control_matcher)); |
| 567 } | 581 } |
| 568 | 582 |
| 569 | 583 |
| 584 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) { |
| 585 return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect, value_matcher)); |
| 586 } |
| 587 |
| 588 |
| 570 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher, | 589 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher, |
| 571 const Matcher<Node*>& effect_matcher) { | 590 const Matcher<Node*>& effect_matcher) { |
| 572 return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher)); | 591 return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher)); |
| 573 } | 592 } |
| 574 | 593 |
| 575 | 594 |
| 576 Matcher<Node*> IsExternalConstant( | 595 Matcher<Node*> IsExternalConstant( |
| 577 const Matcher<ExternalReference>& value_matcher) { | 596 const Matcher<ExternalReference>& value_matcher) { |
| 578 return MakeMatcher(new IsConstantMatcher<ExternalReference>( | 597 return MakeMatcher(new IsConstantMatcher<ExternalReference>( |
| 579 IrOpcode::kExternalConstant, value_matcher)); | 598 IrOpcode::kExternalConstant, value_matcher)); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 IS_BINOP_MATCHER(Word64Equal) | 683 IS_BINOP_MATCHER(Word64Equal) |
| 665 IS_BINOP_MATCHER(Int32AddWithOverflow) | 684 IS_BINOP_MATCHER(Int32AddWithOverflow) |
| 666 #undef IS_BINOP_MATCHER | 685 #undef IS_BINOP_MATCHER |
| 667 | 686 |
| 668 | 687 |
| 669 #define IS_UNOP_MATCHER(Name) \ | 688 #define IS_UNOP_MATCHER(Name) \ |
| 670 Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \ | 689 Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \ |
| 671 return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \ | 690 return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \ |
| 672 } | 691 } |
| 673 IS_UNOP_MATCHER(ConvertInt64ToInt32) | 692 IS_UNOP_MATCHER(ConvertInt64ToInt32) |
| 693 IS_UNOP_MATCHER(ChangeFloat64ToInt32) |
| 674 IS_UNOP_MATCHER(ChangeInt32ToFloat64) | 694 IS_UNOP_MATCHER(ChangeInt32ToFloat64) |
| 675 #undef IS_UNOP_MATCHER | 695 #undef IS_UNOP_MATCHER |
| 676 | 696 |
| 677 } // namespace compiler | 697 } // namespace compiler |
| 678 } // namespace internal | 698 } // namespace internal |
| 679 } // namespace v8 | 699 } // namespace v8 |
| OLD | NEW |