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

Side by Side Diff: src/assembler.cc

Issue 189963005: Revert "Handle non-power-of-2 divisors in division-like operations", "A64 tweaks for division-like … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/assembler.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 int32_t mul = static_cast<int32_t>(q2 + 1);
1626 multiplier_ = (d < 0) ? -mul : mul;
1627 shift_ = p - 32;
1628 }
1629
1630 } } // namespace v8::internal 1596 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698