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 { |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 // At this point we know that 0 <= index < UpperBound(index) under | 1075 // At this point we know that 0 <= index < UpperBound(index) under |
1076 // certain preconditions. Start by emitting this preconditions. | 1076 // certain preconditions. Start by emitting this preconditions. |
1077 scheduler_.Start(); | 1077 scheduler_.Start(); |
1078 | 1078 |
1079 ConstantInstr* max_smi = | 1079 ConstantInstr* max_smi = |
1080 flow_graph_->GetConstant(Smi::Handle(Smi::New(Smi::kMaxValue))); | 1080 flow_graph_->GetConstant(Smi::Handle(Smi::New(Smi::kMaxValue))); |
1081 for (intptr_t i = 0; i < non_positive_symbols.length(); i++) { | 1081 for (intptr_t i = 0; i < non_positive_symbols.length(); i++) { |
1082 CheckArrayBoundInstr* precondition = new CheckArrayBoundInstr( | 1082 CheckArrayBoundInstr* precondition = new CheckArrayBoundInstr( |
1083 new Value(max_smi), | 1083 new Value(max_smi), |
1084 new Value(non_positive_symbols[i]), | 1084 new Value(non_positive_symbols[i]), |
1085 Isolate::kNoDeoptId); | 1085 Thread::kNoDeoptId); |
1086 precondition->mark_generalized(); | 1086 precondition->mark_generalized(); |
1087 precondition = scheduler_.Emit(precondition, check); | 1087 precondition = scheduler_.Emit(precondition, check); |
1088 if (precondition == NULL) { | 1088 if (precondition == NULL) { |
1089 if (FLAG_trace_range_analysis) { | 1089 if (FLAG_trace_range_analysis) { |
1090 THR_Print(" => failed to insert positivity constraint\n"); | 1090 THR_Print(" => failed to insert positivity constraint\n"); |
1091 } | 1091 } |
1092 scheduler_.Rollback(); | 1092 scheduler_.Rollback(); |
1093 return; | 1093 return; |
1094 } | 1094 } |
1095 } | 1095 } |
1096 | 1096 |
1097 CheckArrayBoundInstr* new_check = new CheckArrayBoundInstr( | 1097 CheckArrayBoundInstr* new_check = new CheckArrayBoundInstr( |
1098 new Value(UnwrapConstraint(check->length()->definition())), | 1098 new Value(UnwrapConstraint(check->length()->definition())), |
1099 new Value(upper_bound), | 1099 new Value(upper_bound), |
1100 Isolate::kNoDeoptId); | 1100 Thread::kNoDeoptId); |
1101 new_check->mark_generalized(); | 1101 new_check->mark_generalized(); |
1102 if (new_check->IsRedundant(array_length)) { | 1102 if (new_check->IsRedundant(array_length)) { |
1103 if (FLAG_trace_range_analysis) { | 1103 if (FLAG_trace_range_analysis) { |
1104 THR_Print(" => generalized check is redundant\n"); | 1104 THR_Print(" => generalized check is redundant\n"); |
1105 } | 1105 } |
1106 RemoveGeneralizedCheck(check); | 1106 RemoveGeneralizedCheck(check); |
1107 return; | 1107 return; |
1108 } | 1108 } |
1109 | 1109 |
1110 new_check = scheduler_.Emit(new_check, check); | 1110 new_check = scheduler_.Emit(new_check, check); |
(...skipping 20 matching lines...) Expand all Loading... |
1131 check->RemoveFromGraph(); | 1131 check->RemoveFromGraph(); |
1132 } | 1132 } |
1133 | 1133 |
1134 private: | 1134 private: |
1135 BinarySmiOpInstr* MakeBinaryOp(Token::Kind op_kind, | 1135 BinarySmiOpInstr* MakeBinaryOp(Token::Kind op_kind, |
1136 Definition* left, | 1136 Definition* left, |
1137 Definition* right) { | 1137 Definition* right) { |
1138 return new BinarySmiOpInstr(op_kind, | 1138 return new BinarySmiOpInstr(op_kind, |
1139 new Value(left), | 1139 new Value(left), |
1140 new Value(right), | 1140 new Value(right), |
1141 Isolate::kNoDeoptId); | 1141 Thread::kNoDeoptId); |
1142 } | 1142 } |
1143 | 1143 |
1144 | 1144 |
1145 BinarySmiOpInstr* MakeBinaryOp(Token::Kind op_kind, | 1145 BinarySmiOpInstr* MakeBinaryOp(Token::Kind op_kind, |
1146 Definition* left, | 1146 Definition* left, |
1147 intptr_t right) { | 1147 intptr_t right) { |
1148 ConstantInstr* constant_right = | 1148 ConstantInstr* constant_right = |
1149 flow_graph_->GetConstant(Smi::Handle(Smi::New(right))); | 1149 flow_graph_->GetConstant(Smi::Handle(Smi::New(right))); |
1150 return MakeBinaryOp(op_kind, left, constant_right); | 1150 return MakeBinaryOp(op_kind, left, constant_right); |
1151 } | 1151 } |
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3160 } | 3160 } |
3161 } while (CanonicalizeMaxBoundary(&max) || | 3161 } while (CanonicalizeMaxBoundary(&max) || |
3162 CanonicalizeMinBoundary(&canonical_length)); | 3162 CanonicalizeMinBoundary(&canonical_length)); |
3163 | 3163 |
3164 // Failed to prove that maximum is bounded with array length. | 3164 // Failed to prove that maximum is bounded with array length. |
3165 return false; | 3165 return false; |
3166 } | 3166 } |
3167 | 3167 |
3168 | 3168 |
3169 } // namespace dart | 3169 } // namespace dart |
OLD | NEW |