| 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 30 matching lines...) Expand all Loading... |
| 41 DEFINE_FLAG(bool, constant_propagation, true, | 41 DEFINE_FLAG(bool, constant_propagation, true, |
| 42 "Do conditional constant propagation/unreachable code elimination."); | 42 "Do conditional constant propagation/unreachable code elimination."); |
| 43 DEFINE_FLAG(bool, common_subexpression_elimination, true, | 43 DEFINE_FLAG(bool, common_subexpression_elimination, true, |
| 44 "Do common subexpression elimination."); | 44 "Do common subexpression elimination."); |
| 45 DEFINE_FLAG(bool, loop_invariant_code_motion, true, | 45 DEFINE_FLAG(bool, loop_invariant_code_motion, true, |
| 46 "Do loop invariant code motion."); | 46 "Do loop invariant code motion."); |
| 47 DEFINE_FLAG(bool, allocation_sinking, true, | 47 DEFINE_FLAG(bool, allocation_sinking, true, |
| 48 "Attempt to sink temporary allocations to side exits"); | 48 "Attempt to sink temporary allocations to side exits"); |
| 49 DEFINE_FLAG(int, deoptimization_counter_threshold, 16, | 49 DEFINE_FLAG(int, deoptimization_counter_threshold, 16, |
| 50 "How many times we allow deoptimization before we disallow optimization."); | 50 "How many times we allow deoptimization before we disallow optimization."); |
| 51 DEFINE_FLAG(int, deoptimization_counter_licm_threshold, 8, | |
| 52 "How many times we allow deoptimization before we disable LICM."); | |
| 53 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."); |
| 54 DEFINE_FLAG(bool, print_flow_graph_optimized, false, | 52 DEFINE_FLAG(bool, print_flow_graph_optimized, false, |
| 55 "Print the IR flow graph when optimizing."); | 53 "Print the IR flow graph when optimizing."); |
| 56 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); | 54 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); |
| 57 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); | 55 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); |
| 58 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 56 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
| 59 DEFINE_FLAG(bool, verify_compiler, false, | 57 DEFINE_FLAG(bool, verify_compiler, false, |
| 60 "Enable compiler verification assertions"); | 58 "Enable compiler verification assertions"); |
| 61 DECLARE_FLAG(bool, trace_failed_optimization_attempts); | 59 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
| 62 | 60 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 433 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 436 } | 434 } |
| 437 } | 435 } |
| 438 | 436 |
| 439 // Optimize (a << b) & c patterns, merge operations. | 437 // Optimize (a << b) & c patterns, merge operations. |
| 440 // Run after CSE in order to have more opportunity to merge | 438 // Run after CSE in order to have more opportunity to merge |
| 441 // instructions that have same inputs. | 439 // instructions that have same inputs. |
| 442 optimizer.TryOptimizePatterns(); | 440 optimizer.TryOptimizePatterns(); |
| 443 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 441 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 444 | 442 |
| 445 if (FLAG_loop_invariant_code_motion && | 443 if (FLAG_loop_invariant_code_motion) { |
| 446 (function.deoptimization_counter() < | |
| 447 FLAG_deoptimization_counter_licm_threshold)) { | |
| 448 LICM licm(flow_graph); | 444 LICM licm(flow_graph); |
| 449 licm.Optimize(); | 445 licm.Optimize(); |
| 450 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 446 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 451 } | 447 } |
| 452 flow_graph->RemoveRedefinitions(); | 448 flow_graph->RemoveRedefinitions(); |
| 453 | 449 |
| 454 if (FLAG_range_analysis) { | 450 if (FLAG_range_analysis) { |
| 455 // Propagate types after store-load-forwarding. Some phis may have | 451 // Propagate types after store-load-forwarding. Some phis may have |
| 456 // become smi phis that can be processed by range analysis. | 452 // become smi phis that can be processed by range analysis. |
| 457 FlowGraphTypePropagator::Propagate(flow_graph); | 453 FlowGraphTypePropagator::Propagate(flow_graph); |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 const Object& result = | 942 const Object& result = |
| 947 Object::Handle(isolate->object_store()->sticky_error()); | 943 Object::Handle(isolate->object_store()->sticky_error()); |
| 948 isolate->object_store()->clear_sticky_error(); | 944 isolate->object_store()->clear_sticky_error(); |
| 949 return result.raw(); | 945 return result.raw(); |
| 950 } | 946 } |
| 951 UNREACHABLE(); | 947 UNREACHABLE(); |
| 952 return Object::null(); | 948 return Object::null(); |
| 953 } | 949 } |
| 954 | 950 |
| 955 } // namespace dart | 951 } // namespace dart |
| OLD | NEW |