| 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/assert.h" | |
| 8 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 9 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 10 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 11 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| 12 #include "vm/flow_graph_optimizer.h" | 11 #include "vm/flow_graph_optimizer.h" |
| 13 #include "vm/il_printer.h" | 12 #include "vm/il_printer.h" |
| 14 #include "vm/intrinsifier.h" | 13 #include "vm/intrinsifier.h" |
| 15 #include "vm/longjump.h" | 14 #include "vm/longjump.h" |
| 16 #include "vm/object.h" | 15 #include "vm/object.h" |
| 17 #include "vm/object_store.h" | 16 #include "vm/object_store.h" |
| 18 | 17 |
| 19 namespace dart { | 18 namespace dart { |
| 20 | 19 |
| 21 DEFINE_FLAG(bool, trace_inlining, false, "Trace inlining"); | 20 DEFINE_FLAG(bool, trace_inlining, false, "Trace inlining"); |
| 22 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); | 21 DEFINE_FLAG(charp, inlining_filter, NULL, "Inline only in named function"); |
| 23 DEFINE_FLAG(int, inlining_size_threshold, 250, | 22 DEFINE_FLAG(int, inlining_size_threshold, 250, |
| 24 "Inline only functions with up to threshold instructions"); | 23 "Inline only functions with up to threshold instructions"); |
| 25 DEFINE_FLAG(bool, inline_control_flow, true, | 24 DEFINE_FLAG(bool, inline_control_flow, true, |
| 26 "Inline functions with control flow."); | 25 "Inline functions with control flow."); |
| 27 DECLARE_FLAG(bool, print_flow_graph); | 26 DECLARE_FLAG(bool, print_flow_graph); |
| 28 DECLARE_FLAG(int, deoptimization_counter_threshold); | 27 DECLARE_FLAG(int, deoptimization_counter_threshold); |
| 28 DECLARE_FLAG(bool, verify_compiler); |
| 29 | 29 |
| 30 #define TRACE_INLINING(statement) \ | 30 #define TRACE_INLINING(statement) \ |
| 31 do { \ | 31 do { \ |
| 32 if (FLAG_trace_inlining) statement; \ | 32 if (FLAG_trace_inlining) statement; \ |
| 33 } while (false) | 33 } while (false) |
| 34 | 34 |
| 35 | 35 |
| 36 // Test if a call is recursive by looking in the deoptimization environment. | 36 // Test if a call is recursive by looking in the deoptimization environment. |
| 37 static bool IsCallRecursive(const Function& function, Definition* call) { | 37 static bool IsCallRecursive(const Function& function, Definition* call) { |
| 38 Environment* env = call->env(); | 38 Environment* env = call->env(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 222 } |
| 223 ASSERT(arg_index == arguments->length()); | 223 ASSERT(arg_index == arguments->length()); |
| 224 | 224 |
| 225 // Replace callee's null constant with caller's null constant. | 225 // Replace callee's null constant with caller's null constant. |
| 226 callee_graph->graph_entry()->constant_null()->ReplaceUsesWith( | 226 callee_graph->graph_entry()->constant_null()->ReplaceUsesWith( |
| 227 caller_graph_->graph_entry()->constant_null()); | 227 caller_graph_->graph_entry()->constant_null()); |
| 228 | 228 |
| 229 TRACE_INLINING(OS::Print(" Success\n")); | 229 TRACE_INLINING(OS::Print(" Success\n")); |
| 230 | 230 |
| 231 // Check that inlining maintains use lists. | 231 // Check that inlining maintains use lists. |
| 232 SLOW_ASSERT(caller_graph_->ValidateUseLists()); | 232 DEBUG_ASSERT(!FLAG_verify_compiler || caller_graph_->ValidateUseLists()); |
| 233 | 233 |
| 234 // Build succeeded so we restore the bailout jump. | 234 // Build succeeded so we restore the bailout jump. |
| 235 inlined_ = true; | 235 inlined_ = true; |
| 236 inlined_size_ += size; | 236 inlined_size_ += size; |
| 237 isolate->set_long_jump_base(base); | 237 isolate->set_long_jump_base(base); |
| 238 isolate->set_deopt_id(prev_deopt_id); | 238 isolate->set_deopt_id(prev_deopt_id); |
| 239 isolate->set_ic_data_array(prev_ic_data.raw()); | 239 isolate->set_ic_data_array(prev_ic_data.raw()); |
| 240 return true; | 240 return true; |
| 241 } else { | 241 } else { |
| 242 Error& error = Error::Handle(); | 242 Error& error = Error::Handle(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 OS::Print("After Inlining of %s\n", flow_graph_-> | 347 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 348 parsed_function().function().ToFullyQualifiedCString()); | 348 parsed_function().function().ToFullyQualifiedCString()); |
| 349 FlowGraphPrinter printer(*flow_graph_); | 349 FlowGraphPrinter printer(*flow_graph_); |
| 350 printer.PrintBlocks(); | 350 printer.PrintBlocks(); |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 } // namespace dart | 356 } // namespace dart |
| OLD | NEW |