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 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 EnsureSpace ensure_space(assembler_); | 1564 EnsureSpace ensure_space(assembler_); |
1565 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 1565 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
1566 state_.written_position = state_.current_position; | 1566 state_.written_position = state_.current_position; |
1567 written = true; | 1567 written = true; |
1568 } | 1568 } |
1569 | 1569 |
1570 // Return whether something was written. | 1570 // Return whether something was written. |
1571 return written; | 1571 return written; |
1572 } | 1572 } |
1573 | 1573 |
1574 | |
1575 MultiplierAndShift::MultiplierAndShift(int32_t d) { | |
1576 DCHECK(d <= -2 || 2 <= d); | |
1577 const uint32_t two31 = 0x80000000; | |
1578 uint32_t ad = Abs(d); | |
1579 uint32_t t = two31 + (uint32_t(d) >> 31); | |
1580 uint32_t anc = t - 1 - t % ad; // Absolute value of nc. | |
1581 int32_t p = 31; // Init. p. | |
1582 uint32_t q1 = two31 / anc; // Init. q1 = 2**p/|nc|. | |
1583 uint32_t r1 = two31 - q1 * anc; // Init. r1 = rem(2**p, |nc|). | |
1584 uint32_t q2 = two31 / ad; // Init. q2 = 2**p/|d|. | |
1585 uint32_t r2 = two31 - q2 * ad; // Init. r2 = rem(2**p, |d|). | |
1586 uint32_t delta; | |
1587 do { | |
1588 p++; | |
1589 q1 *= 2; // Update q1 = 2**p/|nc|. | |
1590 r1 *= 2; // Update r1 = rem(2**p, |nc|). | |
1591 if (r1 >= anc) { // Must be an unsigned comparison here. | |
1592 q1++; | |
1593 r1 = r1 - anc; | |
1594 } | |
1595 q2 *= 2; // Update q2 = 2**p/|d|. | |
1596 r2 *= 2; // Update r2 = rem(2**p, |d|). | |
1597 if (r2 >= ad) { // Must be an unsigned comparison here. | |
1598 q2++; | |
1599 r2 = r2 - ad; | |
1600 } | |
1601 delta = ad - r2; | |
1602 } while (q1 < delta || (q1 == delta && r1 == 0)); | |
1603 int32_t mul = static_cast<int32_t>(q2 + 1); | |
1604 multiplier_ = (d < 0) ? -mul : mul; | |
1605 shift_ = p - 32; | |
1606 } | |
1607 | |
1608 } } // namespace v8::internal | 1574 } } // namespace v8::internal |
OLD | NEW |