OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/graph-builder.h" | 5 #include "src/compiler/graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/generic-graph.h" | 8 #include "src/compiler/generic-graph.h" |
9 #include "src/compiler/generic-node.h" | 9 #include "src/compiler/generic-node.h" |
10 #include "src/compiler/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph, | 22 StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph, |
23 CommonOperatorBuilder* common) | 23 CommonOperatorBuilder* common) |
24 : GraphBuilder(graph), | 24 : GraphBuilder(graph), |
25 common_(common), | 25 common_(common), |
26 environment_(NULL), | 26 environment_(NULL), |
27 current_context_(NULL), | 27 current_context_(NULL), |
28 exit_control_(NULL) {} | 28 exit_control_(NULL) {} |
29 | 29 |
30 | 30 |
31 Node* StructuredGraphBuilder::MakeNode(Operator* op, int value_input_count, | 31 Node* StructuredGraphBuilder::MakeNode(const Operator* op, |
| 32 int value_input_count, |
32 Node** value_inputs) { | 33 Node** value_inputs) { |
33 DCHECK(op->InputCount() == value_input_count); | 34 DCHECK(op->InputCount() == value_input_count); |
34 | 35 |
35 bool has_context = OperatorProperties::HasContextInput(op); | 36 bool has_context = OperatorProperties::HasContextInput(op); |
36 bool has_framestate = OperatorProperties::HasFrameStateInput(op); | 37 bool has_framestate = OperatorProperties::HasFrameStateInput(op); |
37 bool has_control = OperatorProperties::GetControlInputCount(op) == 1; | 38 bool has_control = OperatorProperties::GetControlInputCount(op) == 1; |
38 bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1; | 39 bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1; |
39 | 40 |
40 DCHECK(OperatorProperties::GetControlInputCount(op) < 2); | 41 DCHECK(OperatorProperties::GetControlInputCount(op) < 2); |
41 DCHECK(OperatorProperties::GetEffectInputCount(op) < 2); | 42 DCHECK(OperatorProperties::GetEffectInputCount(op) < 2); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 for (int i = 0; i < static_cast<int>(values()->size()); ++i) { | 155 for (int i = 0; i < static_cast<int>(values()->size()); ++i) { |
155 Node* phi = builder_->NewPhi(1, values()->at(i), control); | 156 Node* phi = builder_->NewPhi(1, values()->at(i), control); |
156 values()->at(i) = phi; | 157 values()->at(i) = phi; |
157 } | 158 } |
158 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); | 159 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); |
159 UpdateEffectDependency(effect); | 160 UpdateEffectDependency(effect); |
160 } | 161 } |
161 | 162 |
162 | 163 |
163 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { | 164 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { |
164 Operator* phi_op = common()->Phi(kMachAnyTagged, count); | 165 const Operator* phi_op = common()->Phi(kMachAnyTagged, count); |
165 Node** buffer = zone()->NewArray<Node*>(count + 1); | 166 Node** buffer = zone()->NewArray<Node*>(count + 1); |
166 MemsetPointer(buffer, input, count); | 167 MemsetPointer(buffer, input, count); |
167 buffer[count] = control; | 168 buffer[count] = control; |
168 return graph()->NewNode(phi_op, count + 1, buffer); | 169 return graph()->NewNode(phi_op, count + 1, buffer); |
169 } | 170 } |
170 | 171 |
171 | 172 |
172 // TODO(mstarzinger): Revisit this once we have proper effect states. | 173 // TODO(mstarzinger): Revisit this once we have proper effect states. |
173 Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input, | 174 Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input, |
174 Node* control) { | 175 Node* control) { |
175 Operator* phi_op = common()->EffectPhi(count); | 176 const Operator* phi_op = common()->EffectPhi(count); |
176 Node** buffer = zone()->NewArray<Node*>(count + 1); | 177 Node** buffer = zone()->NewArray<Node*>(count + 1); |
177 MemsetPointer(buffer, input, count); | 178 MemsetPointer(buffer, input, count); |
178 buffer[count] = control; | 179 buffer[count] = control; |
179 return graph()->NewNode(phi_op, count + 1, buffer); | 180 return graph()->NewNode(phi_op, count + 1, buffer); |
180 } | 181 } |
181 | 182 |
182 | 183 |
183 Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) { | 184 Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) { |
184 int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1; | 185 int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1; |
185 if (control->opcode() == IrOpcode::kLoop) { | 186 if (control->opcode() == IrOpcode::kLoop) { |
186 // Control node for loop exists, add input. | 187 // Control node for loop exists, add input. |
187 Operator* op = common()->Loop(inputs); | 188 const Operator* op = common()->Loop(inputs); |
188 control->AppendInput(zone(), other); | 189 control->AppendInput(zone(), other); |
189 control->set_op(op); | 190 control->set_op(op); |
190 } else if (control->opcode() == IrOpcode::kMerge) { | 191 } else if (control->opcode() == IrOpcode::kMerge) { |
191 // Control node for merge exists, add input. | 192 // Control node for merge exists, add input. |
192 Operator* op = common()->Merge(inputs); | 193 const Operator* op = common()->Merge(inputs); |
193 control->AppendInput(zone(), other); | 194 control->AppendInput(zone(), other); |
194 control->set_op(op); | 195 control->set_op(op); |
195 } else { | 196 } else { |
196 // Control node is a singleton, introduce a merge. | 197 // Control node is a singleton, introduce a merge. |
197 Operator* op = common()->Merge(inputs); | 198 const Operator* op = common()->Merge(inputs); |
198 control = graph()->NewNode(op, control, other); | 199 control = graph()->NewNode(op, control, other); |
199 } | 200 } |
200 return control; | 201 return control; |
201 } | 202 } |
202 | 203 |
203 | 204 |
204 Node* StructuredGraphBuilder::MergeEffect(Node* value, Node* other, | 205 Node* StructuredGraphBuilder::MergeEffect(Node* value, Node* other, |
205 Node* control) { | 206 Node* control) { |
206 int inputs = OperatorProperties::GetControlInputCount(control->op()); | 207 int inputs = OperatorProperties::GetControlInputCount(control->op()); |
207 if (value->opcode() == IrOpcode::kEffectPhi && | 208 if (value->opcode() == IrOpcode::kEffectPhi && |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (!dead_control_.is_set()) { | 240 if (!dead_control_.is_set()) { |
240 Node* dead_node = graph()->NewNode(common_->Dead()); | 241 Node* dead_node = graph()->NewNode(common_->Dead()); |
241 dead_control_.set(dead_node); | 242 dead_control_.set(dead_node); |
242 return dead_node; | 243 return dead_node; |
243 } | 244 } |
244 return dead_control_.get(); | 245 return dead_control_.get(); |
245 } | 246 } |
246 } | 247 } |
247 } | 248 } |
248 } // namespace v8::internal::compiler | 249 } // namespace v8::internal::compiler |
OLD | NEW |