Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
| 6 | 6 |
| 7 #include "vm/block_scheduler.h" | 7 #include "vm/block_scheduler.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 function.ToCString(), | 479 function.ToCString(), |
| 480 function.deoptimization_counter())); | 480 function.deoptimization_counter())); |
| 481 | 481 |
| 482 // TODO(fschneider): Enable inlining inside try-blocks. | 482 // TODO(fschneider): Enable inlining inside try-blocks. |
| 483 if (call_data->call->GetBlock()->try_index() != | 483 if (call_data->call->GetBlock()->try_index() != |
| 484 CatchClauseNode::kInvalidTryIndex) { | 484 CatchClauseNode::kInvalidTryIndex) { |
| 485 TRACE_INLINING(OS::Print(" Bailout: inside try-block\n")); | 485 TRACE_INLINING(OS::Print(" Bailout: inside try-block\n")); |
| 486 return false; | 486 return false; |
| 487 } | 487 } |
| 488 | 488 |
| 489 // Allocate a ZoneHandle so that the unoptimized code is not collected | |
| 490 // while we are trying to inline its function. | |
| 491 const Code& unoptimized_code = | |
|
Ivan Posva
2013/11/16 00:06:21
We should probably keep the code in a local handle
zra
2013/11/18 18:54:33
Done.
| |
| 492 Code::ZoneHandle(function.unoptimized_code()); | |
| 489 // Abort if the inlinable bit on the function is low. | 493 // Abort if the inlinable bit on the function is low. |
| 490 if (!function.IsInlineable()) { | 494 if (!function.IsInlineable()) { |
| 491 TRACE_INLINING(OS::Print(" Bailout: not inlinable\n")); | 495 TRACE_INLINING(OS::Print(" Bailout: not inlinable\n")); |
| 492 return false; | 496 return false; |
| 493 } | 497 } |
| 494 | 498 |
| 495 // Abort if this function has deoptimized too much. | 499 // Abort if this function has deoptimized too much. |
| 496 if (function.deoptimization_counter() >= | 500 if (function.deoptimization_counter() >= |
| 497 FLAG_deoptimization_counter_threshold) { | 501 FLAG_deoptimization_counter_threshold) { |
| 498 function.set_is_inlinable(false); | 502 function.set_is_inlinable(false); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 ParsedFunction* parsed_function; | 542 ParsedFunction* parsed_function; |
| 539 { | 543 { |
| 540 TimerScope timer(FLAG_compiler_stats, | 544 TimerScope timer(FLAG_compiler_stats, |
| 541 &CompilerStats::graphinliner_parse_timer, | 545 &CompilerStats::graphinliner_parse_timer, |
| 542 isolate); | 546 isolate); |
| 543 parsed_function = GetParsedFunction(function, &in_cache); | 547 parsed_function = GetParsedFunction(function, &in_cache); |
| 544 } | 548 } |
| 545 | 549 |
| 546 // Load IC data for the callee. | 550 // Load IC data for the callee. |
| 547 Array& ic_data_array = Array::Handle(); | 551 Array& ic_data_array = Array::Handle(); |
| 548 if (function.HasCode()) { | 552 |
| 549 const Code& unoptimized_code = | 553 // IsInlineable above checked HasCode. Creating a ZoneHandle for the code |
| 550 Code::Handle(function.unoptimized_code()); | 554 // should have kept GC from detaching, but let's assert just to make sure. |
| 551 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray(); | 555 ASSERT(function.HasCode()); |
| 552 } | 556 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray(); |
| 553 | 557 |
| 554 // Build the callee graph. | 558 // Build the callee graph. |
| 555 InlineExitCollector* exit_collector = | 559 InlineExitCollector* exit_collector = |
| 556 new InlineExitCollector(caller_graph_, call); | 560 new InlineExitCollector(caller_graph_, call); |
| 557 FlowGraphBuilder builder(parsed_function, | 561 FlowGraphBuilder builder(parsed_function, |
| 558 ic_data_array, | 562 ic_data_array, |
| 559 exit_collector, | 563 exit_collector, |
| 560 Isolate::kNoDeoptId); | 564 Isolate::kNoDeoptId); |
| 561 builder.SetInitialBlockId(caller_graph_->max_block_id()); | 565 builder.SetInitialBlockId(caller_graph_->max_block_id()); |
| 562 FlowGraph* callee_graph; | 566 FlowGraph* callee_graph; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 "const args: %" Pd "\n", | 664 "const args: %" Pd "\n", |
| 661 size, | 665 size, |
| 662 call_site_count, | 666 call_site_count, |
| 663 constants_count)); | 667 constants_count)); |
| 664 return false; | 668 return false; |
| 665 } | 669 } |
| 666 | 670 |
| 667 collected_call_sites_->FindCallSites(callee_graph, inlining_depth_); | 671 collected_call_sites_->FindCallSites(callee_graph, inlining_depth_); |
| 668 | 672 |
| 669 // Add the function to the cache. | 673 // Add the function to the cache. |
| 670 if (!in_cache) function_cache_.Add(parsed_function); | 674 if (!in_cache) { |
| 675 function_cache_.Add(parsed_function); | |
| 676 } | |
| 671 | 677 |
| 672 // Build succeeded so we restore the bailout jump. | 678 // Build succeeded so we restore the bailout jump. |
| 673 inlined_ = true; | 679 inlined_ = true; |
| 674 inlined_size_ += size; | 680 inlined_size_ += size; |
| 675 isolate->set_long_jump_base(base); | 681 isolate->set_long_jump_base(base); |
| 676 isolate->set_deopt_id(prev_deopt_id); | 682 isolate->set_deopt_id(prev_deopt_id); |
| 677 | 683 |
| 678 call_data->callee_graph = callee_graph; | 684 call_data->callee_graph = callee_graph; |
| 679 call_data->parameter_stubs = param_stubs; | 685 call_data->parameter_stubs = param_stubs; |
| 680 call_data->exit_collector = exit_collector; | 686 call_data->exit_collector = exit_collector; |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1522 OS::Print("After Inlining of %s\n", flow_graph_-> | 1528 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1523 parsed_function().function().ToFullyQualifiedCString()); | 1529 parsed_function().function().ToFullyQualifiedCString()); |
| 1524 FlowGraphPrinter printer(*flow_graph_); | 1530 FlowGraphPrinter printer(*flow_graph_); |
| 1525 printer.PrintBlocks(); | 1531 printer.PrintBlocks(); |
| 1526 } | 1532 } |
| 1527 } | 1533 } |
| 1528 } | 1534 } |
| 1529 } | 1535 } |
| 1530 | 1536 |
| 1531 } // namespace dart | 1537 } // namespace dart |
| OLD | NEW |