| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 11 matching lines...) Expand all Loading... |
| 22 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); | 22 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); |
| 23 DEFINE_FLAG(int, inlining_size_threshold, 50, | 23 DEFINE_FLAG(int, inlining_size_threshold, 50, |
| 24 "Inline only functions with up to threshold instructions (default 50)"); | 24 "Inline only functions with up to threshold instructions (default 50)"); |
| 25 // TODO(srdjan): set to 3 once crash in apidoc.dart is resolved. | 25 // TODO(srdjan): set to 3 once crash in apidoc.dart is resolved. |
| 26 DEFINE_FLAG(int, inlining_depth_threshold, 3, | 26 DEFINE_FLAG(int, inlining_depth_threshold, 3, |
| 27 "Inline recursively up to threshold depth (default 3)"); | 27 "Inline recursively up to threshold depth (default 3)"); |
| 28 DECLARE_FLAG(bool, print_flow_graph); | 28 DECLARE_FLAG(bool, print_flow_graph); |
| 29 DECLARE_FLAG(int, deoptimization_counter_threshold); | 29 DECLARE_FLAG(int, deoptimization_counter_threshold); |
| 30 DECLARE_FLAG(bool, verify_compiler); | 30 DECLARE_FLAG(bool, verify_compiler); |
| 31 DECLARE_FLAG(bool, compiler_stats); | 31 DECLARE_FLAG(bool, compiler_stats); |
| 32 DECLARE_FLAG(bool, reject_named_argument_as_positional); | |
| 33 | 32 |
| 34 #define TRACE_INLINING(statement) \ | 33 #define TRACE_INLINING(statement) \ |
| 35 do { \ | 34 do { \ |
| 36 if (FLAG_trace_inlining) statement; \ | 35 if (FLAG_trace_inlining) statement; \ |
| 37 } while (false) | 36 } while (false) |
| 38 | 37 |
| 39 | 38 |
| 40 // Test if a call is recursive by looking in the deoptimization environment. | 39 // Test if a call is recursive by looking in the deoptimization environment. |
| 41 static bool IsCallRecursive(const Function& function, Definition* call) { | 40 static bool IsCallRecursive(const Function& function, Definition* call) { |
| 42 Environment* env = call->env(); | 41 Environment* env = call->env(); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 return false; | 272 return false; |
| 274 } | 273 } |
| 275 | 274 |
| 276 // Abort if the callee has an intrinsic translation. | 275 // Abort if the callee has an intrinsic translation. |
| 277 if (Intrinsifier::CanIntrinsify(function)) { | 276 if (Intrinsifier::CanIntrinsify(function)) { |
| 278 function.set_is_inlinable(false); | 277 function.set_is_inlinable(false); |
| 279 TRACE_INLINING(OS::Print(" Bailout: can intrinsify\n")); | 278 TRACE_INLINING(OS::Print(" Bailout: can intrinsify\n")); |
| 280 return false; | 279 return false; |
| 281 } | 280 } |
| 282 | 281 |
| 283 // Abort if we are running legacy support for optional parameters. | |
| 284 if (!FLAG_reject_named_argument_as_positional && | |
| 285 function.HasOptionalPositionalParameters() && | |
| 286 (!argument_names.IsNull() && (argument_names.Length() > 0))) { | |
| 287 function.set_is_inlinable(false); | |
| 288 TRACE_INLINING(OS::Print( | |
| 289 " Bailout: named optional positional parameter\n")); | |
| 290 return false; | |
| 291 } | |
| 292 | |
| 293 Isolate* isolate = Isolate::Current(); | 282 Isolate* isolate = Isolate::Current(); |
| 294 // Save and clear IC data. | 283 // Save and clear IC data. |
| 295 const Array& prev_ic_data = Array::Handle(isolate->ic_data_array()); | 284 const Array& prev_ic_data = Array::Handle(isolate->ic_data_array()); |
| 296 isolate->set_ic_data_array(Array::null()); | 285 isolate->set_ic_data_array(Array::null()); |
| 297 // Save and clear deopt id. | 286 // Save and clear deopt id. |
| 298 const intptr_t prev_deopt_id = isolate->deopt_id(); | 287 const intptr_t prev_deopt_id = isolate->deopt_id(); |
| 299 isolate->set_deopt_id(0); | 288 isolate->set_deopt_id(0); |
| 300 // Install bailout jump. | 289 // Install bailout jump. |
| 301 LongJump* base = isolate->long_jump_base(); | 290 LongJump* base = isolate->long_jump_base(); |
| 302 LongJump jump; | 291 LongJump jump; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 OS::Print("After Inlining of %s\n", flow_graph_-> | 685 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 697 parsed_function().function().ToFullyQualifiedCString()); | 686 parsed_function().function().ToFullyQualifiedCString()); |
| 698 FlowGraphPrinter printer(*flow_graph_); | 687 FlowGraphPrinter printer(*flow_graph_); |
| 699 printer.PrintBlocks(); | 688 printer.PrintBlocks(); |
| 700 } | 689 } |
| 701 } | 690 } |
| 702 } | 691 } |
| 703 } | 692 } |
| 704 | 693 |
| 705 } // namespace dart | 694 } // namespace dart |
| OLD | NEW |