| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_range_analysis.h" | 5 #include "vm/flow_graph_range_analysis.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/il_printer.h" | 8 #include "vm/il_printer.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 DEFINE_FLAG(bool, array_bounds_check_elimination, true, | 12 DEFINE_FLAG(bool, array_bounds_check_elimination, true, |
| 13 "Eliminate redundant bounds checks."); | 13 "Eliminate redundant bounds checks."); |
| 14 DEFINE_FLAG(bool, trace_range_analysis, false, "Trace range analysis progress"); | 14 DEFINE_FLAG(bool, trace_range_analysis, false, "Trace range analysis progress"); |
| 15 DEFINE_FLAG(bool, trace_integer_ir_selection, false, | 15 DEFINE_FLAG(bool, trace_integer_ir_selection, false, |
| 16 "Print integer IR selection optimization pass."); | 16 "Print integer IR selection optimization pass."); |
| 17 DECLARE_FLAG(bool, precompilation); | |
| 18 DECLARE_FLAG(bool, trace_constant_propagation); | 17 DECLARE_FLAG(bool, trace_constant_propagation); |
| 19 | 18 |
| 20 // Quick access to the locally defined isolate() and zone() methods. | 19 // Quick access to the locally defined isolate() and zone() methods. |
| 21 #define I (isolate()) | 20 #define I (isolate()) |
| 22 #define Z (zone()) | 21 #define Z (zone()) |
| 23 | 22 |
| 24 void RangeAnalysis::Analyze() { | 23 void RangeAnalysis::Analyze() { |
| 25 CollectValues(); | 24 CollectValues(); |
| 26 InsertConstraints(); | 25 InsertConstraints(); |
| 27 DiscoverSimpleInductionVariables(); | 26 DiscoverSimpleInductionVariables(); |
| (...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 | 1526 |
| 1528 | 1527 |
| 1529 void RangeAnalysis::EliminateRedundantBoundsChecks() { | 1528 void RangeAnalysis::EliminateRedundantBoundsChecks() { |
| 1530 if (FLAG_array_bounds_check_elimination) { | 1529 if (FLAG_array_bounds_check_elimination) { |
| 1531 const Function& function = flow_graph_->function(); | 1530 const Function& function = flow_graph_->function(); |
| 1532 // Generalization only if we have not deoptimized on a generalized | 1531 // Generalization only if we have not deoptimized on a generalized |
| 1533 // check earlier, or we're compiling precompiled code (no | 1532 // check earlier, or we're compiling precompiled code (no |
| 1534 // optimistic hoisting of checks possible) | 1533 // optimistic hoisting of checks possible) |
| 1535 const bool try_generalization = | 1534 const bool try_generalization = |
| 1536 function.allows_bounds_check_generalization() && | 1535 function.allows_bounds_check_generalization() && |
| 1537 !FLAG_precompilation; | 1536 !FLAG_precompiled_mode; |
| 1538 | 1537 |
| 1539 BoundsCheckGeneralizer generalizer(this, flow_graph_); | 1538 BoundsCheckGeneralizer generalizer(this, flow_graph_); |
| 1540 | 1539 |
| 1541 for (intptr_t i = 0; i < bounds_checks_.length(); i++) { | 1540 for (intptr_t i = 0; i < bounds_checks_.length(); i++) { |
| 1542 CheckArrayBoundInstr* check = bounds_checks_[i]; | 1541 CheckArrayBoundInstr* check = bounds_checks_[i]; |
| 1543 RangeBoundary array_length = | 1542 RangeBoundary array_length = |
| 1544 RangeBoundary::FromDefinition(check->length()->definition()); | 1543 RangeBoundary::FromDefinition(check->length()->definition()); |
| 1545 if (check->IsRedundant(array_length)) { | 1544 if (check->IsRedundant(array_length)) { |
| 1546 check->RemoveFromGraph(); | 1545 check->RemoveFromGraph(); |
| 1547 } else if (try_generalization) { | 1546 } else if (try_generalization) { |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3158 } | 3157 } |
| 3159 } while (CanonicalizeMaxBoundary(&max) || | 3158 } while (CanonicalizeMaxBoundary(&max) || |
| 3160 CanonicalizeMinBoundary(&canonical_length)); | 3159 CanonicalizeMinBoundary(&canonical_length)); |
| 3161 | 3160 |
| 3162 // Failed to prove that maximum is bounded with array length. | 3161 // Failed to prove that maximum is bounded with array length. |
| 3163 return false; | 3162 return false; |
| 3164 } | 3163 } |
| 3165 | 3164 |
| 3166 | 3165 |
| 3167 } // namespace dart | 3166 } // namespace dart |
| OLD | NEW |