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