| 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" |
| 11 #include "vm/flow_graph_compiler.h" | 11 #include "vm/flow_graph_compiler.h" |
| 12 #include "vm/flow_graph_optimizer.h" | 12 #include "vm/flow_graph_optimizer.h" |
| 13 #include "vm/il_printer.h" | 13 #include "vm/il_printer.h" |
| 14 #include "vm/intrinsifier.h" | 14 #include "vm/intrinsifier.h" |
| 15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
| 16 #include "vm/object.h" | 16 #include "vm/object.h" |
| 17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 18 #include "vm/timer.h" | 18 #include "vm/timer.h" |
| 19 | 19 |
| 20 namespace dart { | 20 namespace dart { |
| 21 | 21 |
| 22 DEFINE_FLAG(int, deoptimization_counter_inlining_threshold, 12, |
| 23 "How many times we allow deoptimization before we stop inlining."); |
| 22 DEFINE_FLAG(bool, trace_inlining, false, "Trace inlining"); | 24 DEFINE_FLAG(bool, trace_inlining, false, "Trace inlining"); |
| 23 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); | 25 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); |
| 24 | 26 |
| 25 // Flags for inlining heuristics. | 27 // Flags for inlining heuristics. |
| 26 DEFINE_FLAG(int, inlining_depth_threshold, 3, | 28 DEFINE_FLAG(int, inlining_depth_threshold, 3, |
| 27 "Inline function calls up to threshold nesting depth"); | 29 "Inline function calls up to threshold nesting depth"); |
| 28 DEFINE_FLAG(int, inlining_size_threshold, 22, | 30 DEFINE_FLAG(int, inlining_size_threshold, 22, |
| 29 "Always inline functions that have threshold or fewer instructions"); | 31 "Always inline functions that have threshold or fewer instructions"); |
| 30 DEFINE_FLAG(int, inlining_callee_call_sites_threshold, 1, | 32 DEFINE_FLAG(int, inlining_callee_call_sites_threshold, 1, |
| 31 "Always inline functions containing threshold or fewer calls."); | 33 "Always inline functions containing threshold or fewer calls."); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return true; | 382 return true; |
| 381 } | 383 } |
| 382 return false; | 384 return false; |
| 383 } | 385 } |
| 384 | 386 |
| 385 // TODO(srdjan): Handle large 'skip_static_call_deopt_ids'. Currently | 387 // TODO(srdjan): Handle large 'skip_static_call_deopt_ids'. Currently |
| 386 // max. size observed is 11 (dart2js). | 388 // max. size observed is 11 (dart2js). |
| 387 void InlineCalls() { | 389 void InlineCalls() { |
| 388 // If inlining depth is less then one abort. | 390 // If inlining depth is less then one abort. |
| 389 if (FLAG_inlining_depth_threshold < 1) return; | 391 if (FLAG_inlining_depth_threshold < 1) return; |
| 392 if (caller_graph_->parsed_function().function().deoptimization_counter() >= |
| 393 FLAG_deoptimization_counter_inlining_threshold) { |
| 394 return; |
| 395 } |
| 390 // Create two call site collections to swap between. | 396 // Create two call site collections to swap between. |
| 391 CallSites sites1(caller_graph_); | 397 CallSites sites1(caller_graph_); |
| 392 CallSites sites2(caller_graph_); | 398 CallSites sites2(caller_graph_); |
| 393 CallSites* call_sites_temp = NULL; | 399 CallSites* call_sites_temp = NULL; |
| 394 collected_call_sites_ = &sites1; | 400 collected_call_sites_ = &sites1; |
| 395 inlining_call_sites_ = &sites2; | 401 inlining_call_sites_ = &sites2; |
| 396 // Collect initial call sites. | 402 // Collect initial call sites. |
| 397 collected_call_sites_->FindCallSites(caller_graph_); | 403 collected_call_sites_->FindCallSites(caller_graph_); |
| 398 while (collected_call_sites_->HasCalls()) { | 404 while (collected_call_sites_->HasCalls()) { |
| 399 TRACE_INLINING(OS::Print(" Depth %"Pd" ----------\n", inlining_depth_)); | 405 TRACE_INLINING(OS::Print(" Depth %"Pd" ----------\n", inlining_depth_)); |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 OS::Print("After Inlining of %s\n", flow_graph_-> | 1372 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1367 parsed_function().function().ToFullyQualifiedCString()); | 1373 parsed_function().function().ToFullyQualifiedCString()); |
| 1368 FlowGraphPrinter printer(*flow_graph_); | 1374 FlowGraphPrinter printer(*flow_graph_); |
| 1369 printer.PrintBlocks(); | 1375 printer.PrintBlocks(); |
| 1370 } | 1376 } |
| 1371 } | 1377 } |
| 1372 } | 1378 } |
| 1373 } | 1379 } |
| 1374 | 1380 |
| 1375 } // namespace dart | 1381 } // namespace dart |
| OLD | NEW |