Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1696)

Unified Diff: src/assembler.cc

Issue 532003004: Generalized division via multiplication. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/assembler.h ('k') | src/base/base.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/assembler.cc
diff --git a/src/assembler.cc b/src/assembler.cc
index d2c8bd67772faf846ae1e4f1900be1d369eca68b..3121dab43b3eab251b306eb8dd4f6067a18d494e 100644
--- a/src/assembler.cc
+++ b/src/assembler.cc
@@ -1571,38 +1571,4 @@ bool PositionsRecorder::WriteRecordedPositions() {
return written;
}
-
-MultiplierAndShift::MultiplierAndShift(int32_t d) {
- DCHECK(d <= -2 || 2 <= d);
- const uint32_t two31 = 0x80000000;
- uint32_t ad = Abs(d);
- uint32_t t = two31 + (uint32_t(d) >> 31);
- uint32_t anc = t - 1 - t % ad; // Absolute value of nc.
- int32_t p = 31; // Init. p.
- uint32_t q1 = two31 / anc; // Init. q1 = 2**p/|nc|.
- uint32_t r1 = two31 - q1 * anc; // Init. r1 = rem(2**p, |nc|).
- uint32_t q2 = two31 / ad; // Init. q2 = 2**p/|d|.
- uint32_t r2 = two31 - q2 * ad; // Init. r2 = rem(2**p, |d|).
- uint32_t delta;
- do {
- p++;
- q1 *= 2; // Update q1 = 2**p/|nc|.
- r1 *= 2; // Update r1 = rem(2**p, |nc|).
- if (r1 >= anc) { // Must be an unsigned comparison here.
- q1++;
- r1 = r1 - anc;
- }
- q2 *= 2; // Update q2 = 2**p/|d|.
- r2 *= 2; // Update r2 = rem(2**p, |d|).
- if (r2 >= ad) { // Must be an unsigned comparison here.
- q2++;
- r2 = r2 - ad;
- }
- delta = ad - r2;
- } while (q1 < delta || (q1 == delta && r1 == 0));
- int32_t mul = static_cast<int32_t>(q2 + 1);
- multiplier_ = (d < 0) ? -mul : mul;
- shift_ = p - 32;
-}
-
} } // namespace v8::internal
« no previous file with comments | « src/assembler.h ('k') | src/base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698