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 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 *os << "), effect ("; | 1453 *os << "), effect ("; |
1454 effect_matcher_.DescribeTo(os); | 1454 effect_matcher_.DescribeTo(os); |
1455 *os << "), and control ("; | 1455 *os << "), and control ("; |
1456 control_matcher_.DescribeTo(os); | 1456 control_matcher_.DescribeTo(os); |
1457 *os << ")"; | 1457 *os << ")"; |
1458 } | 1458 } |
1459 | 1459 |
1460 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { | 1460 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
1461 return (NodeMatcher::MatchAndExplain(node, listener) && | 1461 return (NodeMatcher::MatchAndExplain(node, listener) && |
1462 PrintMatchAndExplain(OpParameter<const NamedAccess>(node).name(), | 1462 PrintMatchAndExplain(OpParameter<const NamedAccess>(node).name(), |
1463 "descriptor", name_matcher_, listener) && | 1463 "name", name_matcher_, listener) && |
1464 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), | 1464 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
1465 "object", object_value_matcher_, listener) && | 1465 "object", object_value_matcher_, listener) && |
1466 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), | 1466 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
1467 "feedback vector", feedback_vector_matcher_, | 1467 "feedback vector", feedback_vector_matcher_, |
1468 listener) && | 1468 listener) && |
1469 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", | 1469 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
1470 effect_matcher_, listener) && | 1470 effect_matcher_, listener) && |
1471 PrintMatchAndExplain(NodeProperties::GetControlInput(node), | 1471 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
1472 "control", control_matcher_, listener)); | 1472 "control", control_matcher_, listener)); |
1473 } | 1473 } |
1474 | 1474 |
1475 private: | 1475 private: |
1476 const Matcher<Handle<Name>> name_matcher_; | 1476 const Matcher<Handle<Name>> name_matcher_; |
1477 const Matcher<Node*> object_value_matcher_; | 1477 const Matcher<Node*> object_value_matcher_; |
1478 const Matcher<Node*> feedback_vector_matcher_; | 1478 const Matcher<Node*> feedback_vector_matcher_; |
1479 const Matcher<Node*> effect_matcher_; | 1479 const Matcher<Node*> effect_matcher_; |
1480 const Matcher<Node*> control_matcher_; | 1480 const Matcher<Node*> control_matcher_; |
1481 }; | 1481 }; |
1482 | 1482 |
1483 | 1483 |
| 1484 class IsJSLoadGlobalMatcher final : public NodeMatcher { |
| 1485 public: |
| 1486 IsJSLoadGlobalMatcher(const Matcher<Handle<Name>>& name_matcher, |
| 1487 const Matcher<Node*>& feedback_vector_matcher, |
| 1488 const Matcher<Node*>& effect_matcher, |
| 1489 const Matcher<Node*>& control_matcher) |
| 1490 : NodeMatcher(IrOpcode::kJSLoadGlobal), |
| 1491 name_matcher_(name_matcher), |
| 1492 feedback_vector_matcher_(feedback_vector_matcher), |
| 1493 effect_matcher_(effect_matcher), |
| 1494 control_matcher_(control_matcher) {} |
| 1495 |
| 1496 void DescribeTo(std::ostream* os) const final { |
| 1497 NodeMatcher::DescribeTo(os); |
| 1498 *os << " whose name ("; |
| 1499 name_matcher_.DescribeTo(os); |
| 1500 *os << "), feedback vector ("; |
| 1501 feedback_vector_matcher_.DescribeTo(os); |
| 1502 *os << "), effect ("; |
| 1503 effect_matcher_.DescribeTo(os); |
| 1504 *os << "), and control ("; |
| 1505 control_matcher_.DescribeTo(os); |
| 1506 *os << ")"; |
| 1507 } |
| 1508 |
| 1509 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1510 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1511 PrintMatchAndExplain( |
| 1512 OpParameter<const LoadGlobalParameters>(node).name(), "name", |
| 1513 name_matcher_, listener) && |
| 1514 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 1515 "feedback vector", feedback_vector_matcher_, |
| 1516 listener) && |
| 1517 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 1518 effect_matcher_, listener) && |
| 1519 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 1520 "control", control_matcher_, listener)); |
| 1521 } |
| 1522 |
| 1523 private: |
| 1524 const Matcher<Handle<Name>> name_matcher_; |
| 1525 const Matcher<Node*> feedback_vector_matcher_; |
| 1526 const Matcher<Node*> effect_matcher_; |
| 1527 const Matcher<Node*> control_matcher_; |
| 1528 }; |
| 1529 |
| 1530 |
| 1531 class IsJSStoreGlobalMatcher final : public NodeMatcher { |
| 1532 public: |
| 1533 IsJSStoreGlobalMatcher(const Matcher<Handle<Name>>& name_matcher, |
| 1534 const Matcher<Node*>& value_matcher, |
| 1535 const Matcher<Node*>& feedback_vector_matcher, |
| 1536 const Matcher<Node*>& effect_matcher, |
| 1537 const Matcher<Node*>& control_matcher) |
| 1538 : NodeMatcher(IrOpcode::kJSStoreGlobal), |
| 1539 name_matcher_(name_matcher), |
| 1540 value_matcher_(value_matcher), |
| 1541 feedback_vector_matcher_(feedback_vector_matcher), |
| 1542 effect_matcher_(effect_matcher), |
| 1543 control_matcher_(control_matcher) {} |
| 1544 |
| 1545 void DescribeTo(std::ostream* os) const final { |
| 1546 NodeMatcher::DescribeTo(os); |
| 1547 *os << " whose name ("; |
| 1548 name_matcher_.DescribeTo(os); |
| 1549 *os << "), value ("; |
| 1550 value_matcher_.DescribeTo(os); |
| 1551 *os << "), feedback vector ("; |
| 1552 feedback_vector_matcher_.DescribeTo(os); |
| 1553 *os << "), effect ("; |
| 1554 effect_matcher_.DescribeTo(os); |
| 1555 *os << "), and control ("; |
| 1556 control_matcher_.DescribeTo(os); |
| 1557 *os << ")"; |
| 1558 } |
| 1559 |
| 1560 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1561 return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1562 PrintMatchAndExplain( |
| 1563 OpParameter<const StoreGlobalParameters>(node).name(), "name", |
| 1564 name_matcher_, listener) && |
| 1565 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 1566 "value", value_matcher_, listener) && |
| 1567 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 1568 "feedback vector", feedback_vector_matcher_, |
| 1569 listener) && |
| 1570 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 1571 effect_matcher_, listener) && |
| 1572 PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 1573 "control", control_matcher_, listener)); |
| 1574 } |
| 1575 |
| 1576 private: |
| 1577 const Matcher<Handle<Name>> name_matcher_; |
| 1578 const Matcher<Node*> value_matcher_; |
| 1579 const Matcher<Node*> feedback_vector_matcher_; |
| 1580 const Matcher<Node*> effect_matcher_; |
| 1581 const Matcher<Node*> control_matcher_; |
| 1582 }; |
| 1583 |
| 1584 |
1484 class IsJSCallFunctionMatcher final : public NodeMatcher { | 1585 class IsJSCallFunctionMatcher final : public NodeMatcher { |
1485 public: | 1586 public: |
1486 IsJSCallFunctionMatcher(const std::vector<Matcher<Node*>>& value_matchers, | 1587 IsJSCallFunctionMatcher(const std::vector<Matcher<Node*>>& value_matchers, |
1487 const Matcher<Node*>& effect_matcher, | 1588 const Matcher<Node*>& effect_matcher, |
1488 const Matcher<Node*>& control_matcher) | 1589 const Matcher<Node*>& control_matcher) |
1489 : NodeMatcher(IrOpcode::kJSCallFunction), | 1590 : NodeMatcher(IrOpcode::kJSCallFunction), |
1490 value_matchers_(value_matchers), | 1591 value_matchers_(value_matchers), |
1491 effect_matcher_(effect_matcher), | 1592 effect_matcher_(effect_matcher), |
1492 control_matcher_(control_matcher) {} | 1593 control_matcher_(control_matcher) {} |
1493 | 1594 |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2110 const Matcher<Node*>& object_value_matcher, | 2211 const Matcher<Node*>& object_value_matcher, |
2111 const Matcher<Node*>& feedback_vector_matcher, | 2212 const Matcher<Node*>& feedback_vector_matcher, |
2112 const Matcher<Node*>& effect_matcher, | 2213 const Matcher<Node*>& effect_matcher, |
2113 const Matcher<Node*>& control_matcher) { | 2214 const Matcher<Node*>& control_matcher) { |
2114 return MakeMatcher(new IsJSLoadNamedMatcher(name, object_value_matcher, | 2215 return MakeMatcher(new IsJSLoadNamedMatcher(name, object_value_matcher, |
2115 feedback_vector_matcher, | 2216 feedback_vector_matcher, |
2116 effect_matcher, control_matcher)); | 2217 effect_matcher, control_matcher)); |
2117 } | 2218 } |
2118 | 2219 |
2119 | 2220 |
| 2221 Matcher<Node*> IsJSLoadGlobal(const Handle<Name> name, |
| 2222 const Matcher<Node*>& feedback_vector_matcher, |
| 2223 const Matcher<Node*>& effect_matcher, |
| 2224 const Matcher<Node*>& control_matcher) { |
| 2225 return MakeMatcher(new IsJSLoadGlobalMatcher( |
| 2226 name, feedback_vector_matcher, effect_matcher, control_matcher)); |
| 2227 } |
| 2228 |
| 2229 |
| 2230 Matcher<Node*> IsJSStoreGlobal(const Handle<Name> name, |
| 2231 const Matcher<Node*>& value_matcher, |
| 2232 const Matcher<Node*>& feedback_vector_matcher, |
| 2233 const Matcher<Node*>& effect_matcher, |
| 2234 const Matcher<Node*>& control_matcher) { |
| 2235 return MakeMatcher( |
| 2236 new IsJSStoreGlobalMatcher(name, value_matcher, feedback_vector_matcher, |
| 2237 effect_matcher, control_matcher)); |
| 2238 } |
| 2239 |
| 2240 |
2120 Matcher<Node*> IsJSCallFunction(std::vector<Matcher<Node*>> value_matchers, | 2241 Matcher<Node*> IsJSCallFunction(std::vector<Matcher<Node*>> value_matchers, |
2121 const Matcher<Node*>& effect_matcher, | 2242 const Matcher<Node*>& effect_matcher, |
2122 const Matcher<Node*>& control_matcher) { | 2243 const Matcher<Node*>& control_matcher) { |
2123 return MakeMatcher(new IsJSCallFunctionMatcher(value_matchers, effect_matcher, | 2244 return MakeMatcher(new IsJSCallFunctionMatcher(value_matchers, effect_matcher, |
2124 control_matcher)); | 2245 control_matcher)); |
2125 } | 2246 } |
2126 | 2247 |
2127 | 2248 |
2128 #define IS_BINOP_MATCHER(Name) \ | 2249 #define IS_BINOP_MATCHER(Name) \ |
2129 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ | 2250 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 IS_UNOP_MATCHER(Float64ExtractHighWord32) | 2322 IS_UNOP_MATCHER(Float64ExtractHighWord32) |
2202 IS_UNOP_MATCHER(NumberToInt32) | 2323 IS_UNOP_MATCHER(NumberToInt32) |
2203 IS_UNOP_MATCHER(NumberToUint32) | 2324 IS_UNOP_MATCHER(NumberToUint32) |
2204 IS_UNOP_MATCHER(ObjectIsSmi) | 2325 IS_UNOP_MATCHER(ObjectIsSmi) |
2205 IS_UNOP_MATCHER(Word32Clz) | 2326 IS_UNOP_MATCHER(Word32Clz) |
2206 #undef IS_UNOP_MATCHER | 2327 #undef IS_UNOP_MATCHER |
2207 | 2328 |
2208 } // namespace compiler | 2329 } // namespace compiler |
2209 } // namespace internal | 2330 } // namespace internal |
2210 } // namespace v8 | 2331 } // namespace v8 |
OLD | NEW |