| 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/compiler.h" | 5 #include "vm/compiler.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 | 8 |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 "Do conditional constant propagation/unreachable code elimination."); | 44 "Do conditional constant propagation/unreachable code elimination."); |
| 45 DEFINE_FLAG(int, deoptimization_counter_threshold, 16, | 45 DEFINE_FLAG(int, deoptimization_counter_threshold, 16, |
| 46 "How many times we allow deoptimization before we disallow optimization."); | 46 "How many times we allow deoptimization before we disallow optimization."); |
| 47 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); | 47 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); |
| 48 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); | 48 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); |
| 49 DEFINE_FLAG(bool, loop_invariant_code_motion, true, | 49 DEFINE_FLAG(bool, loop_invariant_code_motion, true, |
| 50 "Do loop invariant code motion."); | 50 "Do loop invariant code motion."); |
| 51 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); | 51 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); |
| 52 DEFINE_FLAG(bool, print_flow_graph_optimized, false, | 52 DEFINE_FLAG(bool, print_flow_graph_optimized, false, |
| 53 "Print the IR flow graph when optimizing."); | 53 "Print the IR flow graph when optimizing."); |
| 54 DEFINE_FLAG(bool, print_ic_data_map, false, |
| 55 "Print the deopt-id to ICData map in optimizing compiler."); |
| 54 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); | 56 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); |
| 55 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); | 57 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); |
| 56 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 58 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
| 57 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); | 59 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); |
| 58 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 60 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 59 DEFINE_FLAG(bool, verify_compiler, false, | 61 DEFINE_FLAG(bool, verify_compiler, false, |
| 60 "Enable compiler verification assertions"); | 62 "Enable compiler verification assertions"); |
| 61 | 63 |
| 62 DECLARE_FLAG(bool, trace_failed_optimization_attempts); | 64 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
| 63 DECLARE_FLAG(bool, trace_patching); | 65 DECLARE_FLAG(bool, trace_patching); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 Error& error = Error::Handle(isolate); | 235 Error& error = Error::Handle(isolate); |
| 234 error = isolate->object_store()->sticky_error(); | 236 error = isolate->object_store()->sticky_error(); |
| 235 isolate->object_store()->clear_sticky_error(); | 237 isolate->object_store()->clear_sticky_error(); |
| 236 return error.raw(); | 238 return error.raw(); |
| 237 } | 239 } |
| 238 UNREACHABLE(); | 240 UNREACHABLE(); |
| 239 return Error::null(); | 241 return Error::null(); |
| 240 } | 242 } |
| 241 | 243 |
| 242 | 244 |
| 243 | |
| 244 // Return false if bailed out. | 245 // Return false if bailed out. |
| 245 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, | 246 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, |
| 246 bool optimized, | 247 bool optimized, |
| 247 intptr_t osr_id) { | 248 intptr_t osr_id) { |
| 248 const Function& function = parsed_function->function(); | 249 const Function& function = parsed_function->function(); |
| 249 if (optimized && !function.IsOptimizable()) { | 250 if (optimized && !function.IsOptimizable()) { |
| 250 return false; | 251 return false; |
| 251 } | 252 } |
| 252 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); | 253 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); |
| 253 bool is_compiled = false; | 254 bool is_compiled = false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 282 isolate); | 283 isolate); |
| 283 ZoneGrowableArray<const ICData*>* ic_data_array = | 284 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 284 new(isolate) ZoneGrowableArray<const ICData*>(); | 285 new(isolate) ZoneGrowableArray<const ICData*>(); |
| 285 if (optimized) { | 286 if (optimized) { |
| 286 ASSERT(function.HasCode()); | 287 ASSERT(function.HasCode()); |
| 287 // Extract type feedback before the graph is built, as the graph | 288 // Extract type feedback before the graph is built, as the graph |
| 288 // builder uses it to attach it to nodes. | 289 // builder uses it to attach it to nodes. |
| 289 ASSERT(function.deoptimization_counter() < | 290 ASSERT(function.deoptimization_counter() < |
| 290 FLAG_deoptimization_counter_threshold); | 291 FLAG_deoptimization_counter_threshold); |
| 291 function.RestoreICDataMap(ic_data_array); | 292 function.RestoreICDataMap(ic_data_array); |
| 293 if (FLAG_print_ic_data_map) { |
| 294 for (intptr_t i = 0; i < ic_data_array->length(); i++) { |
| 295 if ((*ic_data_array)[i] != NULL) { |
| 296 OS::Print("%" Pd " ", i); |
| 297 FlowGraphPrinter::PrintICData(*(*ic_data_array)[i]); |
| 298 } |
| 299 } |
| 300 } |
| 292 } | 301 } |
| 293 | 302 |
| 294 // Build the flow graph. | 303 // Build the flow graph. |
| 295 FlowGraphBuilder builder(parsed_function, | 304 FlowGraphBuilder builder(parsed_function, |
| 296 *ic_data_array, | 305 *ic_data_array, |
| 297 NULL, // NULL = not inlining. | 306 NULL, // NULL = not inlining. |
| 298 osr_id, | 307 osr_id, |
| 299 optimized); | 308 optimized); |
| 300 flow_graph = builder.BuildGraph(); | 309 flow_graph = builder.BuildGraph(); |
| 301 } | 310 } |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 const Object& result = | 1021 const Object& result = |
| 1013 Object::Handle(isolate->object_store()->sticky_error()); | 1022 Object::Handle(isolate->object_store()->sticky_error()); |
| 1014 isolate->object_store()->clear_sticky_error(); | 1023 isolate->object_store()->clear_sticky_error(); |
| 1015 return result.raw(); | 1024 return result.raw(); |
| 1016 } | 1025 } |
| 1017 UNREACHABLE(); | 1026 UNREACHABLE(); |
| 1018 return Object::null(); | 1027 return Object::null(); |
| 1019 } | 1028 } |
| 1020 | 1029 |
| 1021 } // namespace dart | 1030 } // namespace dart |
| OLD | NEW |