| 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/constant_propagator.h" | 8 #include "vm/constant_propagator.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 | 1623 |
| 1624 return false; | 1624 return false; |
| 1625 } | 1625 } |
| 1626 | 1626 |
| 1627 | 1627 |
| 1628 RawInteger* UnaryIntegerOpInstr::Evaluate(const Integer& value) const { | 1628 RawInteger* UnaryIntegerOpInstr::Evaluate(const Integer& value) const { |
| 1629 Integer& result = Integer::Handle(); | 1629 Integer& result = Integer::Handle(); |
| 1630 | 1630 |
| 1631 switch (op_kind()) { | 1631 switch (op_kind()) { |
| 1632 case Token::kNEGATE: | 1632 case Token::kNEGATE: |
| 1633 result = value.ArithmeticOp(Token::kMUL, Smi::Handle(Smi::New(-1))); | 1633 result = value.ArithmeticOp(Token::kMUL, |
| 1634 Smi::Handle(Smi::New(-1)), |
| 1635 Heap::kOld); |
| 1634 break; | 1636 break; |
| 1635 | 1637 |
| 1636 case Token::kBIT_NOT: | 1638 case Token::kBIT_NOT: |
| 1637 if (value.IsSmi()) { | 1639 if (value.IsSmi()) { |
| 1638 result = Integer::New(~Smi::Cast(value).Value()); | 1640 result = Integer::New(~Smi::Cast(value).Value()); |
| 1639 } else if (value.IsMint()) { | 1641 } else if (value.IsMint()) { |
| 1640 result = Integer::New(~Mint::Cast(value).value()); | 1642 result = Integer::New(~Mint::Cast(value).value()); |
| 1641 } | 1643 } |
| 1642 break; | 1644 break; |
| 1643 | 1645 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1668 case Token::kTRUNCDIV: | 1670 case Token::kTRUNCDIV: |
| 1669 case Token::kMOD: | 1671 case Token::kMOD: |
| 1670 // Check right value for zero. | 1672 // Check right value for zero. |
| 1671 if (right.IsSmi() && right.AsInt64Value() == 0) { | 1673 if (right.IsSmi() && right.AsInt64Value() == 0) { |
| 1672 break; // Will throw. | 1674 break; // Will throw. |
| 1673 } | 1675 } |
| 1674 // Fall through. | 1676 // Fall through. |
| 1675 case Token::kADD: | 1677 case Token::kADD: |
| 1676 case Token::kSUB: | 1678 case Token::kSUB: |
| 1677 case Token::kMUL: { | 1679 case Token::kMUL: { |
| 1678 result = left.ArithmeticOp(op_kind(), right); | 1680 result = left.ArithmeticOp(op_kind(), right, Heap::kOld); |
| 1679 break; | 1681 break; |
| 1680 } | 1682 } |
| 1681 case Token::kSHL: | 1683 case Token::kSHL: |
| 1682 case Token::kSHR: | 1684 case Token::kSHR: |
| 1683 if (left.IsSmi() && right.IsSmi() && (Smi::Cast(right).Value() >= 0)) { | 1685 if (left.IsSmi() && right.IsSmi() && (Smi::Cast(right).Value() >= 0)) { |
| 1684 result = Smi::Cast(left).ShiftOp(op_kind(), Smi::Cast(right)); | 1686 result = Smi::Cast(left).ShiftOp(op_kind(), Smi::Cast(right)); |
| 1685 } | 1687 } |
| 1686 break; | 1688 break; |
| 1687 case Token::kBIT_AND: | 1689 case Token::kBIT_AND: |
| 1688 case Token::kBIT_OR: | 1690 case Token::kBIT_OR: |
| (...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3645 case Token::kTRUNCDIV: return 0; | 3647 case Token::kTRUNCDIV: return 0; |
| 3646 case Token::kMOD: return 1; | 3648 case Token::kMOD: return 1; |
| 3647 default: UNIMPLEMENTED(); return -1; | 3649 default: UNIMPLEMENTED(); return -1; |
| 3648 } | 3650 } |
| 3649 } | 3651 } |
| 3650 | 3652 |
| 3651 | 3653 |
| 3652 #undef __ | 3654 #undef __ |
| 3653 | 3655 |
| 3654 } // namespace dart | 3656 } // namespace dart |
| OLD | NEW |