| 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/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 3790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3801 ConstantInstr* bytes_per_element = | 3801 ConstantInstr* bytes_per_element = |
| 3802 flow_graph()->GetConstant(Smi::Handle(I, Smi::New(element_size))); | 3802 flow_graph()->GetConstant(Smi::Handle(I, Smi::New(element_size))); |
| 3803 BinarySmiOpInstr* len_in_bytes = | 3803 BinarySmiOpInstr* len_in_bytes = |
| 3804 new(I) BinarySmiOpInstr(Token::kMUL, | 3804 new(I) BinarySmiOpInstr(Token::kMUL, |
| 3805 new(I) Value(length), | 3805 new(I) Value(length), |
| 3806 new(I) Value(bytes_per_element), | 3806 new(I) Value(bytes_per_element), |
| 3807 call->deopt_id(), call->token_pos()); | 3807 call->deopt_id(), call->token_pos()); |
| 3808 *cursor = flow_graph()->AppendTo(*cursor, len_in_bytes, call->env(), | 3808 *cursor = flow_graph()->AppendTo(*cursor, len_in_bytes, call->env(), |
| 3809 FlowGraph::kValue); | 3809 FlowGraph::kValue); |
| 3810 | 3810 |
| 3811 ConstantInstr* length_adjustment = | |
| 3812 flow_graph()->GetConstant(Smi::Handle(I, Smi::New( | |
| 3813 Instance::ElementSizeFor(view_cid) - 1))); | |
| 3814 // adjusted_length = len_in_bytes - (element_size - 1). | 3811 // adjusted_length = len_in_bytes - (element_size - 1). |
| 3815 BinarySmiOpInstr* adjusted_length = | 3812 Definition* adjusted_length = len_in_bytes; |
| 3816 new(I) BinarySmiOpInstr(Token::kSUB, | 3813 intptr_t adjustment = Instance::ElementSizeFor(view_cid) - 1; |
| 3817 new(I) Value(len_in_bytes), | 3814 if (adjustment > 0) { |
| 3818 new(I) Value(length_adjustment), | 3815 ConstantInstr* length_adjustment = |
| 3819 call->deopt_id(), call->token_pos()); | 3816 flow_graph()->GetConstant(Smi::Handle(I, Smi::New(adjustment))); |
| 3820 *cursor = flow_graph()->AppendTo(*cursor, adjusted_length, call->env(), | 3817 adjusted_length = |
| 3821 FlowGraph::kValue); | 3818 new(I) BinarySmiOpInstr(Token::kSUB, |
| 3819 new(I) Value(len_in_bytes), |
| 3820 new(I) Value(length_adjustment), |
| 3821 call->deopt_id(), call->token_pos()); |
| 3822 *cursor = flow_graph()->AppendTo(*cursor, adjusted_length, call->env(), |
| 3823 FlowGraph::kValue); |
| 3824 } |
| 3822 | 3825 |
| 3823 // Check adjusted_length > 0. | 3826 // Check adjusted_length > 0. |
| 3824 ConstantInstr* zero = | 3827 ConstantInstr* zero = |
| 3825 flow_graph()->GetConstant(Smi::Handle(I, Smi::New(0))); | 3828 flow_graph()->GetConstant(Smi::Handle(I, Smi::New(0))); |
| 3826 *cursor = flow_graph()->AppendTo(*cursor, | 3829 *cursor = flow_graph()->AppendTo(*cursor, |
| 3827 new(I) CheckArrayBoundInstr( | 3830 new(I) CheckArrayBoundInstr( |
| 3828 new(I) Value(adjusted_length), | 3831 new(I) Value(adjusted_length), |
| 3829 new(I) Value(zero), | 3832 new(I) Value(zero), |
| 3830 call->deopt_id()), | 3833 call->deopt_id()), |
| 3831 call->env(), | 3834 call->env(), |
| (...skipping 5786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9618 | 9621 |
| 9619 // Insert materializations at environment uses. | 9622 // Insert materializations at environment uses. |
| 9620 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 9623 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 9621 CreateMaterializationAt( | 9624 CreateMaterializationAt( |
| 9622 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); | 9625 exits_collector_.exits()[i], alloc, alloc->cls(), *slots); |
| 9623 } | 9626 } |
| 9624 } | 9627 } |
| 9625 | 9628 |
| 9626 | 9629 |
| 9627 } // namespace dart | 9630 } // namespace dart |
| OLD | NEW |