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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "graph-tester.h" | 7 #include "graph-tester.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 CHECK_EQ(2, node->InputCount()); | 95 CHECK_EQ(2, node->InputCount()); |
96 node->set_op(&OPC2); | 96 node->set_op(&OPC2); |
97 return Replace(node); | 97 return Replace(node); |
98 } | 98 } |
99 return NoChange(); | 99 return NoChange(); |
100 } | 100 } |
101 }; | 101 }; |
102 | 102 |
103 | 103 |
104 // Wraps all "OPA0" nodes in "OPB1" operators by allocating new nodes. | 104 // Wraps all "OPA0" nodes in "OPB1" operators by allocating new nodes. |
105 class A0Wrapper V8_FINAL : public Reducer { | 105 class A0Wrapper FINAL : public Reducer { |
106 public: | 106 public: |
107 explicit A0Wrapper(Graph* graph) : graph_(graph) {} | 107 explicit A0Wrapper(Graph* graph) : graph_(graph) {} |
108 virtual Reduction Reduce(Node* node) V8_OVERRIDE { | 108 virtual Reduction Reduce(Node* node) OVERRIDE { |
109 switch (node->op()->opcode()) { | 109 switch (node->op()->opcode()) { |
110 case OPCODE_A0: | 110 case OPCODE_A0: |
111 CHECK_EQ(0, node->InputCount()); | 111 CHECK_EQ(0, node->InputCount()); |
112 return Replace(graph_->NewNode(&OPB1, node)); | 112 return Replace(graph_->NewNode(&OPB1, node)); |
113 } | 113 } |
114 return NoChange(); | 114 return NoChange(); |
115 } | 115 } |
116 Graph* graph_; | 116 Graph* graph_; |
117 }; | 117 }; |
118 | 118 |
119 | 119 |
120 // Wraps all "OPB0" nodes in two "OPC1" operators by allocating new nodes. | 120 // Wraps all "OPB0" nodes in two "OPC1" operators by allocating new nodes. |
121 class B0Wrapper V8_FINAL : public Reducer { | 121 class B0Wrapper FINAL : public Reducer { |
122 public: | 122 public: |
123 explicit B0Wrapper(Graph* graph) : graph_(graph) {} | 123 explicit B0Wrapper(Graph* graph) : graph_(graph) {} |
124 virtual Reduction Reduce(Node* node) V8_OVERRIDE { | 124 virtual Reduction Reduce(Node* node) OVERRIDE { |
125 switch (node->op()->opcode()) { | 125 switch (node->op()->opcode()) { |
126 case OPCODE_B0: | 126 case OPCODE_B0: |
127 CHECK_EQ(0, node->InputCount()); | 127 CHECK_EQ(0, node->InputCount()); |
128 return Replace(graph_->NewNode(&OPC1, graph_->NewNode(&OPC1, node))); | 128 return Replace(graph_->NewNode(&OPC1, graph_->NewNode(&OPC1, node))); |
129 } | 129 } |
130 return NoChange(); | 130 return NoChange(); |
131 } | 131 } |
132 Graph* graph_; | 132 Graph* graph_; |
133 }; | 133 }; |
134 | 134 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 reducer.AddReducer(&once); | 652 reducer.AddReducer(&once); |
653 | 653 |
654 // Tests A* => B* with in-place updates. Should only be applied once. | 654 // Tests A* => B* with in-place updates. Should only be applied once. |
655 int before = graph.NodeCount(); | 655 int before = graph.NodeCount(); |
656 reducer.ReduceGraph(); | 656 reducer.ReduceGraph(); |
657 CHECK_EQ(before, graph.NodeCount()); | 657 CHECK_EQ(before, graph.NodeCount()); |
658 CHECK_EQ(&OPB0, n1->op()); | 658 CHECK_EQ(&OPB0, n1->op()); |
659 CHECK_EQ(&OPB1, end->op()); | 659 CHECK_EQ(&OPB1, end->op()); |
660 CHECK_EQ(n1, end->InputAt(0)); | 660 CHECK_EQ(n1, end->InputAt(0)); |
661 } | 661 } |
OLD | NEW |