Chromium Code Reviews| 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 CreateClosureParametersMatcher final | |
| 1863 : public MatcherInterface<CreateClosureParameters*> { | |
| 1864 public: | |
| 1865 explicit CreateClosureParametersMatcher(CreateClosureParameters* parameters) | |
| 1866 : parameters_(parameters) {} | |
| 1867 | |
| 1868 void DescribeTo(::std::ostream* os) const final { | |
| 1869 *os << "is a CreateClosureParameters instance"; | |
| 1870 } | |
| 1871 | |
| 1872 bool MatchAndExplain(CreateClosureParameters* parameters, | |
| 1873 MatchResultListener* listener) const override { | |
| 1874 if (parameters == NULL) { | |
| 1875 *listener << "which is NULL"; | |
| 1876 return false; | |
| 1877 } | |
| 1878 if (*parameters->shared_info() != *parameters_->shared_info()) { | |
| 1879 *listener << "whose shared function info is " | |
| 1880 << *parameters->shared_info() << " but should have been " | |
| 1881 << *parameters_->shared_info(); | |
| 1882 return false; | |
| 1883 } | |
| 1884 if (parameters->pretenure() != parameters_->pretenure()) { | |
| 1885 *listener << "whose tenured flag is " << parameters->pretenure() | |
| 1886 << " but should have been " << parameters_->pretenure(); | |
| 1887 return false; | |
| 1888 } | |
| 1889 return true; | |
| 1890 } | |
| 1891 | |
| 1892 private: | |
| 1893 CreateClosureParameters* parameters_; | |
| 1894 }; | |
| 1895 | |
| 1896 | |
| 1897 class IsCreateClosureMatcher final : public NodeMatcher { | |
| 1898 public: | |
| 1899 IsCreateClosureMatcher( | |
| 1900 const Matcher<CreateClosureParameters*>& parameters_matcher, | |
| 1901 const Matcher<Node*>& effect_matcher, | |
| 1902 const Matcher<Node*>& control_matcher) | |
| 1903 : NodeMatcher(IrOpcode::Value::kJSCreateClosure), | |
| 1904 parameters_matcher_(parameters_matcher), | |
| 1905 effect_matcher_(effect_matcher), | |
| 1906 control_matcher_(control_matcher) {} | |
| 1907 | |
| 1908 void DescribeTo(std::ostream* os) const final { | |
| 1909 NodeMatcher::DescribeTo(os); | |
| 1910 *os << " whose value ("; | |
| 1911 parameters_matcher_.DescribeTo(os); | |
| 1912 *os << "), effect ("; | |
| 1913 effect_matcher_.DescribeTo(os); | |
| 1914 *os << ") and control ("; | |
| 1915 control_matcher_.DescribeTo(os); | |
| 1916 *os << ")"; | |
| 1917 } | |
| 1918 | |
| 1919 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | |
| 1920 if (!NodeMatcher::MatchAndExplain(node, listener)) { | |
| 1921 return false; | |
| 1922 } | |
| 1923 CreateClosureParameters parameters = | |
| 1924 OpParameter<CreateClosureParameters>(node); | |
| 1925 return (PrintMatchAndExplain(¶meters, "value", parameters_matcher_, | |
|
Michael Starzinger
2015/11/23 11:18:38
Instead of going through extra lengths of making t
oth
2015/11/24 12:29:36
Done.
| |
| 1926 listener) && | |
| 1927 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | |
| 1928 effect_matcher_, listener) && | |
| 1929 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | |
| 1930 "control", control_matcher_, listener)); | |
| 1931 } | |
| 1932 | |
| 1933 private: | |
| 1934 const Matcher<CreateClosureParameters*> parameters_matcher_; | |
| 1935 const Matcher<Node*> effect_matcher_; | |
| 1936 const Matcher<Node*> control_matcher_; | |
| 1937 }; | |
| 1938 | |
| 1861 } // namespace | 1939 } // namespace |
| 1862 | 1940 |
| 1863 | 1941 |
| 1864 Matcher<Node*> IsDead() { | 1942 Matcher<Node*> IsDead() { |
| 1865 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); | 1943 return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); |
| 1866 } | 1944 } |
| 1867 | 1945 |
| 1868 | 1946 |
| 1869 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { | 1947 Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { |
| 1870 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); | 1948 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2528 | 2606 |
| 2529 Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers, | 2607 Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers, |
| 2530 const Matcher<Node*>& effect_matcher, | 2608 const Matcher<Node*>& effect_matcher, |
| 2531 const Matcher<Node*>& control_matcher) { | 2609 const Matcher<Node*>& control_matcher) { |
| 2532 return MakeMatcher(new IsJSCallMatcher(IrOpcode::kJSCallRuntime, | 2610 return MakeMatcher(new IsJSCallMatcher(IrOpcode::kJSCallRuntime, |
| 2533 value_matchers, effect_matcher, | 2611 value_matchers, effect_matcher, |
| 2534 control_matcher)); | 2612 control_matcher)); |
| 2535 } | 2613 } |
| 2536 | 2614 |
| 2537 | 2615 |
| 2616 Matcher<CreateClosureParameters*> IsCreateClosureParameters( | |
| 2617 CreateClosureParameters* parameters) { | |
| 2618 return MakeMatcher(new CreateClosureParametersMatcher(parameters)); | |
| 2619 } | |
| 2620 | |
| 2621 | |
| 2622 Matcher<Node*> IsCreateClosure( | |
| 2623 const Matcher<CreateClosureParameters*>& parameters_matcher, | |
| 2624 const Matcher<Node*>& effect_matcher, | |
| 2625 const Matcher<Node*>& control_matcher) { | |
| 2626 return MakeMatcher(new IsCreateClosureMatcher( | |
| 2627 parameters_matcher, effect_matcher, control_matcher)); | |
| 2628 } | |
| 2629 | |
| 2630 | |
| 2538 #define IS_BINOP_MATCHER(Name) \ | 2631 #define IS_BINOP_MATCHER(Name) \ |
| 2539 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ | 2632 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
| 2540 const Matcher<Node*>& rhs_matcher) { \ | 2633 const Matcher<Node*>& rhs_matcher) { \ |
| 2541 return MakeMatcher( \ | 2634 return MakeMatcher( \ |
| 2542 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ | 2635 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ |
| 2543 } | 2636 } |
| 2544 IS_BINOP_MATCHER(NumberEqual) | 2637 IS_BINOP_MATCHER(NumberEqual) |
| 2545 IS_BINOP_MATCHER(NumberLessThan) | 2638 IS_BINOP_MATCHER(NumberLessThan) |
| 2546 IS_BINOP_MATCHER(NumberSubtract) | 2639 IS_BINOP_MATCHER(NumberSubtract) |
| 2547 IS_BINOP_MATCHER(NumberMultiply) | 2640 IS_BINOP_MATCHER(NumberMultiply) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2613 IS_UNOP_MATCHER(NumberToUint32) | 2706 IS_UNOP_MATCHER(NumberToUint32) |
| 2614 IS_UNOP_MATCHER(ObjectIsSmi) | 2707 IS_UNOP_MATCHER(ObjectIsSmi) |
| 2615 IS_UNOP_MATCHER(Word32Clz) | 2708 IS_UNOP_MATCHER(Word32Clz) |
| 2616 IS_UNOP_MATCHER(JSUnaryNot) | 2709 IS_UNOP_MATCHER(JSUnaryNot) |
| 2617 IS_UNOP_MATCHER(JSTypeOf) | 2710 IS_UNOP_MATCHER(JSTypeOf) |
| 2618 #undef IS_UNOP_MATCHER | 2711 #undef IS_UNOP_MATCHER |
| 2619 | 2712 |
| 2620 } // namespace compiler | 2713 } // namespace compiler |
| 2621 } // namespace internal | 2714 } // namespace internal |
| 2622 } // namespace v8 | 2715 } // namespace v8 |
| OLD | NEW |