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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 break; | 1161 break; |
1162 default: | 1162 default: |
1163 UNREACHABLE(); | 1163 UNREACHABLE(); |
1164 } | 1164 } |
1165 const Double& result = Double::ZoneHandle(Double::NewCanonical(result_val)); | 1165 const Double& result = Double::ZoneHandle(Double::NewCanonical(result_val)); |
1166 SetValue(instr, result); | 1166 SetValue(instr, result); |
1167 } | 1167 } |
1168 } | 1168 } |
1169 | 1169 |
1170 | 1170 |
| 1171 void ConstantPropagator::VisitDoubleTestOp(DoubleTestOpInstr* instr) { |
| 1172 const Object& value = instr->value()->definition()->constant_value(); |
| 1173 if (value.IsInteger()) { |
| 1174 SetValue(instr, Bool::False()); |
| 1175 } else if (IsIntegerOrDouble(value)) { |
| 1176 switch (instr->op_kind()) { |
| 1177 case MethodRecognizer::kDouble_getIsNaN: |
| 1178 SetValue(instr, Bool::Get(isnan(ToDouble(value)))); |
| 1179 break; |
| 1180 case MethodRecognizer::kDouble_getIsInfinite: |
| 1181 SetValue(instr, Bool::Get(isinf(ToDouble(value)))); |
| 1182 break; |
| 1183 default: |
| 1184 UNREACHABLE(); |
| 1185 } |
| 1186 } else { |
| 1187 SetValue(instr, non_constant_); |
| 1188 } |
| 1189 } |
| 1190 |
| 1191 |
1171 void ConstantPropagator::VisitBinaryFloat32x4Op( | 1192 void ConstantPropagator::VisitBinaryFloat32x4Op( |
1172 BinaryFloat32x4OpInstr* instr) { | 1193 BinaryFloat32x4OpInstr* instr) { |
1173 const Object& left = instr->left()->definition()->constant_value(); | 1194 const Object& left = instr->left()->definition()->constant_value(); |
1174 const Object& right = instr->right()->definition()->constant_value(); | 1195 const Object& right = instr->right()->definition()->constant_value(); |
1175 if (IsNonConstant(left) || IsNonConstant(right)) { | 1196 if (IsNonConstant(left) || IsNonConstant(right)) { |
1176 SetValue(instr, non_constant_); | 1197 SetValue(instr, non_constant_); |
1177 } else if (IsConstant(left) && IsConstant(right)) { | 1198 } else if (IsConstant(left) && IsConstant(right)) { |
1178 // TODO(kmillikin): Handle binary operation. | 1199 // TODO(kmillikin): Handle binary operation. |
1179 SetValue(instr, non_constant_); | 1200 SetValue(instr, non_constant_); |
1180 } | 1201 } |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 GrowableArray<BitVector*> dominance_frontier; | 1710 GrowableArray<BitVector*> dominance_frontier; |
1690 graph_->ComputeDominators(&dominance_frontier); | 1711 graph_->ComputeDominators(&dominance_frontier); |
1691 | 1712 |
1692 if (FLAG_trace_constant_propagation && | 1713 if (FLAG_trace_constant_propagation && |
1693 FlowGraphPrinter::ShouldPrint(graph_->function())) { | 1714 FlowGraphPrinter::ShouldPrint(graph_->function())) { |
1694 FlowGraphPrinter::PrintGraph("After CP", graph_); | 1715 FlowGraphPrinter::PrintGraph("After CP", graph_); |
1695 } | 1716 } |
1696 } | 1717 } |
1697 | 1718 |
1698 } // namespace dart | 1719 } // namespace dart |
OLD | NEW |