OLD | NEW |
---|---|
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/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
9 #include "src/compiler/all-nodes.h" | 9 #include "src/compiler/all-nodes.h" |
10 #include "src/compiler/ast-graph-builder.h" | 10 #include "src/compiler/ast-graph-builder.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 edge.UpdateTo(effect); | 158 edge.UpdateTo(effect); |
159 } else if (NodeProperties::IsControlEdge(edge)) { | 159 } else if (NodeProperties::IsControlEdge(edge)) { |
160 edge.UpdateTo(control); | 160 edge.UpdateTo(control); |
161 } else { | 161 } else { |
162 UNREACHABLE(); | 162 UNREACHABLE(); |
163 } | 163 } |
164 break; | 164 break; |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 // TODO(turbofan): This can be unified once End takes a variable number of | 168 NodeVector values(local_zone_); |
169 // inputs. | 169 NodeVector effects(local_zone_); |
170 Node* value_output; | 170 NodeVector controls(local_zone_); |
171 Node* effect_output; | 171 for (Node* const input : end->inputs()) { |
172 Node* control_output; | 172 switch (input->opcode()) { |
173 | 173 case IrOpcode::kReturn: |
174 Node* final_merge = NodeProperties::GetControlInput(end); | 174 values.push_back(NodeProperties::GetValueInput(input, 0)); |
175 if (final_merge->opcode() == IrOpcode::kReturn) { | 175 effects.push_back(NodeProperties::GetEffectInput(input)); |
176 value_output = NodeProperties::GetValueInput(final_merge, 0); | 176 controls.push_back(NodeProperties::GetControlInput(input)); |
177 effect_output = NodeProperties::GetEffectInput(final_merge, 0); | 177 break; |
178 control_output = NodeProperties::GetControlInput(final_merge, 0); | 178 default: |
179 } else { | 179 // TODO(turbofan): Handle Throw, Terminate and Deoptimize here. |
180 NodeVector values(local_zone_); | 180 UNREACHABLE(); |
181 NodeVector effects(local_zone_); | 181 break; |
182 NodeVector controls(local_zone_); | |
183 DCHECK_EQ(IrOpcode::kMerge, final_merge->opcode()); | |
184 for (Node* const input : final_merge->inputs()) { | |
185 switch (input->opcode()) { | |
186 case IrOpcode::kReturn: | |
187 values.push_back(NodeProperties::GetValueInput(input, 0)); | |
188 effects.push_back(NodeProperties::GetEffectInput(input)); | |
189 controls.push_back(NodeProperties::GetControlInput(input)); | |
190 break; | |
191 default: | |
192 // TODO(turbofan): Handle Throw, Terminate and Deoptimize here. | |
193 UNREACHABLE(); | |
194 break; | |
195 } | |
196 } | 182 } |
197 DCHECK_NE(0u, values.size()); | |
198 DCHECK_EQ(values.size(), effects.size()); | |
199 DCHECK_EQ(values.size(), controls.size()); | |
200 int const input_count = static_cast<int>(controls.size()); | |
201 control_output = jsgraph_->graph()->NewNode( | |
202 jsgraph_->common()->Merge(input_count), input_count, &controls.front()); | |
203 values.push_back(control_output); | |
204 effects.push_back(control_output); | |
205 value_output = jsgraph_->graph()->NewNode( | |
206 jsgraph_->common()->Phi(kMachAnyTagged, input_count), | |
207 static_cast<int>(values.size()), &values.front()); | |
208 effect_output = jsgraph_->graph()->NewNode( | |
209 jsgraph_->common()->EffectPhi(input_count), | |
210 static_cast<int>(effects.size()), &effects.front()); | |
211 } | 183 } |
184 DCHECK_NE(0u, values.size()); | |
185 DCHECK_EQ(values.size(), effects.size()); | |
186 DCHECK_EQ(values.size(), controls.size()); | |
187 int const input_count = static_cast<int>(controls.size()); | |
188 Node* control_output = jsgraph_->graph()->NewNode( | |
189 jsgraph_->common()->Merge(input_count), input_count, &controls.front()); | |
Michael Starzinger
2015/05/26 10:28:05
This will create a singleton Merge as well as sing
Benedikt Meurer
2015/05/26 10:29:31
Yes. My plan is to optimize this away later. For n
| |
190 values.push_back(control_output); | |
191 effects.push_back(control_output); | |
192 Node* value_output = jsgraph_->graph()->NewNode( | |
193 jsgraph_->common()->Phi(kMachAnyTagged, input_count), | |
194 static_cast<int>(values.size()), &values.front()); | |
195 Node* effect_output = jsgraph_->graph()->NewNode( | |
196 jsgraph_->common()->EffectPhi(input_count), | |
197 static_cast<int>(effects.size()), &effects.front()); | |
212 | 198 |
213 ReplaceWithValue(call, value_output, effect_output, control_output); | 199 ReplaceWithValue(call, value_output, effect_output, control_output); |
214 | 200 |
215 return Changed(value_output); | 201 return Changed(value_output); |
216 } | 202 } |
217 | 203 |
218 | 204 |
219 Node* JSInliner::CreateArgumentsAdaptorFrameState(JSCallFunctionAccessor* call, | 205 Node* JSInliner::CreateArgumentsAdaptorFrameState(JSCallFunctionAccessor* call, |
220 Zone* temp_zone) { | 206 Zone* temp_zone) { |
221 const Operator* op = jsgraph_->common()->FrameState( | 207 const Operator* op = jsgraph_->common()->FrameState( |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 } | 302 } |
317 } | 303 } |
318 } | 304 } |
319 | 305 |
320 return InlineCall(node, start, end); | 306 return InlineCall(node, start, end); |
321 } | 307 } |
322 | 308 |
323 } // namespace compiler | 309 } // namespace compiler |
324 } // namespace internal | 310 } // namespace internal |
325 } // namespace v8 | 311 } // namespace v8 |
OLD | NEW |