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