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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 (checked_type.IsInt32x4Type() && (rep == kUnboxedInt32x4)) || | 748 (checked_type.IsInt32x4Type() && (rep == kUnboxedInt32x4)) || |
749 (checked_type.IsDoubleType() && (rep == kUnboxedDouble) && | 749 (checked_type.IsDoubleType() && (rep == kUnboxedDouble) && |
750 FlowGraphCompiler::SupportsUnboxedDoubles()) || | 750 FlowGraphCompiler::SupportsUnboxedDoubles()) || |
751 (checked_type.IsIntType() && (rep == kUnboxedMint))) { | 751 (checked_type.IsIntType() && (rep == kUnboxedMint))) { |
752 // Ensure that compile time type matches representation. | 752 // Ensure that compile time type matches representation. |
753 ASSERT(((rep == kUnboxedFloat32x4) && (value_cid == kFloat32x4Cid)) || | 753 ASSERT(((rep == kUnboxedFloat32x4) && (value_cid == kFloat32x4Cid)) || |
754 ((rep == kUnboxedInt32x4) && (value_cid == kInt32x4Cid)) || | 754 ((rep == kUnboxedInt32x4) && (value_cid == kInt32x4Cid)) || |
755 ((rep == kUnboxedDouble) && (value_cid == kDoubleCid)) || | 755 ((rep == kUnboxedDouble) && (value_cid == kDoubleCid)) || |
756 ((rep == kUnboxedMint) && (value_cid == kMintCid))); | 756 ((rep == kUnboxedMint) && (value_cid == kMintCid))); |
757 // The representation guarantees the type check to be true. | 757 // The representation guarantees the type check to be true. |
758 SetValue(instr, instr->negate_result() ? Bool::False() : Bool::True()); | 758 SetValue(instr, Bool::True()); |
759 } else { | 759 } else { |
760 SetValue(instr, non_constant_); | 760 SetValue(instr, non_constant_); |
761 } | 761 } |
762 } else if (IsConstant(value)) { | 762 } else if (IsConstant(value)) { |
763 if (value.IsInstance()) { | 763 if (value.IsInstance()) { |
764 const Instance& instance = Instance::Cast(value); | 764 const Instance& instance = Instance::Cast(value); |
765 const AbstractType& checked_type = instr->type(); | 765 const AbstractType& checked_type = instr->type(); |
766 if (instr->instantiator_type_arguments()->BindsToConstantNull()) { | 766 if (instr->instantiator_type_arguments()->BindsToConstantNull()) { |
767 const TypeArguments& checked_type_arguments = TypeArguments::Handle(); | 767 const TypeArguments& checked_type_arguments = TypeArguments::Handle(); |
768 Error& bound_error = Error::Handle(); | 768 Error& bound_error = Error::Handle(); |
769 bool is_instance = instance.IsInstanceOf( | 769 bool is_instance = instance.IsInstanceOf( |
770 checked_type, checked_type_arguments, &bound_error); | 770 checked_type, checked_type_arguments, &bound_error); |
771 // Can only have bound error with generics. | 771 // Can only have bound error with generics. |
772 ASSERT(bound_error.IsNull()); | 772 ASSERT(bound_error.IsNull()); |
773 SetValue(instr, Bool::Get(instr->negate_result() ? !is_instance | 773 SetValue(instr, Bool::Get(is_instance)); |
774 : is_instance)); | |
775 return; | 774 return; |
776 } | 775 } |
777 } | 776 } |
778 SetValue(instr, non_constant_); | 777 SetValue(instr, non_constant_); |
779 } | 778 } |
780 } | 779 } |
781 | 780 |
782 | 781 |
783 void ConstantPropagator::VisitCreateArray(CreateArrayInstr* instr) { | 782 void ConstantPropagator::VisitCreateArray(CreateArrayInstr* instr) { |
784 SetValue(instr, non_constant_); | 783 SetValue(instr, non_constant_); |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 GrowableArray<BitVector*> dominance_frontier; | 1712 GrowableArray<BitVector*> dominance_frontier; |
1714 graph_->ComputeDominators(&dominance_frontier); | 1713 graph_->ComputeDominators(&dominance_frontier); |
1715 | 1714 |
1716 if (FLAG_trace_constant_propagation && | 1715 if (FLAG_trace_constant_propagation && |
1717 FlowGraphPrinter::ShouldPrint(graph_->function())) { | 1716 FlowGraphPrinter::ShouldPrint(graph_->function())) { |
1718 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1717 FlowGraphPrinter::PrintGraph("After CP", graph_); |
1719 } | 1718 } |
1720 } | 1719 } |
1721 | 1720 |
1722 } // namespace dart | 1721 } // namespace dart |
OLD | NEW |