| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 const ImmutableArray& constant_array = | 548 const ImmutableArray& constant_array = |
| 549 ImmutableArray::Cast(array_def->value()); | 549 ImmutableArray::Cast(array_def->value()); |
| 550 ConstantInstr* index_def = (*index)->definition()->AsConstant(); | 550 ConstantInstr* index_def = (*index)->definition()->AsConstant(); |
| 551 if (index_def->value().IsSmi()) { | 551 if (index_def->value().IsSmi()) { |
| 552 intptr_t constant_index = Smi::Cast(index_def->value()).Value(); | 552 intptr_t constant_index = Smi::Cast(index_def->value()).Value(); |
| 553 skip_check = (constant_index < constant_array.Length()); | 553 skip_check = (constant_index < constant_array.Length()); |
| 554 } | 554 } |
| 555 } | 555 } |
| 556 if (!skip_check) { | 556 if (!skip_check) { |
| 557 // Insert array length load and bounds check. | 557 // Insert array length load and bounds check. |
| 558 const bool is_immutable = (class_id != kGrowableObjectArrayCid); | 558 const bool is_immutable = |
| 559 CheckArrayBoundInstr::IsFixedLengthArrayType(class_id); |
| 559 LoadFieldInstr* length = new LoadFieldInstr( | 560 LoadFieldInstr* length = new LoadFieldInstr( |
| 560 (*array)->Copy(), | 561 (*array)->Copy(), |
| 561 CheckArrayBoundInstr::LengthOffsetFor(class_id), | 562 CheckArrayBoundInstr::LengthOffsetFor(class_id), |
| 562 Type::ZoneHandle(Type::SmiType()), | 563 Type::ZoneHandle(Type::SmiType()), |
| 563 is_immutable); | 564 is_immutable); |
| 564 length->set_result_cid(kSmiCid); | 565 length->set_result_cid(kSmiCid); |
| 565 length->set_recognized_kind( | 566 length->set_recognized_kind( |
| 566 LoadFieldInstr::RecognizedKindFromArrayCid(class_id)); | 567 LoadFieldInstr::RecognizedKindFromArrayCid(class_id)); |
| 567 InsertBefore(call, length, NULL, Definition::kValue); | 568 InsertBefore(call, length, NULL, Definition::kValue); |
| 568 InsertBefore(call, | 569 InsertBefore(call, |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 switch (recognized_kind) { | 1250 switch (recognized_kind) { |
| 1250 case MethodRecognizer::kObjectArrayLength: | 1251 case MethodRecognizer::kObjectArrayLength: |
| 1251 case MethodRecognizer::kImmutableArrayLength: | 1252 case MethodRecognizer::kImmutableArrayLength: |
| 1252 case MethodRecognizer::kByteArrayBaseLength: | 1253 case MethodRecognizer::kByteArrayBaseLength: |
| 1253 case MethodRecognizer::kGrowableArrayLength: { | 1254 case MethodRecognizer::kGrowableArrayLength: { |
| 1254 if (!ic_data.HasOneTarget()) { | 1255 if (!ic_data.HasOneTarget()) { |
| 1255 // TODO(srdjan): Implement for mutiple targets. | 1256 // TODO(srdjan): Implement for mutiple targets. |
| 1256 return false; | 1257 return false; |
| 1257 } | 1258 } |
| 1258 const bool is_immutable = | 1259 const bool is_immutable = |
| 1259 (recognized_kind != MethodRecognizer::kGrowableArrayLength); | 1260 (recognized_kind == MethodRecognizer::kObjectArrayLength) || |
| 1261 (recognized_kind == MethodRecognizer::kImmutableArrayLength) || |
| 1262 (recognized_kind == MethodRecognizer::kByteArrayBaseLength); |
| 1260 InlineArrayLengthGetter(call, | 1263 InlineArrayLengthGetter(call, |
| 1261 OffsetForLengthGetter(recognized_kind), | 1264 OffsetForLengthGetter(recognized_kind), |
| 1262 is_immutable, | 1265 is_immutable, |
| 1263 recognized_kind); | 1266 recognized_kind); |
| 1264 return true; | 1267 return true; |
| 1265 } | 1268 } |
| 1266 case MethodRecognizer::kGrowableArrayCapacity: | 1269 case MethodRecognizer::kGrowableArrayCapacity: |
| 1267 InlineGrowableArrayCapacityGetter(call); | 1270 InlineGrowableArrayCapacityGetter(call); |
| 1268 return true; | 1271 return true; |
| 1269 case MethodRecognizer::kStringBaseLength: | 1272 case MethodRecognizer::kStringBaseLength: |
| (...skipping 3291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4561 | 4564 |
| 4562 if (FLAG_trace_constant_propagation) { | 4565 if (FLAG_trace_constant_propagation) { |
| 4563 OS::Print("\n==== After constant propagation ====\n"); | 4566 OS::Print("\n==== After constant propagation ====\n"); |
| 4564 FlowGraphPrinter printer(*graph_); | 4567 FlowGraphPrinter printer(*graph_); |
| 4565 printer.PrintBlocks(); | 4568 printer.PrintBlocks(); |
| 4566 } | 4569 } |
| 4567 } | 4570 } |
| 4568 | 4571 |
| 4569 | 4572 |
| 4570 } // namespace dart | 4573 } // namespace dart |
| OLD | NEW |