Chromium Code Reviews| 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/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/hash_map.h" | 10 #include "vm/hash_map.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 case kGrowableObjectArrayCid: { | 356 case kGrowableObjectArrayCid: { |
| 357 Value* array = call->ArgumentAt(0)->value(); | 357 Value* array = call->ArgumentAt(0)->value(); |
| 358 Value* index = call->ArgumentAt(1)->value(); | 358 Value* index = call->ArgumentAt(1)->value(); |
| 359 // Insert class check and index smi checks and attach a copy of the | 359 // Insert class check and index smi checks and attach a copy of the |
| 360 // original environment because the operation can still deoptimize. | 360 // original environment because the operation can still deoptimize. |
| 361 AddCheckClass(call, array->Copy()); | 361 AddCheckClass(call, array->Copy()); |
| 362 InsertBefore(call, | 362 InsertBefore(call, |
| 363 new CheckSmiInstr(index->Copy(), call->deopt_id()), | 363 new CheckSmiInstr(index->Copy(), call->deopt_id()), |
| 364 call->env(), | 364 call->env(), |
| 365 Definition::kEffect); | 365 Definition::kEffect); |
| 366 // Insert array bounds check. | 366 // If both index and array are constants, then the bound check always |
| 367 InsertBefore(call, | 367 // succeeded. |
| 368 new CheckArrayBoundInstr(array->Copy(), | 368 if (!(array->BindsToConstant() && index->BindsToConstant())) { |
|
Vyacheslav Egorov (Google)
2012/09/13 09:27:51
Please add todo so that we remove it when constant
srdjan
2012/09/13 09:46:45
Done.
| |
| 369 index->Copy(), | 369 // Insert array bounds check. |
| 370 class_id, | 370 InsertBefore(call, |
| 371 call), | 371 new CheckArrayBoundInstr(array->Copy(), |
| 372 call->env(), | 372 index->Copy(), |
| 373 Definition::kEffect); | 373 class_id, |
| 374 call), | |
| 375 call->env(), | |
| 376 Definition::kEffect); | |
| 377 } | |
| 374 if (class_id == kGrowableObjectArrayCid) { | 378 if (class_id == kGrowableObjectArrayCid) { |
| 375 // Insert data elements load. | 379 // Insert data elements load. |
| 376 LoadFieldInstr* elements = | 380 LoadFieldInstr* elements = |
| 377 new LoadFieldInstr(array->Copy(), | 381 new LoadFieldInstr(array->Copy(), |
| 378 GrowableObjectArray::data_offset(), | 382 GrowableObjectArray::data_offset(), |
| 379 Type::ZoneHandle(Type::DynamicType())); | 383 Type::ZoneHandle(Type::DynamicType())); |
| 380 elements->set_result_cid(kArrayCid); | 384 elements->set_result_cid(kArrayCid); |
| 381 InsertBefore(call, elements, NULL, Definition::kValue); | 385 InsertBefore(call, elements, NULL, Definition::kValue); |
| 382 array = new Value(elements); | 386 array = new Value(elements); |
| 383 } | 387 } |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1567 DirectChainedHashMap<Definition*> child_map(*map); // Copy map. | 1571 DirectChainedHashMap<Definition*> child_map(*map); // Copy map. |
| 1568 OptimizeRecursive(child, &child_map); | 1572 OptimizeRecursive(child, &child_map); |
| 1569 } else { | 1573 } else { |
| 1570 OptimizeRecursive(child, map); // Reuse map for the last child. | 1574 OptimizeRecursive(child, map); // Reuse map for the last child. |
| 1571 } | 1575 } |
| 1572 } | 1576 } |
| 1573 } | 1577 } |
| 1574 | 1578 |
| 1575 | 1579 |
| 1576 } // namespace dart | 1580 } // namespace dart |
| OLD | NEW |