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

Side by Side Diff: runtime/vm/bigint_operations.cc

Issue 14845021: Cleanups: addressed your comments from https://codereview.chromium.org/14962008/ (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « runtime/vm/bigint_operations.h ('k') | runtime/vm/bigint_operations_test.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 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 Google Inc. All Rights Reserved.
2 2
3 #include "vm/bigint_operations.h" 3 #include "vm/bigint_operations.h"
4 4
5 #include "platform/utils.h" 5 #include "platform/utils.h"
6 6
7 #include "vm/double_internals.h" 7 #include "vm/double_internals.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/zone.h" 10 #include "vm/zone.h"
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 (biased_exponent << kPhysicalSignificandSize) + significand; 598 (biased_exponent << kPhysicalSignificandSize) + significand;
599 599
600 double value = bit_cast<double>(double_bits); 600 double value = bit_cast<double>(double_bits);
601 if (bigint.IsNegative()) { 601 if (bigint.IsNegative()) {
602 value = -value; 602 value = -value;
603 } 603 }
604 return Double::New(value); 604 return Double::New(value);
605 } 605 }
606 606
607 607
608 bool BigintOperations::FitsIntoMint(const Bigint& bigint) { 608 bool BigintOperations::FitsIntoInt64(const Bigint& bigint) {
609 intptr_t bigint_length = bigint.Length(); 609 intptr_t bigint_length = bigint.Length();
610 if (bigint_length == 0) { 610 if (bigint_length == 0) {
611 return true; 611 return true;
612 } 612 }
613 if ((bigint_length < 3) && 613 if ((bigint_length < 3) &&
614 (static_cast<size_t>(kDigitBitSize) < 614 (static_cast<size_t>(kDigitBitSize) <
615 (sizeof(intptr_t) * kBitsPerByte))) { 615 (sizeof(intptr_t) * kBitsPerByte))) {
616 return true; 616 return true;
617 } 617 }
618 618
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 ASSERT(AbsFitsIntoUint64(bigint)); 656 ASSERT(AbsFitsIntoUint64(bigint));
657 uint64_t value = 0; 657 uint64_t value = 0;
658 for (int i = bigint.Length() - 1; i >= 0; i--) { 658 for (int i = bigint.Length() - 1; i >= 0; i--) {
659 value <<= kDigitBitSize; 659 value <<= kDigitBitSize;
660 value += static_cast<intptr_t>(bigint.GetChunkAt(i)); 660 value += static_cast<intptr_t>(bigint.GetChunkAt(i));
661 } 661 }
662 return value; 662 return value;
663 } 663 }
664 664
665 665
666 int64_t BigintOperations::ToMint(const Bigint& bigint) { 666 int64_t BigintOperations::ToInt64(const Bigint& bigint) {
667 if (bigint.IsZero()) { 667 if (bigint.IsZero()) {
668 return 0; 668 return 0;
669 } 669 }
670 ASSERT(FitsIntoMint(bigint)); 670 ASSERT(FitsIntoInt64(bigint));
671 int64_t value = AbsToUint64(bigint); 671 int64_t value = AbsToUint64(bigint);
672 if (bigint.IsNegative()) { 672 if (bigint.IsNegative()) {
673 value = -value; 673 value = -value;
674 } 674 }
675 return value; 675 return value;
676 } 676 }
677 677
678 678
679 bool BigintOperations::AbsFitsIntoUint64(const Bigint& bigint) { 679 bool BigintOperations::AbsFitsIntoUint64(const Bigint& bigint) {
680 intptr_t b_length = bigint.Length(); 680 intptr_t b_length = bigint.Length();
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 int BigintOperations::CountBits(Chunk digit) { 1665 int BigintOperations::CountBits(Chunk digit) {
1666 int result = 0; 1666 int result = 0;
1667 while (digit != 0) { 1667 while (digit != 0) {
1668 digit >>= 1; 1668 digit >>= 1;
1669 result++; 1669 result++;
1670 } 1670 }
1671 return result; 1671 return result;
1672 } 1672 }
1673 1673
1674 } // namespace dart 1674 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bigint_operations.h ('k') | runtime/vm/bigint_operations_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698