OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/common-operator.h" |
| 6 #include "src/compiler/graph.h" |
5 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
6 | |
7 #include "src/compiler/common-operator.h" | |
8 #include "src/compiler/operator-properties.h" | 8 #include "src/compiler/operator-properties.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 // static | 14 // static |
15 int NodeProperties::PastValueIndex(Node* node) { | 15 int NodeProperties::PastValueIndex(Node* node) { |
16 return FirstValueIndex(node) + node->op()->ValueInputCount(); | 16 return FirstValueIndex(node) + node->op()->ValueInputCount(); |
17 } | 17 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 node->ReplaceInput(FirstFrameStateIndex(node) + index, frame_state); | 144 node->ReplaceInput(FirstFrameStateIndex(node) + index, frame_state); |
145 } | 145 } |
146 | 146 |
147 | 147 |
148 // static | 148 // static |
149 void NodeProperties::RemoveNonValueInputs(Node* node) { | 149 void NodeProperties::RemoveNonValueInputs(Node* node) { |
150 node->TrimInputCount(node->op()->ValueInputCount()); | 150 node->TrimInputCount(node->op()->ValueInputCount()); |
151 } | 151 } |
152 | 152 |
153 | 153 |
| 154 void NodeProperties::MergeControlToEnd(Graph* graph, |
| 155 CommonOperatorBuilder* common, |
| 156 Node* node) { |
| 157 // Connect the node to the merge exiting the graph. |
| 158 Node* end_pred = NodeProperties::GetControlInput(graph->end()); |
| 159 if (end_pred->opcode() == IrOpcode::kMerge) { |
| 160 int inputs = end_pred->op()->ControlInputCount() + 1; |
| 161 end_pred->AppendInput(graph->zone(), node); |
| 162 end_pred->set_op(common->Merge(inputs)); |
| 163 } else { |
| 164 Node* merge = graph->NewNode(common->Merge(2), end_pred, node); |
| 165 NodeProperties::ReplaceControlInput(graph->end(), merge); |
| 166 } |
| 167 } |
| 168 |
| 169 |
154 // static | 170 // static |
155 void NodeProperties::ReplaceWithValue(Node* node, Node* value, Node* effect, | 171 void NodeProperties::ReplaceWithValue(Node* node, Node* value, Node* effect, |
156 Node* control) { | 172 Node* control) { |
157 if (!effect && node->op()->EffectInputCount() > 0) { | 173 if (!effect && node->op()->EffectInputCount() > 0) { |
158 effect = NodeProperties::GetEffectInput(node); | 174 effect = NodeProperties::GetEffectInput(node); |
159 } | 175 } |
160 if (control == nullptr && node->op()->ControlInputCount() > 0) { | 176 if (control == nullptr && node->op()->ControlInputCount() > 0) { |
161 control = NodeProperties::GetControlInput(node); | 177 control = NodeProperties::GetControlInput(node); |
162 } | 178 } |
163 | 179 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // static | 270 // static |
255 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { | 271 bool NodeProperties::IsInputRange(Edge edge, int first, int num) { |
256 if (num == 0) return false; | 272 if (num == 0) return false; |
257 int const index = edge.index(); | 273 int const index = edge.index(); |
258 return first <= index && index < first + num; | 274 return first <= index && index < first + num; |
259 } | 275 } |
260 | 276 |
261 } // namespace compiler | 277 } // namespace compiler |
262 } // namespace internal | 278 } // namespace internal |
263 } // namespace v8 | 279 } // namespace v8 |
OLD | NEW |