| 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/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 // Create two call site collections to swap between. | 406 // Create two call site collections to swap between. |
| 407 CallSites sites1(caller_graph_); | 407 CallSites sites1(caller_graph_); |
| 408 CallSites sites2(caller_graph_); | 408 CallSites sites2(caller_graph_); |
| 409 CallSites* call_sites_temp = NULL; | 409 CallSites* call_sites_temp = NULL; |
| 410 collected_call_sites_ = &sites1; | 410 collected_call_sites_ = &sites1; |
| 411 inlining_call_sites_ = &sites2; | 411 inlining_call_sites_ = &sites2; |
| 412 // Collect initial call sites. | 412 // Collect initial call sites. |
| 413 collected_call_sites_->FindCallSites(caller_graph_); | 413 collected_call_sites_->FindCallSites(caller_graph_); |
| 414 while (collected_call_sites_->HasCalls()) { | 414 while (collected_call_sites_->HasCalls()) { |
| 415 TRACE_INLINING(OS::Print(" Depth %"Pd" ----------\n", inlining_depth_)); | 415 TRACE_INLINING(OS::Print(" Depth %" Pd " ----------\n", |
| 416 inlining_depth_)); |
| 416 // Swap collected and inlining arrays and clear the new collecting array. | 417 // Swap collected and inlining arrays and clear the new collecting array. |
| 417 call_sites_temp = collected_call_sites_; | 418 call_sites_temp = collected_call_sites_; |
| 418 collected_call_sites_ = inlining_call_sites_; | 419 collected_call_sites_ = inlining_call_sites_; |
| 419 inlining_call_sites_ = call_sites_temp; | 420 inlining_call_sites_ = call_sites_temp; |
| 420 collected_call_sites_->Clear(); | 421 collected_call_sites_->Clear(); |
| 421 // Inline call sites at the current depth. | 422 // Inline call sites at the current depth. |
| 422 InlineStaticCalls(); | 423 InlineStaticCalls(); |
| 423 InlineClosureCalls(); | 424 InlineClosureCalls(); |
| 424 InlineInstanceCalls(); | 425 InlineInstanceCalls(); |
| 425 // Increment the inlining depth. Checked before recursive inlining. | 426 // Increment the inlining depth. Checked before recursive inlining. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 return false; | 465 return false; |
| 465 } | 466 } |
| 466 | 467 |
| 467 GrowableArray<Value*>* arguments = call_data->arguments; | 468 GrowableArray<Value*>* arguments = call_data->arguments; |
| 468 const intptr_t constant_arguments = CountConstants(*arguments); | 469 const intptr_t constant_arguments = CountConstants(*arguments); |
| 469 if (!ShouldWeInline(function, | 470 if (!ShouldWeInline(function, |
| 470 function.optimized_instruction_count(), | 471 function.optimized_instruction_count(), |
| 471 function.optimized_call_site_count(), | 472 function.optimized_call_site_count(), |
| 472 constant_arguments)) { | 473 constant_arguments)) { |
| 473 TRACE_INLINING(OS::Print(" Bailout: early heuristics with " | 474 TRACE_INLINING(OS::Print(" Bailout: early heuristics with " |
| 474 "code size: %"Pd", " | 475 "code size: %" Pd ", " |
| 475 "call sites: %"Pd", " | 476 "call sites: %" Pd ", " |
| 476 "const args: %"Pd"\n", | 477 "const args: %" Pd "\n", |
| 477 function.optimized_instruction_count(), | 478 function.optimized_instruction_count(), |
| 478 function.optimized_call_site_count(), | 479 function.optimized_call_site_count(), |
| 479 constant_arguments)); | 480 constant_arguments)); |
| 480 return false; | 481 return false; |
| 481 } | 482 } |
| 482 | 483 |
| 483 // Abort if this is a recursive occurrence. | 484 // Abort if this is a recursive occurrence. |
| 484 Definition* call = call_data->call; | 485 Definition* call = call_data->call; |
| 485 if (!FLAG_inline_recursive && IsCallRecursive(function, call)) { | 486 if (!FLAG_inline_recursive && IsCallRecursive(function, call)) { |
| 486 function.set_is_inlinable(false); | 487 function.set_is_inlinable(false); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 if (!ShouldWeInline(function, size, call_site_count, constants_count)) { | 617 if (!ShouldWeInline(function, size, call_site_count, constants_count)) { |
| 617 // If size is larger than all thresholds, don't consider it again. | 618 // If size is larger than all thresholds, don't consider it again. |
| 618 if ((size > FLAG_inlining_size_threshold) && | 619 if ((size > FLAG_inlining_size_threshold) && |
| 619 (call_site_count > FLAG_inlining_callee_call_sites_threshold) && | 620 (call_site_count > FLAG_inlining_callee_call_sites_threshold) && |
| 620 (size > FLAG_inlining_constant_arguments_size_threshold)) { | 621 (size > FLAG_inlining_constant_arguments_size_threshold)) { |
| 621 function.set_is_inlinable(false); | 622 function.set_is_inlinable(false); |
| 622 } | 623 } |
| 623 isolate->set_long_jump_base(base); | 624 isolate->set_long_jump_base(base); |
| 624 isolate->set_deopt_id(prev_deopt_id); | 625 isolate->set_deopt_id(prev_deopt_id); |
| 625 TRACE_INLINING(OS::Print(" Bailout: heuristics with " | 626 TRACE_INLINING(OS::Print(" Bailout: heuristics with " |
| 626 "code size: %"Pd", " | 627 "code size: %" Pd ", " |
| 627 "call sites: %"Pd", " | 628 "call sites: %" Pd ", " |
| 628 "const args: %"Pd"\n", | 629 "const args: %" Pd "\n", |
| 629 size, | 630 size, |
| 630 call_site_count, | 631 call_site_count, |
| 631 constants_count)); | 632 constants_count)); |
| 632 return false; | 633 return false; |
| 633 } | 634 } |
| 634 | 635 |
| 635 // If depth is less or equal to threshold recursively add call sites. | 636 // If depth is less or equal to threshold recursively add call sites. |
| 636 if (inlining_depth_ < FLAG_inlining_depth_threshold) { | 637 if (inlining_depth_ < FLAG_inlining_depth_threshold) { |
| 637 collected_call_sites_->FindCallSites(callee_graph); | 638 collected_call_sites_->FindCallSites(callee_graph); |
| 638 } | 639 } |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 OS::Print("After Inlining of %s\n", flow_graph_-> | 1425 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1425 parsed_function().function().ToFullyQualifiedCString()); | 1426 parsed_function().function().ToFullyQualifiedCString()); |
| 1426 FlowGraphPrinter printer(*flow_graph_); | 1427 FlowGraphPrinter printer(*flow_graph_); |
| 1427 printer.PrintBlocks(); | 1428 printer.PrintBlocks(); |
| 1428 } | 1429 } |
| 1429 } | 1430 } |
| 1430 } | 1431 } |
| 1431 } | 1432 } |
| 1432 | 1433 |
| 1433 } // namespace dart | 1434 } // namespace dart |
| OLD | NEW |