Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: test/unittests/compiler/node-test-utils.cc

Issue 1114163005: [turbofan] Fix tail call optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/unittests/compiler/node-test-utils.h" 5 #include "test/unittests/compiler/node-test-utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "src/assembler.h" 9 #include "src/assembler.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 652 }
653 653
654 private: 654 private:
655 const Matcher<CallDescriptor*> descriptor_matcher_; 655 const Matcher<CallDescriptor*> descriptor_matcher_;
656 const std::vector<Matcher<Node*>> value_matchers_; 656 const std::vector<Matcher<Node*>> value_matchers_;
657 const Matcher<Node*> effect_matcher_; 657 const Matcher<Node*> effect_matcher_;
658 const Matcher<Node*> control_matcher_; 658 const Matcher<Node*> control_matcher_;
659 }; 659 };
660 660
661 661
662 class IsTailCallMatcher final : public NodeMatcher {
663 public:
664 IsTailCallMatcher(const Matcher<CallDescriptor const*>& descriptor_matcher,
665 const std::vector<Matcher<Node*>>& value_matchers,
666 const Matcher<Node*>& effect_matcher,
667 const Matcher<Node*>& control_matcher)
668 : NodeMatcher(IrOpcode::kTailCall),
669 descriptor_matcher_(descriptor_matcher),
670 value_matchers_(value_matchers),
671 effect_matcher_(effect_matcher),
672 control_matcher_(control_matcher) {}
673
674 void DescribeTo(std::ostream* os) const final {
675 NodeMatcher::DescribeTo(os);
676 for (size_t i = 0; i < value_matchers_.size(); ++i) {
677 if (i == 0) {
678 *os << " whose value0 (";
679 } else {
680 *os << "), value" << i << " (";
681 }
682 value_matchers_[i].DescribeTo(os);
683 }
684 *os << "), effect (";
685 effect_matcher_.DescribeTo(os);
686 *os << ") and control (";
687 control_matcher_.DescribeTo(os);
688 *os << ")";
689 }
690
691 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
692 if (!NodeMatcher::MatchAndExplain(node, listener) ||
693 !PrintMatchAndExplain(OpParameter<CallDescriptor const*>(node),
694 "descriptor", descriptor_matcher_, listener)) {
695 return false;
696 }
697 for (size_t i = 0; i < value_matchers_.size(); ++i) {
698 std::ostringstream ost;
699 ost << "value" << i;
700 if (!PrintMatchAndExplain(
701 NodeProperties::GetValueInput(node, static_cast<int>(i)),
702 ost.str(), value_matchers_[i], listener)) {
703 return false;
704 }
705 }
706 return (PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
707 effect_matcher_, listener) &&
708 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
709 "control", control_matcher_, listener));
710 }
711
712 private:
713 const Matcher<CallDescriptor const*> descriptor_matcher_;
714 const std::vector<Matcher<Node*>> value_matchers_;
715 const Matcher<Node*> effect_matcher_;
716 const Matcher<Node*> control_matcher_;
717 };
718
719
662 class IsAllocateMatcher final : public NodeMatcher { 720 class IsAllocateMatcher final : public NodeMatcher {
663 public: 721 public:
664 IsAllocateMatcher(const Matcher<Node*>& size_matcher, 722 IsAllocateMatcher(const Matcher<Node*>& size_matcher,
665 const Matcher<Node*>& effect_matcher, 723 const Matcher<Node*>& effect_matcher,
666 const Matcher<Node*>& control_matcher) 724 const Matcher<Node*>& control_matcher)
667 : NodeMatcher(IrOpcode::kAllocate), 725 : NodeMatcher(IrOpcode::kAllocate),
668 size_matcher_(size_matcher), 726 size_matcher_(size_matcher),
669 effect_matcher_(effect_matcher), 727 effect_matcher_(effect_matcher),
670 control_matcher_(control_matcher) {} 728 control_matcher_(control_matcher) {}
671 729
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 value_matchers.push_back(value2_matcher); 1548 value_matchers.push_back(value2_matcher);
1491 value_matchers.push_back(value3_matcher); 1549 value_matchers.push_back(value3_matcher);
1492 value_matchers.push_back(value4_matcher); 1550 value_matchers.push_back(value4_matcher);
1493 value_matchers.push_back(value5_matcher); 1551 value_matchers.push_back(value5_matcher);
1494 value_matchers.push_back(value6_matcher); 1552 value_matchers.push_back(value6_matcher);
1495 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, 1553 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1496 effect_matcher, control_matcher)); 1554 effect_matcher, control_matcher));
1497 } 1555 }
1498 1556
1499 1557
1558 Matcher<Node*> IsTailCall(
1559 const Matcher<CallDescriptor const*>& descriptor_matcher,
1560 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1561 const Matcher<Node*>& effect_matcher,
1562 const Matcher<Node*>& control_matcher) {
1563 std::vector<Matcher<Node*>> value_matchers;
1564 value_matchers.push_back(value0_matcher);
1565 value_matchers.push_back(value1_matcher);
1566 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1567 effect_matcher, control_matcher));
1568 }
1569
1570
1500 Matcher<Node*> IsAllocate(const Matcher<Node*>& size_matcher, 1571 Matcher<Node*> IsAllocate(const Matcher<Node*>& size_matcher,
1501 const Matcher<Node*>& effect_matcher, 1572 const Matcher<Node*>& effect_matcher,
1502 const Matcher<Node*>& control_matcher) { 1573 const Matcher<Node*>& control_matcher) {
1503 return MakeMatcher( 1574 return MakeMatcher(
1504 new IsAllocateMatcher(size_matcher, effect_matcher, control_matcher)); 1575 new IsAllocateMatcher(size_matcher, effect_matcher, control_matcher));
1505 } 1576 }
1506 1577
1507 1578
1508 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher, 1579 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
1509 const Matcher<Node*>& base_matcher, 1580 const Matcher<Node*>& base_matcher,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 IS_UNOP_MATCHER(NumberToInt32) 1738 IS_UNOP_MATCHER(NumberToInt32)
1668 IS_UNOP_MATCHER(NumberToUint32) 1739 IS_UNOP_MATCHER(NumberToUint32)
1669 IS_UNOP_MATCHER(ObjectIsSmi) 1740 IS_UNOP_MATCHER(ObjectIsSmi)
1670 IS_UNOP_MATCHER(ObjectIsNonNegativeSmi) 1741 IS_UNOP_MATCHER(ObjectIsNonNegativeSmi)
1671 IS_UNOP_MATCHER(Word32Clz) 1742 IS_UNOP_MATCHER(Word32Clz)
1672 #undef IS_UNOP_MATCHER 1743 #undef IS_UNOP_MATCHER
1673 1744
1674 } // namespace compiler 1745 } // namespace compiler
1675 } // namespace internal 1746 } // namespace internal
1676 } // namespace v8 1747 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698