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/constant_propagator.h" | 5 #include "vm/constant_propagator.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
10 #include "vm/flow_graph_range_analysis.h" | 10 #include "vm/flow_graph_range_analysis.h" |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 if (constant->value().IsString()) { | 796 if (constant->value().IsString()) { |
797 SetValue(instr, Smi::ZoneHandle(I, | 797 SetValue(instr, Smi::ZoneHandle(I, |
798 Smi::New(String::Cast(constant->value()).Length()))); | 798 Smi::New(String::Cast(constant->value()).Length()))); |
799 return; | 799 return; |
800 } | 800 } |
801 if (constant->value().IsArray()) { | 801 if (constant->value().IsArray()) { |
802 SetValue(instr, Smi::ZoneHandle(I, | 802 SetValue(instr, Smi::ZoneHandle(I, |
803 Smi::New(Array::Cast(constant->value()).Length()))); | 803 Smi::New(Array::Cast(constant->value()).Length()))); |
804 return; | 804 return; |
805 } | 805 } |
| 806 if (constant->value().IsTypedData()) { |
| 807 SetValue(instr, Smi::ZoneHandle(I, |
| 808 Smi::New(TypedData::Cast(constant->value()).Length()))); |
| 809 return; |
| 810 } |
806 } | 811 } |
807 } | 812 } |
808 SetValue(instr, non_constant_); | 813 SetValue(instr, non_constant_); |
809 } | 814 } |
810 | 815 |
811 | 816 |
812 void ConstantPropagator::VisitInstantiateType(InstantiateTypeInstr* instr) { | 817 void ConstantPropagator::VisitInstantiateType(InstantiateTypeInstr* instr) { |
813 const Object& object = | 818 const Object& object = |
814 instr->instantiator()->definition()->constant_value(); | 819 instr->instantiator()->definition()->constant_value(); |
815 if (IsNonConstant(object)) { | 820 if (IsNonConstant(object)) { |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 graph_->ComputeDominators(&dominance_frontier); | 1634 graph_->ComputeDominators(&dominance_frontier); |
1630 | 1635 |
1631 if (FLAG_trace_constant_propagation) { | 1636 if (FLAG_trace_constant_propagation) { |
1632 OS::Print("\n==== After constant propagation ====\n"); | 1637 OS::Print("\n==== After constant propagation ====\n"); |
1633 FlowGraphPrinter printer(*graph_); | 1638 FlowGraphPrinter printer(*graph_); |
1634 printer.PrintBlocks(); | 1639 printer.PrintBlocks(); |
1635 } | 1640 } |
1636 } | 1641 } |
1637 | 1642 |
1638 } // namespace dart | 1643 } // namespace dart |
OLD | NEW |