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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 void ConstantPropagator::VisitRedefinition(RedefinitionInstr* instr) { | 320 void ConstantPropagator::VisitRedefinition(RedefinitionInstr* instr) { |
321 // Ensure that we never remove redefinition of a constant unless we are also | 321 // Ensure that we never remove redefinition of a constant unless we are also |
322 // are guaranteed to fold away code paths that correspond to non-matching | 322 // are guaranteed to fold away code paths that correspond to non-matching |
323 // class ids. Otherwise LICM might potentially hoist incorrect code. | 323 // class ids. Otherwise LICM might potentially hoist incorrect code. |
324 const Object& value = instr->value()->definition()->constant_value(); | 324 const Object& value = instr->value()->definition()->constant_value(); |
325 if (IsConstant(value) && | 325 if (IsConstant(value) && |
326 CheckClassInstr::IsImmutableClassId(value.GetClassId())) { | 326 !Field::IsExternalizableCid(value.GetClassId())) { |
327 SetValue(instr, value); | 327 SetValue(instr, value); |
328 } else { | 328 } else { |
329 SetValue(instr, non_constant_); | 329 SetValue(instr, non_constant_); |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 | 333 |
334 void ConstantPropagator::VisitParameter(ParameterInstr* instr) { | 334 void ConstantPropagator::VisitParameter(ParameterInstr* instr) { |
335 SetValue(instr, non_constant_); | 335 SetValue(instr, non_constant_); |
336 } | 336 } |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) { | 798 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) { |
799 intptr_t cid = instr->object()->Type()->ToCid(); | 799 intptr_t cid = instr->object()->Type()->ToCid(); |
800 if (cid != kDynamicCid) { | 800 if (cid != kDynamicCid) { |
801 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); | 801 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); |
802 return; | 802 return; |
803 } | 803 } |
804 | 804 |
805 const Object& object = instr->object()->definition()->constant_value(); | 805 const Object& object = instr->object()->definition()->constant_value(); |
806 if (IsConstant(object)) { | 806 if (IsConstant(object)) { |
807 cid = object.GetClassId(); | 807 cid = object.GetClassId(); |
808 if (CheckClassInstr::IsImmutableClassId(cid)) { | 808 if (!Field::IsExternalizableCid(cid)) { |
809 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); | 809 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); |
810 return; | 810 return; |
811 } | 811 } |
812 } | 812 } |
813 SetValue(instr, non_constant_); | 813 SetValue(instr, non_constant_); |
814 } | 814 } |
815 | 815 |
816 | 816 |
817 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) { | 817 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) { |
818 Value* instance = instr->instance(); | 818 Value* instance = instr->instance(); |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 graph_->MergeBlocks(); | 1685 graph_->MergeBlocks(); |
1686 GrowableArray<BitVector*> dominance_frontier; | 1686 GrowableArray<BitVector*> dominance_frontier; |
1687 graph_->ComputeDominators(&dominance_frontier); | 1687 graph_->ComputeDominators(&dominance_frontier); |
1688 | 1688 |
1689 if (FLAG_trace_constant_propagation) { | 1689 if (FLAG_trace_constant_propagation) { |
1690 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1690 FlowGraphPrinter::PrintGraph("After CP", graph_); |
1691 } | 1691 } |
1692 } | 1692 } |
1693 | 1693 |
1694 } // namespace dart | 1694 } // namespace dart |
OLD | NEW |