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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 SetValue(instr, non_constant_); | 781 SetValue(instr, non_constant_); |
782 } | 782 } |
783 | 783 |
784 | 784 |
785 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) { | 785 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) { |
786 intptr_t cid = instr->object()->Type()->ToCid(); | 786 intptr_t cid = instr->object()->Type()->ToCid(); |
787 if (cid != kDynamicCid) { | 787 if (cid != kDynamicCid) { |
788 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); | 788 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); |
789 return; | 789 return; |
790 } | 790 } |
791 | |
792 const Object& object = instr->object()->definition()->constant_value(); | 791 const Object& object = instr->object()->definition()->constant_value(); |
793 if (IsConstant(object)) { | 792 if (IsConstant(object)) { |
794 cid = object.GetClassId(); | 793 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(object.GetClassId()))); |
795 if (CheckClassInstr::IsImmutableClassId(cid)) { | 794 return; |
796 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); | |
797 return; | |
798 } | |
799 } | 795 } |
800 SetValue(instr, non_constant_); | 796 SetValue(instr, non_constant_); |
801 } | 797 } |
802 | 798 |
803 | 799 |
804 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) { | 800 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) { |
805 Value* instance = instr->instance(); | 801 Value* instance = instr->instance(); |
806 if ((instr->recognized_kind() == MethodRecognizer::kObjectArrayLength) && | 802 if ((instr->recognized_kind() == MethodRecognizer::kObjectArrayLength) && |
807 instance->definition()->OriginalDefinition()->IsCreateArray()) { | 803 instance->definition()->OriginalDefinition()->IsCreateArray()) { |
808 Value* num_elements = instance->definition()->OriginalDefinition() | 804 Value* num_elements = instance->definition()->OriginalDefinition() |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 graph_->MergeBlocks(); | 1663 graph_->MergeBlocks(); |
1668 GrowableArray<BitVector*> dominance_frontier; | 1664 GrowableArray<BitVector*> dominance_frontier; |
1669 graph_->ComputeDominators(&dominance_frontier); | 1665 graph_->ComputeDominators(&dominance_frontier); |
1670 | 1666 |
1671 if (FLAG_trace_constant_propagation) { | 1667 if (FLAG_trace_constant_propagation) { |
1672 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1668 FlowGraphPrinter::PrintGraph("After CP", graph_); |
1673 } | 1669 } |
1674 } | 1670 } |
1675 | 1671 |
1676 } // namespace dart | 1672 } // namespace dart |
OLD | NEW |