| 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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 ASSERT(((rep == kUnboxedFloat32x4) && (value_cid == kFloat32x4Cid)) || | 733 ASSERT(((rep == kUnboxedFloat32x4) && (value_cid == kFloat32x4Cid)) || |
| 734 ((rep == kUnboxedInt32x4) && (value_cid == kInt32x4Cid)) || | 734 ((rep == kUnboxedInt32x4) && (value_cid == kInt32x4Cid)) || |
| 735 ((rep == kUnboxedDouble) && (value_cid == kDoubleCid)) || | 735 ((rep == kUnboxedDouble) && (value_cid == kDoubleCid)) || |
| 736 ((rep == kUnboxedMint) && (value_cid == kMintCid))); | 736 ((rep == kUnboxedMint) && (value_cid == kMintCid))); |
| 737 // The representation guarantees the type check to be true. | 737 // The representation guarantees the type check to be true. |
| 738 SetValue(instr, instr->negate_result() ? Bool::False() : Bool::True()); | 738 SetValue(instr, instr->negate_result() ? Bool::False() : Bool::True()); |
| 739 } else { | 739 } else { |
| 740 SetValue(instr, non_constant_); | 740 SetValue(instr, non_constant_); |
| 741 } | 741 } |
| 742 } else if (IsConstant(value)) { | 742 } else if (IsConstant(value)) { |
| 743 // TODO(kmillikin): Handle instanceof on constants. | 743 if (value.IsInstance()) { |
| 744 const Instance& instance = Instance::Cast(value); |
| 745 const AbstractType& checked_type = instr->type(); |
| 746 if (instr->instantiator()->BindsToConstantNull() && |
| 747 instr->instantiator_type_arguments()->BindsToConstantNull()) { |
| 748 const TypeArguments& checked_type_arguments = TypeArguments::Handle(); |
| 749 Error& bound_error = Error::Handle(); |
| 750 bool is_instance = instance.IsInstanceOf(checked_type, |
| 751 checked_type_arguments, |
| 752 &bound_error); |
| 753 // Can only have bound error with generics. |
| 754 ASSERT(bound_error.IsNull()); |
| 755 SetValue(instr, Bool::Get(instr->negate_result() |
| 756 ? !is_instance : is_instance)); |
| 757 return; |
| 758 } |
| 759 } |
| 744 SetValue(instr, non_constant_); | 760 SetValue(instr, non_constant_); |
| 745 } | 761 } |
| 746 } | 762 } |
| 747 | 763 |
| 748 | 764 |
| 749 void ConstantPropagator::VisitCreateArray(CreateArrayInstr* instr) { | 765 void ConstantPropagator::VisitCreateArray(CreateArrayInstr* instr) { |
| 750 SetValue(instr, non_constant_); | 766 SetValue(instr, non_constant_); |
| 751 } | 767 } |
| 752 | 768 |
| 753 | 769 |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 graph_->ComputeDominators(&dominance_frontier); | 1653 graph_->ComputeDominators(&dominance_frontier); |
| 1638 | 1654 |
| 1639 if (FLAG_trace_constant_propagation) { | 1655 if (FLAG_trace_constant_propagation) { |
| 1640 OS::Print("\n==== After constant propagation ====\n"); | 1656 OS::Print("\n==== After constant propagation ====\n"); |
| 1641 FlowGraphPrinter printer(*graph_); | 1657 FlowGraphPrinter printer(*graph_); |
| 1642 printer.PrintBlocks(); | 1658 printer.PrintBlocks(); |
| 1643 } | 1659 } |
| 1644 } | 1660 } |
| 1645 | 1661 |
| 1646 } // namespace dart | 1662 } // namespace dart |
| OLD | NEW |