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/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/all-nodes.h" | 10 #include "src/compiler/all-nodes.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // Return the effect output of the graph, | 72 // Return the effect output of the graph, |
73 // that is the effect input of the return statement of the inlinee. | 73 // that is the effect input of the return statement of the inlinee. |
74 Node* effect_output() { | 74 Node* effect_output() { |
75 return NodeProperties::GetEffectInput(unique_return()); | 75 return NodeProperties::GetEffectInput(unique_return()); |
76 } | 76 } |
77 // Return the value output of the graph, | 77 // Return the value output of the graph, |
78 // that is the value input of the return statement of the inlinee. | 78 // that is the value input of the return statement of the inlinee. |
79 Node* value_output() { | 79 Node* value_output() { |
80 return NodeProperties::GetValueInput(unique_return(), 0); | 80 return NodeProperties::GetValueInput(unique_return(), 0); |
81 } | 81 } |
| 82 // Return the control output of the graph, |
| 83 // that is the control input of the return statement of the inlinee. |
| 84 Node* control_output() { |
| 85 return NodeProperties::GetControlInput(unique_return(), 0); |
| 86 } |
82 // Return the unique return statement of the graph. | 87 // Return the unique return statement of the graph. |
83 Node* unique_return() { | 88 Node* unique_return() { |
84 Node* unique_return = NodeProperties::GetControlInput(end_); | 89 Node* unique_return = NodeProperties::GetControlInput(end_); |
85 DCHECK_EQ(IrOpcode::kReturn, unique_return->opcode()); | 90 DCHECK_EQ(IrOpcode::kReturn, unique_return->opcode()); |
86 return unique_return; | 91 return unique_return; |
87 } | 92 } |
88 | 93 |
89 // Counts JSFunction, Receiver, arguments, context but not effect, control. | 94 // Counts JSFunction, Receiver, arguments, context but not effect, control. |
90 size_t total_parameters() { return start_->op()->ValueOutputCount(); } | 95 size_t total_parameters() { return start_->op()->ValueOutputCount(); } |
91 | 96 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 edge.UpdateTo(context); | 261 edge.UpdateTo(context); |
257 } else if (NodeProperties::IsControlEdge(edge)) { | 262 } else if (NodeProperties::IsControlEdge(edge)) { |
258 edge.UpdateTo(control); | 263 edge.UpdateTo(control); |
259 } else { | 264 } else { |
260 UNREACHABLE(); | 265 UNREACHABLE(); |
261 } | 266 } |
262 break; | 267 break; |
263 } | 268 } |
264 } | 269 } |
265 | 270 |
266 NodeProperties::ReplaceWithValue(call, value_output(), effect_output()); | 271 for (Edge edge : call->use_edges()) { |
| 272 if (NodeProperties::IsControlEdge(edge)) { |
| 273 // TODO(turbofan): Handle kIfException uses. |
| 274 DCHECK_EQ(IrOpcode::kIfSuccess, edge.from()->opcode()); |
| 275 edge.from()->ReplaceUses(control_output()); |
| 276 edge.UpdateTo(nullptr); |
| 277 } else if (NodeProperties::IsEffectEdge(edge)) { |
| 278 edge.UpdateTo(effect_output()); |
| 279 } else { |
| 280 edge.UpdateTo(value_output()); |
| 281 } |
| 282 } |
| 283 |
267 return Reducer::Replace(value_output()); | 284 return Reducer::Replace(value_output()); |
268 } | 285 } |
269 | 286 |
270 } // namespace | 287 } // namespace |
271 | 288 |
272 | 289 |
273 void JSInliner::AddClosureToFrameState(Node* frame_state, | 290 void JSInliner::AddClosureToFrameState(Node* frame_state, |
274 Handle<JSFunction> jsfunction) { | 291 Handle<JSFunction> jsfunction) { |
275 FrameStateCallInfo call_info = OpParameter<FrameStateCallInfo>(frame_state); | 292 FrameStateCallInfo call_info = OpParameter<FrameStateCallInfo>(frame_state); |
276 const Operator* op = jsgraph_->common()->FrameState( | 293 const Operator* op = jsgraph_->common()->FrameState( |
(...skipping 28 matching lines...) Expand all Loading... |
305 | 322 |
306 Reduction JSInliner::Reduce(Node* node) { | 323 Reduction JSInliner::Reduce(Node* node) { |
307 if (node->opcode() != IrOpcode::kJSCallFunction) return NoChange(); | 324 if (node->opcode() != IrOpcode::kJSCallFunction) return NoChange(); |
308 | 325 |
309 JSCallFunctionAccessor call(node); | 326 JSCallFunctionAccessor call(node); |
310 HeapObjectMatcher<JSFunction> match(call.jsfunction()); | 327 HeapObjectMatcher<JSFunction> match(call.jsfunction()); |
311 if (!match.HasValue()) return NoChange(); | 328 if (!match.HasValue()) return NoChange(); |
312 | 329 |
313 Handle<JSFunction> function = match.Value().handle(); | 330 Handle<JSFunction> function = match.Value().handle(); |
314 | 331 |
315 if (function->shared()->native()) { | |
316 if (FLAG_trace_turbo_inlining) { | |
317 SmartArrayPointer<char> name = | |
318 function->shared()->DebugName()->ToCString(); | |
319 PrintF("Not Inlining %s into %s because inlinee is native\n", name.get(), | |
320 info_->shared_info()->DebugName()->ToCString().get()); | |
321 } | |
322 return NoChange(); | |
323 } | |
324 | |
325 CompilationInfoWithZone info(function); | 332 CompilationInfoWithZone info(function); |
326 | 333 |
327 if (!Compiler::ParseAndAnalyze(&info)) return NoChange(); | 334 if (!Compiler::ParseAndAnalyze(&info)) return NoChange(); |
328 if (!Compiler::EnsureDeoptimizationSupport(&info)) return NoChange(); | 335 if (!Compiler::EnsureDeoptimizationSupport(&info)) return NoChange(); |
329 | 336 |
330 if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) { | 337 if (info.scope()->arguments() != NULL && is_sloppy(info.language_mode())) { |
331 // For now do not inline functions that use their arguments array. | 338 // For now do not inline functions that use their arguments array. |
332 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); | 339 SmartArrayPointer<char> name = function->shared()->DebugName()->ToCString(); |
333 if (FLAG_trace_turbo_inlining) { | 340 if (FLAG_trace_turbo_inlining) { |
334 PrintF( | 341 PrintF( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 380 } |
374 } | 381 } |
375 } | 382 } |
376 | 383 |
377 return inlinee.InlineAtCall(jsgraph_, node); | 384 return inlinee.InlineAtCall(jsgraph_, node); |
378 } | 385 } |
379 | 386 |
380 } // namespace compiler | 387 } // namespace compiler |
381 } // namespace internal | 388 } // namespace internal |
382 } // namespace v8 | 389 } // namespace v8 |
OLD | NEW |