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/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 4031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4042 case Token::kGT: return (result > 0); | 4042 case Token::kGT: return (result > 0); |
4043 case Token::kLTE: return (result <= 0); | 4043 case Token::kLTE: return (result <= 0); |
4044 case Token::kGTE: return (result >= 0); | 4044 case Token::kGTE: return (result >= 0); |
4045 default: | 4045 default: |
4046 UNREACHABLE(); | 4046 UNREACHABLE(); |
4047 return false; | 4047 return false; |
4048 } | 4048 } |
4049 } | 4049 } |
4050 | 4050 |
4051 | 4051 |
| 4052 void ConstantPropagator::VisitTestSmi(TestSmiInstr* instr) { |
| 4053 const Object& left = instr->left()->definition()->constant_value(); |
| 4054 const Object& right = instr->right()->definition()->constant_value(); |
| 4055 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 4056 SetValue(instr, non_constant_); |
| 4057 } else if (IsConstant(left) && IsConstant(right)) { |
| 4058 if (left.IsInteger() && right.IsInteger()) { |
| 4059 const bool result = CompareIntegers( |
| 4060 instr->kind(), |
| 4061 Integer::Handle(Integer::Cast(left).BitOp(Token::kBIT_AND, |
| 4062 Integer::Cast(right))), |
| 4063 Smi::Handle(Smi::New(0))); |
| 4064 SetValue(instr, result ? Bool::True() : Bool::False()); |
| 4065 } else { |
| 4066 SetValue(instr, non_constant_); |
| 4067 } |
| 4068 } |
| 4069 } |
| 4070 |
| 4071 |
4052 void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) { | 4072 void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) { |
4053 const Object& left = instr->left()->definition()->constant_value(); | 4073 const Object& left = instr->left()->definition()->constant_value(); |
4054 const Object& right = instr->right()->definition()->constant_value(); | 4074 const Object& right = instr->right()->definition()->constant_value(); |
4055 if (IsNonConstant(left) || IsNonConstant(right)) { | 4075 if (IsNonConstant(left) || IsNonConstant(right)) { |
4056 SetValue(instr, non_constant_); | 4076 SetValue(instr, non_constant_); |
4057 } else if (IsConstant(left) && IsConstant(right)) { | 4077 } else if (IsConstant(left) && IsConstant(right)) { |
4058 if (left.IsInteger() && right.IsInteger()) { | 4078 if (left.IsInteger() && right.IsInteger()) { |
4059 const bool result = CompareIntegers(instr->kind(), | 4079 const bool result = CompareIntegers(instr->kind(), |
4060 Integer::Cast(left), | 4080 Integer::Cast(left), |
4061 Integer::Cast(right)); | 4081 Integer::Cast(right)); |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5016 if (changed) { | 5036 if (changed) { |
5017 // We may have changed the block order and the dominator tree. | 5037 // We may have changed the block order and the dominator tree. |
5018 flow_graph->DiscoverBlocks(); | 5038 flow_graph->DiscoverBlocks(); |
5019 GrowableArray<BitVector*> dominance_frontier; | 5039 GrowableArray<BitVector*> dominance_frontier; |
5020 flow_graph->ComputeDominators(&dominance_frontier); | 5040 flow_graph->ComputeDominators(&dominance_frontier); |
5021 } | 5041 } |
5022 } | 5042 } |
5023 | 5043 |
5024 | 5044 |
5025 } // namespace dart | 5045 } // namespace dart |
OLD | NEW |