| 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 12 matching lines...) Expand all Loading... |
| 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(Operator* op, int value_input_count, |
| 32 Node** value_inputs) { | 32 Node** value_inputs) { |
| 33 DCHECK(op->InputCount() == value_input_count); |
| 34 |
| 33 bool has_context = OperatorProperties::HasContextInput(op); | 35 bool has_context = OperatorProperties::HasContextInput(op); |
| 36 bool has_framestate = OperatorProperties::HasFrameStateInput(op); |
| 34 bool has_control = OperatorProperties::GetControlInputCount(op) == 1; | 37 bool has_control = OperatorProperties::GetControlInputCount(op) == 1; |
| 35 bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1; | 38 bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1; |
| 36 | 39 |
| 37 DCHECK(OperatorProperties::GetControlInputCount(op) < 2); | 40 DCHECK(OperatorProperties::GetControlInputCount(op) < 2); |
| 38 DCHECK(OperatorProperties::GetEffectInputCount(op) < 2); | 41 DCHECK(OperatorProperties::GetEffectInputCount(op) < 2); |
| 39 | 42 |
| 40 Node* result = NULL; | 43 Node* result = NULL; |
| 41 if (!has_context && !has_control && !has_effect) { | 44 if (!has_context && !has_control && !has_effect) { |
| 42 result = graph()->NewNode(op, value_input_count, value_inputs); | 45 result = graph()->NewNode(op, value_input_count, value_inputs); |
| 43 } else { | 46 } else { |
| 44 int input_count_with_deps = value_input_count; | 47 int input_count_with_deps = value_input_count; |
| 45 if (has_context) ++input_count_with_deps; | 48 if (has_context) ++input_count_with_deps; |
| 49 if (has_framestate) ++input_count_with_deps; |
| 46 if (has_control) ++input_count_with_deps; | 50 if (has_control) ++input_count_with_deps; |
| 47 if (has_effect) ++input_count_with_deps; | 51 if (has_effect) ++input_count_with_deps; |
| 48 void* raw_buffer = alloca(kPointerSize * input_count_with_deps); | 52 void* raw_buffer = alloca(kPointerSize * input_count_with_deps); |
| 49 Node** buffer = reinterpret_cast<Node**>(raw_buffer); | 53 Node** buffer = reinterpret_cast<Node**>(raw_buffer); |
| 50 memcpy(buffer, value_inputs, kPointerSize * value_input_count); | 54 memcpy(buffer, value_inputs, kPointerSize * value_input_count); |
| 51 Node** current_input = buffer + value_input_count; | 55 Node** current_input = buffer + value_input_count; |
| 52 if (has_context) { | 56 if (has_context) { |
| 53 *current_input++ = current_context(); | 57 *current_input++ = current_context(); |
| 54 } | 58 } |
| 59 if (has_framestate) { |
| 60 // The frame state will be inserted later. Here we misuse |
| 61 // the dead_control node as a sentinel to be later overwritten |
| 62 // with the real frame state. |
| 63 *current_input++ = dead_control(); |
| 64 } |
| 55 if (has_effect) { | 65 if (has_effect) { |
| 56 *current_input++ = environment_->GetEffectDependency(); | 66 *current_input++ = environment_->GetEffectDependency(); |
| 57 } | 67 } |
| 58 if (has_control) { | 68 if (has_control) { |
| 59 *current_input++ = environment_->GetControlDependency(); | 69 *current_input++ = environment_->GetControlDependency(); |
| 60 } | 70 } |
| 61 result = graph()->NewNode(op, input_count_with_deps, buffer); | 71 result = graph()->NewNode(op, input_count_with_deps, buffer); |
| 62 if (has_effect) { | 72 if (has_effect) { |
| 63 environment_->UpdateEffectDependency(result); | 73 environment_->UpdateEffectDependency(result); |
| 64 } | 74 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (!dead_control_.is_set()) { | 242 if (!dead_control_.is_set()) { |
| 233 Node* dead_node = graph()->NewNode(common_->Dead()); | 243 Node* dead_node = graph()->NewNode(common_->Dead()); |
| 234 dead_control_.set(dead_node); | 244 dead_control_.set(dead_node); |
| 235 return dead_node; | 245 return dead_node; |
| 236 } | 246 } |
| 237 return dead_control_.get(); | 247 return dead_control_.get(); |
| 238 } | 248 } |
| 239 } | 249 } |
| 240 } | 250 } |
| 241 } // namespace v8::internal::compiler | 251 } // namespace v8::internal::compiler |
| OLD | NEW |