Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/compiler/graph-builder.cc

Issue 686213002: Inline trivial OperatorProperties methods. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | src/compiler/graph-replay.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 44
45 Node* StructuredGraphBuilder::MakeNode(const Operator* op, 45 Node* StructuredGraphBuilder::MakeNode(const Operator* op,
46 int value_input_count, 46 int value_input_count,
47 Node** value_inputs, bool incomplete) { 47 Node** value_inputs, bool incomplete) {
48 DCHECK(op->InputCount() == value_input_count); 48 DCHECK(op->InputCount() == value_input_count);
49 49
50 bool has_context = OperatorProperties::HasContextInput(op); 50 bool has_context = OperatorProperties::HasContextInput(op);
51 bool has_framestate = OperatorProperties::HasFrameStateInput(op); 51 bool has_framestate = OperatorProperties::HasFrameStateInput(op);
52 bool has_control = OperatorProperties::GetControlInputCount(op) == 1; 52 bool has_control = op->ControlInputCount() == 1;
53 bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1; 53 bool has_effect = op->EffectInputCount() == 1;
54 54
55 DCHECK(OperatorProperties::GetControlInputCount(op) < 2); 55 DCHECK(op->ControlInputCount() < 2);
56 DCHECK(OperatorProperties::GetEffectInputCount(op) < 2); 56 DCHECK(op->EffectInputCount() < 2);
57 57
58 Node* result = NULL; 58 Node* result = NULL;
59 if (!has_context && !has_framestate && !has_control && !has_effect) { 59 if (!has_context && !has_framestate && !has_control && !has_effect) {
60 result = graph()->NewNode(op, value_input_count, value_inputs, incomplete); 60 result = graph()->NewNode(op, value_input_count, value_inputs, incomplete);
61 } else { 61 } else {
62 int input_count_with_deps = value_input_count; 62 int input_count_with_deps = value_input_count;
63 if (has_context) ++input_count_with_deps; 63 if (has_context) ++input_count_with_deps;
64 if (has_framestate) ++input_count_with_deps; 64 if (has_framestate) ++input_count_with_deps;
65 if (has_control) ++input_count_with_deps; 65 if (has_control) ++input_count_with_deps;
66 if (has_effect) ++input_count_with_deps; 66 if (has_effect) ++input_count_with_deps;
(...skipping 12 matching lines...) Expand all
79 if (has_effect) { 79 if (has_effect) {
80 *current_input++ = environment_->GetEffectDependency(); 80 *current_input++ = environment_->GetEffectDependency();
81 } 81 }
82 if (has_control) { 82 if (has_control) {
83 *current_input++ = environment_->GetControlDependency(); 83 *current_input++ = environment_->GetControlDependency();
84 } 84 }
85 result = graph()->NewNode(op, input_count_with_deps, buffer, incomplete); 85 result = graph()->NewNode(op, input_count_with_deps, buffer, incomplete);
86 if (has_effect) { 86 if (has_effect) {
87 environment_->UpdateEffectDependency(result); 87 environment_->UpdateEffectDependency(result);
88 } 88 }
89 if (OperatorProperties::HasControlOutput(result->op()) && 89 if (result->op()->ControlOutputCount() > 0 &&
90 !environment()->IsMarkedAsUnreachable()) { 90 !environment()->IsMarkedAsUnreachable()) {
91 environment_->UpdateControlDependency(result); 91 environment_->UpdateControlDependency(result);
92 } 92 }
93 } 93 }
94 94
95 return result; 95 return result;
96 } 96 }
97 97
98 98
99 void StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction( 99 void StructuredGraphBuilder::UpdateControlDependencyToLeaveFunction(
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 Node* control) { 202 Node* control) {
203 const Operator* phi_op = common()->EffectPhi(count); 203 const Operator* phi_op = common()->EffectPhi(count);
204 Node** buffer = EnsureInputBufferSize(count + 1); 204 Node** buffer = EnsureInputBufferSize(count + 1);
205 MemsetPointer(buffer, input, count); 205 MemsetPointer(buffer, input, count);
206 buffer[count] = control; 206 buffer[count] = control;
207 return graph()->NewNode(phi_op, count + 1, buffer, true); 207 return graph()->NewNode(phi_op, count + 1, buffer, true);
208 } 208 }
209 209
210 210
211 Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) { 211 Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) {
212 int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1; 212 int inputs = control->op()->ControlInputCount() + 1;
213 if (control->opcode() == IrOpcode::kLoop) { 213 if (control->opcode() == IrOpcode::kLoop) {
214 // Control node for loop exists, add input. 214 // Control node for loop exists, add input.
215 const Operator* op = common()->Loop(inputs); 215 const Operator* op = common()->Loop(inputs);
216 control->AppendInput(graph_zone(), other); 216 control->AppendInput(graph_zone(), other);
217 control->set_op(op); 217 control->set_op(op);
218 } else if (control->opcode() == IrOpcode::kMerge) { 218 } else if (control->opcode() == IrOpcode::kMerge) {
219 // Control node for merge exists, add input. 219 // Control node for merge exists, add input.
220 const Operator* op = common()->Merge(inputs); 220 const Operator* op = common()->Merge(inputs);
221 control->AppendInput(graph_zone(), other); 221 control->AppendInput(graph_zone(), other);
222 control->set_op(op); 222 control->set_op(op);
223 } else { 223 } else {
224 // Control node is a singleton, introduce a merge. 224 // Control node is a singleton, introduce a merge.
225 const Operator* op = common()->Merge(inputs); 225 const Operator* op = common()->Merge(inputs);
226 Node* inputs[] = {control, other}; 226 Node* inputs[] = {control, other};
227 control = graph()->NewNode(op, arraysize(inputs), inputs, true); 227 control = graph()->NewNode(op, arraysize(inputs), inputs, true);
228 } 228 }
229 return control; 229 return control;
230 } 230 }
231 231
232 232
233 Node* StructuredGraphBuilder::MergeEffect(Node* value, Node* other, 233 Node* StructuredGraphBuilder::MergeEffect(Node* value, Node* other,
234 Node* control) { 234 Node* control) {
235 int inputs = OperatorProperties::GetControlInputCount(control->op()); 235 int inputs = control->op()->ControlInputCount();
236 if (value->opcode() == IrOpcode::kEffectPhi && 236 if (value->opcode() == IrOpcode::kEffectPhi &&
237 NodeProperties::GetControlInput(value) == control) { 237 NodeProperties::GetControlInput(value) == control) {
238 // Phi already exists, add input. 238 // Phi already exists, add input.
239 value->set_op(common()->EffectPhi(inputs)); 239 value->set_op(common()->EffectPhi(inputs));
240 value->InsertInput(graph_zone(), inputs - 1, other); 240 value->InsertInput(graph_zone(), inputs - 1, other);
241 } else if (value != other) { 241 } else if (value != other) {
242 // Phi does not exist yet, introduce one. 242 // Phi does not exist yet, introduce one.
243 value = NewEffectPhi(inputs, value, control); 243 value = NewEffectPhi(inputs, value, control);
244 value->ReplaceInput(inputs - 1, other); 244 value->ReplaceInput(inputs - 1, other);
245 } 245 }
246 return value; 246 return value;
247 } 247 }
248 248
249 249
250 Node* StructuredGraphBuilder::MergeValue(Node* value, Node* other, 250 Node* StructuredGraphBuilder::MergeValue(Node* value, Node* other,
251 Node* control) { 251 Node* control) {
252 int inputs = OperatorProperties::GetControlInputCount(control->op()); 252 int inputs = control->op()->ControlInputCount();
253 if (value->opcode() == IrOpcode::kPhi && 253 if (value->opcode() == IrOpcode::kPhi &&
254 NodeProperties::GetControlInput(value) == control) { 254 NodeProperties::GetControlInput(value) == control) {
255 // Phi already exists, add input. 255 // Phi already exists, add input.
256 value->set_op(common()->Phi(kMachAnyTagged, inputs)); 256 value->set_op(common()->Phi(kMachAnyTagged, inputs));
257 value->InsertInput(graph_zone(), inputs - 1, other); 257 value->InsertInput(graph_zone(), inputs - 1, other);
258 } else if (value != other) { 258 } else if (value != other) {
259 // Phi does not exist yet, introduce one. 259 // Phi does not exist yet, introduce one.
260 value = NewPhi(inputs, value, control); 260 value = NewPhi(inputs, value, control);
261 value->ReplaceInput(inputs - 1, other); 261 value->ReplaceInput(inputs - 1, other);
262 } 262 }
263 return value; 263 return value;
264 } 264 }
265 265
266 266
267 Node* StructuredGraphBuilder::dead_control() { 267 Node* StructuredGraphBuilder::dead_control() {
268 if (!dead_control_.is_set()) { 268 if (!dead_control_.is_set()) {
269 Node* dead_node = graph()->NewNode(common_->Dead()); 269 Node* dead_node = graph()->NewNode(common_->Dead());
270 dead_control_.set(dead_node); 270 dead_control_.set(dead_node);
271 return dead_node; 271 return dead_node;
272 } 272 }
273 return dead_control_.get(); 273 return dead_control_.get();
274 } 274 }
275 } 275 }
276 } 276 }
277 } // namespace v8::internal::compiler 277 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/control-reducer.cc ('k') | src/compiler/graph-replay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698