| 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 6401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6412 const Object& left = left_val.definition()->constant_value(); | 6412 const Object& left = left_val.definition()->constant_value(); |
| 6413 const Object& right = right_val.definition()->constant_value(); | 6413 const Object& right = right_val.definition()->constant_value(); |
| 6414 if (IsNonConstant(left) || IsNonConstant(right)) { | 6414 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 6415 // TODO(srdjan): Add arithemtic simplifications, e.g, add with 0. | 6415 // TODO(srdjan): Add arithemtic simplifications, e.g, add with 0. |
| 6416 SetValue(instr, non_constant_); | 6416 SetValue(instr, non_constant_); |
| 6417 } else if (IsConstant(left) && IsConstant(right)) { | 6417 } else if (IsConstant(left) && IsConstant(right)) { |
| 6418 if (left.IsInteger() && right.IsInteger()) { | 6418 if (left.IsInteger() && right.IsInteger()) { |
| 6419 const Integer& left_int = Integer::Cast(left); | 6419 const Integer& left_int = Integer::Cast(left); |
| 6420 const Integer& right_int = Integer::Cast(right); | 6420 const Integer& right_int = Integer::Cast(right); |
| 6421 switch (op_kind) { | 6421 switch (op_kind) { |
| 6422 case Token::kTRUNCDIV: |
| 6423 case Token::kMOD: |
| 6424 // Check right value for zero. |
| 6425 if (right_int.AsInt64Value() == 0) { |
| 6426 SetValue(instr, non_constant_); |
| 6427 break; |
| 6428 } |
| 6429 // Fall through. |
| 6422 case Token::kADD: | 6430 case Token::kADD: |
| 6423 case Token::kSUB: | 6431 case Token::kSUB: |
| 6424 case Token::kMUL: | 6432 case Token::kMUL: { |
| 6425 case Token::kTRUNCDIV: | |
| 6426 case Token::kMOD: { | |
| 6427 Instance& result = Integer::ZoneHandle( | 6433 Instance& result = Integer::ZoneHandle( |
| 6428 left_int.ArithmeticOp(op_kind, right_int)); | 6434 left_int.ArithmeticOp(op_kind, right_int)); |
| 6429 result = result.CheckAndCanonicalize(NULL); | 6435 result = result.CheckAndCanonicalize(NULL); |
| 6430 ASSERT(!result.IsNull()); | 6436 ASSERT(!result.IsNull()); |
| 6431 SetValue(instr, result); | 6437 SetValue(instr, result); |
| 6432 break; | 6438 break; |
| 6433 } | 6439 } |
| 6434 case Token::kSHL: | 6440 case Token::kSHL: |
| 6435 case Token::kSHR: | 6441 case Token::kSHR: |
| 6436 if (left.IsSmi() && right.IsSmi()) { | 6442 if (left.IsSmi() && right.IsSmi()) { |
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7647 } | 7653 } |
| 7648 | 7654 |
| 7649 // Insert materializations at environment uses. | 7655 // Insert materializations at environment uses. |
| 7650 for (intptr_t i = 0; i < exits.length(); i++) { | 7656 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7651 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7657 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7652 } | 7658 } |
| 7653 } | 7659 } |
| 7654 | 7660 |
| 7655 | 7661 |
| 7656 } // namespace dart | 7662 } // namespace dart |
| OLD | NEW |