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/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/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 1851 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
1852 "control", control_matcher_, listener)); | 1852 "control", control_matcher_, listener)); |
1853 } | 1853 } |
1854 | 1854 |
1855 private: | 1855 private: |
1856 const std::vector<Matcher<Node*>> value_matchers_; | 1856 const std::vector<Matcher<Node*>> value_matchers_; |
1857 const Matcher<Node*> effect_matcher_; | 1857 const Matcher<Node*> effect_matcher_; |
1858 const Matcher<Node*> control_matcher_; | 1858 const Matcher<Node*> control_matcher_; |
1859 }; | 1859 }; |
1860 | 1860 |
| 1861 |
| 1862 class IsCreateClosureMatcher final : public NodeMatcher { |
| 1863 public: |
| 1864 IsCreateClosureMatcher( |
| 1865 const Matcher<SharedFunctionInfo*>& shared_function_info_matcher, |
| 1866 const Matcher<PretenureFlag>& pretenure_flag_matcher, |
| 1867 const Matcher<Node*>& effect_matcher, |
| 1868 const Matcher<Node*>& control_matcher) |
| 1869 : NodeMatcher(IrOpcode::Value::kJSCreateClosure), |
| 1870 shared_function_info_matcher_(shared_function_info_matcher), |
| 1871 pretenure_flag_matcher_(pretenure_flag_matcher), |
| 1872 effect_matcher_(effect_matcher), |
| 1873 control_matcher_(control_matcher) {} |
| 1874 |
| 1875 void DescribeTo(std::ostream* os) const final { |
| 1876 NodeMatcher::DescribeTo(os); |
| 1877 *os << " whose value ("; |
| 1878 shared_function_info_matcher_.DescribeTo(os); |
| 1879 *os << ", "; |
| 1880 pretenure_flag_matcher_.DescribeTo(os); |
| 1881 *os << "), effect ("; |
| 1882 effect_matcher_.DescribeTo(os); |
| 1883 *os << ") and control ("; |
| 1884 control_matcher_.DescribeTo(os); |
| 1885 *os << ")"; |
| 1886 } |
| 1887 |
| 1888 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1889 if (!NodeMatcher::MatchAndExplain(node, listener)) { |
| 1890 return false; |
| 1891 } |
| 1892 return (PrintMatchAndExplain( |
| 1893 *OpParameter<CreateClosureParameters>(node).shared_info(), |
| 1894 "value.shared_info", shared_function_info_matcher_, listener) && |
| 1895 PrintMatchAndExplain( |
| 1896 OpParameter<CreateClosureParameters>(node).pretenure(), |
| 1897 "value.pretenure", pretenure_flag_matcher_, listener) && |
| 1898 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 1899 effect_matcher_, listener) && |
| 1900 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 1901 "control", control_matcher_, listener)); |
| 1902 } |
| 1903 |
| 1904 private: |
| 1905 const Matcher<SharedFunctionInfo*> shared_function_info_matcher_; |
| 1906 const Matcher<PretenureFlag> pretenure_flag_matcher_; |
| 1907 const Matcher<Node*> effect_matcher_; |
| 1908 const Matcher<Node*> control_matcher_; |
| 1909 }; |
| 1910 |
1861 } // namespace | 1911 } // namespace |
1862 | 1912 |
1863 | 1913 |
1864 Matcher<Node*> IsDead() { | 1914 Matcher<Node*> IsDead() { |
1865 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); | 1915 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); |
1866 } | 1916 } |
1867 | 1917 |
1868 | 1918 |
1869 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { | 1919 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { |
1870 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); | 1920 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2528 | 2578 |
2529 Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers, | 2579 Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers, |
2530 const Matcher<Node*>& effect_matcher, | 2580 const Matcher<Node*>& effect_matcher, |
2531 const Matcher<Node*>& control_matcher) { | 2581 const Matcher<Node*>& control_matcher) { |
2532 return MakeMatcher(new IsJSCallMatcher(IrOpcode::kJSCallRuntime, | 2582 return MakeMatcher(new IsJSCallMatcher(IrOpcode::kJSCallRuntime, |
2533 value_matchers, effect_matcher, | 2583 value_matchers, effect_matcher, |
2534 control_matcher)); | 2584 control_matcher)); |
2535 } | 2585 } |
2536 | 2586 |
2537 | 2587 |
| 2588 Matcher<Node*> IsCreateClosure( |
| 2589 const Matcher<SharedFunctionInfo*>& shared_function_info_matcher, |
| 2590 const Matcher<PretenureFlag>& pretenure_flag_matcher, |
| 2591 const Matcher<Node*>& effect_matcher, |
| 2592 const Matcher<Node*>& control_matcher) { |
| 2593 return MakeMatcher(new IsCreateClosureMatcher( |
| 2594 shared_function_info_matcher, pretenure_flag_matcher, effect_matcher, |
| 2595 control_matcher)); |
| 2596 } |
| 2597 |
| 2598 |
2538 #define IS_BINOP_MATCHER(Name) \ | 2599 #define IS_BINOP_MATCHER(Name) \ |
2539 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ | 2600 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
2540 const Matcher<Node*>& rhs_matcher) { \ | 2601 const Matcher<Node*>& rhs_matcher) { \ |
2541 return MakeMatcher( \ | 2602 return MakeMatcher( \ |
2542 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ | 2603 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ |
2543 } | 2604 } |
2544 IS_BINOP_MATCHER(NumberEqual) | 2605 IS_BINOP_MATCHER(NumberEqual) |
2545 IS_BINOP_MATCHER(NumberLessThan) | 2606 IS_BINOP_MATCHER(NumberLessThan) |
2546 IS_BINOP_MATCHER(NumberSubtract) | 2607 IS_BINOP_MATCHER(NumberSubtract) |
2547 IS_BINOP_MATCHER(NumberMultiply) | 2608 IS_BINOP_MATCHER(NumberMultiply) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 IS_UNOP_MATCHER(NumberToUint32) | 2674 IS_UNOP_MATCHER(NumberToUint32) |
2614 IS_UNOP_MATCHER(ObjectIsSmi) | 2675 IS_UNOP_MATCHER(ObjectIsSmi) |
2615 IS_UNOP_MATCHER(Word32Clz) | 2676 IS_UNOP_MATCHER(Word32Clz) |
2616 IS_UNOP_MATCHER(JSUnaryNot) | 2677 IS_UNOP_MATCHER(JSUnaryNot) |
2617 IS_UNOP_MATCHER(JSTypeOf) | 2678 IS_UNOP_MATCHER(JSTypeOf) |
2618 #undef IS_UNOP_MATCHER | 2679 #undef IS_UNOP_MATCHER |
2619 | 2680 |
2620 } // namespace compiler | 2681 } // namespace compiler |
2621 } // namespace internal | 2682 } // namespace internal |
2622 } // namespace v8 | 2683 } // namespace v8 |
OLD | NEW |