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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 Node* result = NULL; | 43 Node* result = NULL; |
44 if (!has_context && !has_control && !has_effect) { | 44 if (!has_context && !has_control && !has_effect) { |
45 result = graph()->NewNode(op, value_input_count, value_inputs); | 45 result = graph()->NewNode(op, value_input_count, value_inputs); |
46 } else { | 46 } else { |
47 int input_count_with_deps = value_input_count; | 47 int input_count_with_deps = value_input_count; |
48 if (has_context) ++input_count_with_deps; | 48 if (has_context) ++input_count_with_deps; |
49 if (has_framestate) ++input_count_with_deps; | 49 if (has_framestate) ++input_count_with_deps; |
50 if (has_control) ++input_count_with_deps; | 50 if (has_control) ++input_count_with_deps; |
51 if (has_effect) ++input_count_with_deps; | 51 if (has_effect) ++input_count_with_deps; |
52 void* raw_buffer = alloca(kPointerSize * input_count_with_deps); | 52 Node** buffer = zone()->NewArray<Node*>(input_count_with_deps); |
53 Node** buffer = reinterpret_cast<Node**>(raw_buffer); | |
54 memcpy(buffer, value_inputs, kPointerSize * value_input_count); | 53 memcpy(buffer, value_inputs, kPointerSize * value_input_count); |
55 Node** current_input = buffer + value_input_count; | 54 Node** current_input = buffer + value_input_count; |
56 if (has_context) { | 55 if (has_context) { |
57 *current_input++ = current_context(); | 56 *current_input++ = current_context(); |
58 } | 57 } |
59 if (has_framestate) { | 58 if (has_framestate) { |
60 // The frame state will be inserted later. Here we misuse | 59 // The frame state will be inserted later. Here we misuse |
61 // the dead_control node as a sentinel to be later overwritten | 60 // the dead_control node as a sentinel to be later overwritten |
62 // with the real frame state. | 61 // with the real frame state. |
63 *current_input++ = dead_control(); | 62 *current_input++ = dead_control(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 Node* phi = builder_->NewPhi(1, values()->at(i), control); | 155 Node* phi = builder_->NewPhi(1, values()->at(i), control); |
157 values()->at(i) = phi; | 156 values()->at(i) = phi; |
158 } | 157 } |
159 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); | 158 Node* effect = builder_->NewEffectPhi(1, GetEffectDependency(), control); |
160 UpdateEffectDependency(effect); | 159 UpdateEffectDependency(effect); |
161 } | 160 } |
162 | 161 |
163 | 162 |
164 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { | 163 Node* StructuredGraphBuilder::NewPhi(int count, Node* input, Node* control) { |
165 Operator* phi_op = common()->Phi(count); | 164 Operator* phi_op = common()->Phi(count); |
166 void* raw_buffer = alloca(kPointerSize * (count + 1)); | 165 Node** buffer = zone()->NewArray<Node*>(count + 1); |
167 Node** buffer = reinterpret_cast<Node**>(raw_buffer); | |
168 MemsetPointer(buffer, input, count); | 166 MemsetPointer(buffer, input, count); |
169 buffer[count] = control; | 167 buffer[count] = control; |
170 return graph()->NewNode(phi_op, count + 1, buffer); | 168 return graph()->NewNode(phi_op, count + 1, buffer); |
171 } | 169 } |
172 | 170 |
173 | 171 |
174 // TODO(mstarzinger): Revisit this once we have proper effect states. | 172 // TODO(mstarzinger): Revisit this once we have proper effect states. |
175 Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input, | 173 Node* StructuredGraphBuilder::NewEffectPhi(int count, Node* input, |
176 Node* control) { | 174 Node* control) { |
177 Operator* phi_op = common()->EffectPhi(count); | 175 Operator* phi_op = common()->EffectPhi(count); |
178 void* raw_buffer = alloca(kPointerSize * (count + 1)); | 176 Node** buffer = zone()->NewArray<Node*>(count + 1); |
179 Node** buffer = reinterpret_cast<Node**>(raw_buffer); | |
180 MemsetPointer(buffer, input, count); | 177 MemsetPointer(buffer, input, count); |
181 buffer[count] = control; | 178 buffer[count] = control; |
182 return graph()->NewNode(phi_op, count + 1, buffer); | 179 return graph()->NewNode(phi_op, count + 1, buffer); |
183 } | 180 } |
184 | 181 |
185 | 182 |
186 Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) { | 183 Node* StructuredGraphBuilder::MergeControl(Node* control, Node* other) { |
187 int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1; | 184 int inputs = OperatorProperties::GetControlInputCount(control->op()) + 1; |
188 if (control->opcode() == IrOpcode::kLoop) { | 185 if (control->opcode() == IrOpcode::kLoop) { |
189 // Control node for loop exists, add input. | 186 // Control node for loop exists, add input. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 if (!dead_control_.is_set()) { | 239 if (!dead_control_.is_set()) { |
243 Node* dead_node = graph()->NewNode(common_->Dead()); | 240 Node* dead_node = graph()->NewNode(common_->Dead()); |
244 dead_control_.set(dead_node); | 241 dead_control_.set(dead_node); |
245 return dead_node; | 242 return dead_node; |
246 } | 243 } |
247 return dead_control_.get(); | 244 return dead_control_.get(); |
248 } | 245 } |
249 } | 246 } |
250 } | 247 } |
251 } // namespace v8::internal::compiler | 248 } // namespace v8::internal::compiler |
OLD | NEW |