OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 EnsureSpace ensure_space(assembler_); | 1586 EnsureSpace ensure_space(assembler_); |
1587 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 1587 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
1588 state_.written_position = state_.current_position; | 1588 state_.written_position = state_.current_position; |
1589 written = true; | 1589 written = true; |
1590 } | 1590 } |
1591 | 1591 |
1592 // Return whether something was written. | 1592 // Return whether something was written. |
1593 return written; | 1593 return written; |
1594 } | 1594 } |
1595 | 1595 |
| 1596 |
| 1597 MultiplierAndShift::MultiplierAndShift(int32_t d) { |
| 1598 ASSERT(d <= -2 || 2 <= d); |
| 1599 const uint32_t two31 = 0x80000000; |
| 1600 uint32_t ad = Abs(d); |
| 1601 uint32_t t = two31 + (uint32_t(d) >> 31); |
| 1602 uint32_t anc = t - 1 - t % ad; // Absolute value of nc. |
| 1603 int32_t p = 31; // Init. p. |
| 1604 uint32_t q1 = two31 / anc; // Init. q1 = 2**p/|nc|. |
| 1605 uint32_t r1 = two31 - q1 * anc; // Init. r1 = rem(2**p, |nc|). |
| 1606 uint32_t q2 = two31 / ad; // Init. q2 = 2**p/|d|. |
| 1607 uint32_t r2 = two31 - q2 * ad; // Init. r2 = rem(2**p, |d|). |
| 1608 uint32_t delta; |
| 1609 do { |
| 1610 p++; |
| 1611 q1 *= 2; // Update q1 = 2**p/|nc|. |
| 1612 r1 *= 2; // Update r1 = rem(2**p, |nc|). |
| 1613 if (r1 >= anc) { // Must be an unsigned comparison here. |
| 1614 q1++; |
| 1615 r1 = r1 - anc; |
| 1616 } |
| 1617 q2 *= 2; // Update q2 = 2**p/|d|. |
| 1618 r2 *= 2; // Update r2 = rem(2**p, |d|). |
| 1619 if (r2 >= ad) { // Must be an unsigned comparison here. |
| 1620 q2++; |
| 1621 r2 = r2 - ad; |
| 1622 } |
| 1623 delta = ad - r2; |
| 1624 } while (q1 < delta || (q1 == delta && r1 == 0)); |
| 1625 multiplier_ = (d < 0) ? -(q2 + 1) : (q2 + 1); |
| 1626 shift_ = p - 32; |
| 1627 } |
| 1628 |
1596 } } // namespace v8::internal | 1629 } } // namespace v8::internal |
OLD | NEW |