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

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

Issue 1366753003: [turbofan] Make Node::set_op safer via wrapper. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 2 months 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
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.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 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/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 4201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 return graph()->NewNode(phi_op, count + 1, buffer, true); 4212 return graph()->NewNode(phi_op, count + 1, buffer, true);
4213 } 4213 }
4214 4214
4215 4215
4216 Node* AstGraphBuilder::MergeControl(Node* control, Node* other) { 4216 Node* AstGraphBuilder::MergeControl(Node* control, Node* other) {
4217 int inputs = control->op()->ControlInputCount() + 1; 4217 int inputs = control->op()->ControlInputCount() + 1;
4218 if (control->opcode() == IrOpcode::kLoop) { 4218 if (control->opcode() == IrOpcode::kLoop) {
4219 // Control node for loop exists, add input. 4219 // Control node for loop exists, add input.
4220 const Operator* op = common()->Loop(inputs); 4220 const Operator* op = common()->Loop(inputs);
4221 control->AppendInput(graph_zone(), other); 4221 control->AppendInput(graph_zone(), other);
4222 control->set_op(op); 4222 NodeProperties::ChangeOp(control, op);
4223 } else if (control->opcode() == IrOpcode::kMerge) { 4223 } else if (control->opcode() == IrOpcode::kMerge) {
4224 // Control node for merge exists, add input. 4224 // Control node for merge exists, add input.
4225 const Operator* op = common()->Merge(inputs); 4225 const Operator* op = common()->Merge(inputs);
4226 control->AppendInput(graph_zone(), other); 4226 control->AppendInput(graph_zone(), other);
4227 control->set_op(op); 4227 NodeProperties::ChangeOp(control, op);
4228 } else { 4228 } else {
4229 // Control node is a singleton, introduce a merge. 4229 // Control node is a singleton, introduce a merge.
4230 const Operator* op = common()->Merge(inputs); 4230 const Operator* op = common()->Merge(inputs);
4231 Node* inputs[] = {control, other}; 4231 Node* inputs[] = {control, other};
4232 control = graph()->NewNode(op, arraysize(inputs), inputs, true); 4232 control = graph()->NewNode(op, arraysize(inputs), inputs, true);
4233 } 4233 }
4234 return control; 4234 return control;
4235 } 4235 }
4236 4236
4237 4237
4238 Node* AstGraphBuilder::MergeEffect(Node* value, Node* other, Node* control) { 4238 Node* AstGraphBuilder::MergeEffect(Node* value, Node* other, Node* control) {
4239 int inputs = control->op()->ControlInputCount(); 4239 int inputs = control->op()->ControlInputCount();
4240 if (value->opcode() == IrOpcode::kEffectPhi && 4240 if (value->opcode() == IrOpcode::kEffectPhi &&
4241 NodeProperties::GetControlInput(value) == control) { 4241 NodeProperties::GetControlInput(value) == control) {
4242 // Phi already exists, add input. 4242 // Phi already exists, add input.
4243 value->set_op(common()->EffectPhi(inputs));
4244 value->InsertInput(graph_zone(), inputs - 1, other); 4243 value->InsertInput(graph_zone(), inputs - 1, other);
4244 NodeProperties::ChangeOp(value, common()->EffectPhi(inputs));
4245 } else if (value != other) { 4245 } else if (value != other) {
4246 // Phi does not exist yet, introduce one. 4246 // Phi does not exist yet, introduce one.
4247 value = NewEffectPhi(inputs, value, control); 4247 value = NewEffectPhi(inputs, value, control);
4248 value->ReplaceInput(inputs - 1, other); 4248 value->ReplaceInput(inputs - 1, other);
4249 } 4249 }
4250 return value; 4250 return value;
4251 } 4251 }
4252 4252
4253 4253
4254 Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) { 4254 Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) {
4255 int inputs = control->op()->ControlInputCount(); 4255 int inputs = control->op()->ControlInputCount();
4256 if (value->opcode() == IrOpcode::kPhi && 4256 if (value->opcode() == IrOpcode::kPhi &&
4257 NodeProperties::GetControlInput(value) == control) { 4257 NodeProperties::GetControlInput(value) == control) {
4258 // Phi already exists, add input. 4258 // Phi already exists, add input.
4259 value->set_op(common()->Phi(kMachAnyTagged, inputs));
4260 value->InsertInput(graph_zone(), inputs - 1, other); 4259 value->InsertInput(graph_zone(), inputs - 1, other);
4260 NodeProperties::ChangeOp(value, common()->Phi(kMachAnyTagged, inputs));
4261 } else if (value != other) { 4261 } else if (value != other) {
4262 // Phi does not exist yet, introduce one. 4262 // Phi does not exist yet, introduce one.
4263 value = NewPhi(inputs, value, control); 4263 value = NewPhi(inputs, value, control);
4264 value->ReplaceInput(inputs - 1, other); 4264 value->ReplaceInput(inputs - 1, other);
4265 } 4265 }
4266 return value; 4266 return value;
4267 } 4267 }
4268 4268
4269 } // namespace compiler 4269 } // namespace compiler
4270 } // namespace internal 4270 } // namespace internal
4271 } // namespace v8 4271 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698