Chromium Code Reviews| 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2642 intptr_t element_size = FlowGraphCompiler::ElementSizeFor(receiver_cid); | 2642 intptr_t element_size = FlowGraphCompiler::ElementSizeFor(receiver_cid); |
| 2643 ConstantInstr* bytes_per_element = | 2643 ConstantInstr* bytes_per_element = |
| 2644 flow_graph()->GetConstant(Smi::Handle(Smi::New(element_size))); | 2644 flow_graph()->GetConstant(Smi::Handle(Smi::New(element_size))); |
| 2645 BinarySmiOpInstr* len_in_bytes = | 2645 BinarySmiOpInstr* len_in_bytes = |
| 2646 new BinarySmiOpInstr(Token::kMUL, | 2646 new BinarySmiOpInstr(Token::kMUL, |
| 2647 new Value(length), | 2647 new Value(length), |
| 2648 new Value(bytes_per_element), | 2648 new Value(bytes_per_element), |
| 2649 call->deopt_id()); | 2649 call->deopt_id()); |
| 2650 InsertBefore(call, len_in_bytes, call->env(), Definition::kValue); | 2650 InsertBefore(call, len_in_bytes, call->env(), Definition::kValue); |
| 2651 | 2651 |
| 2652 // Check byte_index < len_in_bytes. | 2652 // Check byte_index + num_bytes < len_in_bytes. |
|
Ivan Posva
2013/09/20 17:20:30
Where is the check that byte_index is positive?
siva
2013/09/20 22:03:45
We have been using the name 'element_size_in_bytes
Florian Schneider
2013/09/23 11:02:26
Changed to access_size.
Florian Schneider
2013/09/23 11:02:26
Good catch. Changed into two checks using CheckArr
| |
| 2653 ConstantInstr* num_bytes = | |
| 2654 flow_graph()->GetConstant(Smi::Handle(Smi::New( | |
| 2655 FlowGraphCompiler::ElementSizeFor(view_cid) - 1))); | |
| 2656 BinarySmiOpInstr* adjusted_index = | |
| 2657 new BinarySmiOpInstr(Token::kADD, | |
| 2658 new Value(byte_index), | |
| 2659 new Value(num_bytes), | |
| 2660 call->deopt_id()); | |
| 2661 InsertBefore(call, adjusted_index, call->env(), Definition::kValue); | |
| 2653 InsertBefore(call, | 2662 InsertBefore(call, |
| 2654 new CheckArrayBoundInstr(new Value(len_in_bytes), | 2663 new CheckArrayBoundInstr(new Value(len_in_bytes), |
| 2655 new Value(byte_index), | 2664 new Value(adjusted_index), |
| 2656 call->deopt_id()), | 2665 call->deopt_id()), |
| 2657 call->env(), | 2666 call->env(), |
| 2658 Definition::kEffect); | 2667 Definition::kEffect); |
| 2659 | 2668 |
| 2660 // Insert load of elements for external typed arrays. | 2669 // Insert load of elements for external typed arrays. |
| 2661 if (RawObject::IsExternalTypedDataClassId(receiver_cid)) { | 2670 if (RawObject::IsExternalTypedDataClassId(receiver_cid)) { |
| 2662 LoadUntaggedInstr* elements = | 2671 LoadUntaggedInstr* elements = |
| 2663 new LoadUntaggedInstr(new Value(*array), | 2672 new LoadUntaggedInstr(new Value(*array), |
| 2664 ExternalTypedData::data_offset()); | 2673 ExternalTypedData::data_offset()); |
| 2665 InsertBefore(call, elements, NULL, Definition::kValue); | 2674 InsertBefore(call, elements, NULL, Definition::kValue); |
| (...skipping 5005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7671 } | 7680 } |
| 7672 | 7681 |
| 7673 // Insert materializations at environment uses. | 7682 // Insert materializations at environment uses. |
| 7674 for (intptr_t i = 0; i < exits.length(); i++) { | 7683 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7675 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7684 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7676 } | 7685 } |
| 7677 } | 7686 } |
| 7678 | 7687 |
| 7679 | 7688 |
| 7680 } // namespace dart | 7689 } // namespace dart |
| OLD | NEW |