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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 SetValue(instr, non_constant_); | 1013 SetValue(instr, non_constant_); |
1014 } | 1014 } |
1015 } | 1015 } |
1016 | 1016 |
1017 | 1017 |
1018 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { | 1018 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { |
1019 const Object& value = instr->value()->definition()->constant_value(); | 1019 const Object& value = instr->value()->definition()->constant_value(); |
1020 if (IsConstant(value) && value.IsInteger()) { | 1020 if (IsConstant(value) && value.IsInteger()) { |
1021 SetValue(instr, Double::Handle(I, | 1021 SetValue(instr, Double::Handle(I, |
1022 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); | 1022 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); |
1023 } else if (IsNonConstant(value)) { | 1023 } else if (!IsUnknown(value)) { |
1024 SetValue(instr, non_constant_); | 1024 SetValue(instr, non_constant_); |
1025 } | 1025 } |
1026 } | 1026 } |
1027 | 1027 |
1028 | 1028 |
1029 void ConstantPropagator::VisitMintToDouble(MintToDoubleInstr* instr) { | 1029 void ConstantPropagator::VisitMintToDouble(MintToDoubleInstr* instr) { |
1030 const Object& value = instr->value()->definition()->constant_value(); | 1030 const Object& value = instr->value()->definition()->constant_value(); |
1031 if (IsConstant(value) && value.IsInteger()) { | 1031 if (IsConstant(value) && value.IsInteger()) { |
1032 SetValue(instr, Double::Handle(I, | 1032 SetValue(instr, Double::Handle(I, |
1033 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); | 1033 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); |
1034 } else if (IsNonConstant(value)) { | 1034 } else if (!IsUnknown(value)) { |
1035 SetValue(instr, non_constant_); | 1035 SetValue(instr, non_constant_); |
1036 } | 1036 } |
1037 } | 1037 } |
1038 | 1038 |
1039 | 1039 |
1040 void ConstantPropagator::VisitInt32ToDouble(Int32ToDoubleInstr* instr) { | 1040 void ConstantPropagator::VisitInt32ToDouble(Int32ToDoubleInstr* instr) { |
1041 const Object& value = instr->value()->definition()->constant_value(); | 1041 const Object& value = instr->value()->definition()->constant_value(); |
1042 if (IsConstant(value) && value.IsInteger()) { | 1042 if (IsConstant(value) && value.IsInteger()) { |
1043 SetValue(instr, Double::Handle(I, | 1043 SetValue(instr, Double::Handle(I, |
1044 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); | 1044 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); |
1045 } else if (IsNonConstant(value)) { | 1045 } else if (!IsUnknown(value)) { |
1046 SetValue(instr, non_constant_); | 1046 SetValue(instr, non_constant_); |
1047 } | 1047 } |
1048 } | 1048 } |
1049 | 1049 |
1050 | 1050 |
1051 void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) { | 1051 void ConstantPropagator::VisitDoubleToInteger(DoubleToIntegerInstr* instr) { |
1052 // TODO(kmillikin): Handle conversion. | 1052 // TODO(kmillikin): Handle conversion. |
1053 SetValue(instr, non_constant_); | 1053 SetValue(instr, non_constant_); |
1054 } | 1054 } |
1055 | 1055 |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 graph_->MergeBlocks(); | 1679 graph_->MergeBlocks(); |
1680 GrowableArray<BitVector*> dominance_frontier; | 1680 GrowableArray<BitVector*> dominance_frontier; |
1681 graph_->ComputeDominators(&dominance_frontier); | 1681 graph_->ComputeDominators(&dominance_frontier); |
1682 | 1682 |
1683 if (FLAG_trace_constant_propagation) { | 1683 if (FLAG_trace_constant_propagation) { |
1684 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1684 FlowGraphPrinter::PrintGraph("After CP", graph_); |
1685 } | 1685 } |
1686 } | 1686 } |
1687 | 1687 |
1688 } // namespace dart | 1688 } // namespace dart |
OLD | NEW |