| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 } else { | 1804 } else { |
| 1805 return HValue::InferRange(zone); | 1805 return HValue::InferRange(zone); |
| 1806 } | 1806 } |
| 1807 } | 1807 } |
| 1808 | 1808 |
| 1809 | 1809 |
| 1810 Range* HMod::InferRange(Zone* zone) { | 1810 Range* HMod::InferRange(Zone* zone) { |
| 1811 if (representation().IsInteger32()) { | 1811 if (representation().IsInteger32()) { |
| 1812 Range* a = left()->range(); | 1812 Range* a = left()->range(); |
| 1813 Range* b = right()->range(); | 1813 Range* b = right()->range(); |
| 1814 Range* result = new(zone) Range(); | 1814 |
| 1815 if (a->CanBeMinusZero() || a->CanBeNegative()) { | 1815 // The magnitude of the modulus is bounded by the right operand. Note that |
| 1816 // apart for the cases involving kMinInt, the calculation below is the same |
| 1817 // as Max(Abs(b->lower()), Abs(b->upper())) - 1. |
| 1818 int32_t positive_bound = -(Min(NegAbs(b->lower()), NegAbs(b->upper())) + 1); |
| 1819 |
| 1820 // The result of the modulo operation has the sign of its left operand. |
| 1821 bool left_can_be_negative = a->CanBeMinusZero() || a->CanBeNegative(); |
| 1822 Range* result = new(zone) Range(left_can_be_negative ? -positive_bound : 0, |
| 1823 a->CanBePositive() ? positive_bound : 0); |
| 1824 |
| 1825 if (left_can_be_negative) { |
| 1816 result->set_can_be_minus_zero(true); | 1826 result->set_can_be_minus_zero(true); |
| 1817 } | 1827 } |
| 1818 | 1828 |
| 1819 if (!a->Includes(kMinInt) || !b->Includes(-1)) { | 1829 if (!a->Includes(kMinInt) || !b->Includes(-1)) { |
| 1820 ClearFlag(HValue::kCanOverflow); | 1830 ClearFlag(HValue::kCanOverflow); |
| 1821 } | 1831 } |
| 1822 | 1832 |
| 1823 if (!b->CanBeZero()) { | 1833 if (!b->CanBeZero()) { |
| 1824 ClearFlag(HValue::kCanBeDivByZero); | 1834 ClearFlag(HValue::kCanBeDivByZero); |
| 1825 } | 1835 } |
| (...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3796 case kBackingStore: | 3806 case kBackingStore: |
| 3797 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3807 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3798 stream->Add("[backing-store]"); | 3808 stream->Add("[backing-store]"); |
| 3799 break; | 3809 break; |
| 3800 } | 3810 } |
| 3801 | 3811 |
| 3802 stream->Add("@%d", offset()); | 3812 stream->Add("@%d", offset()); |
| 3803 } | 3813 } |
| 3804 | 3814 |
| 3805 } } // namespace v8::internal | 3815 } } // namespace v8::internal |
| OLD | NEW |