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

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

Issue 88983004: Support Bigint parameters in Int32x4 constructor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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/object.h » ('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/assert.h" 5 #include "platform/assert.h"
6 #include "platform/utils.h" 6 #include "platform/utils.h"
7 7
8 #include "vm/double_internals.h" 8 #include "vm/double_internals.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } 686 }
687 ASSERT(FitsIntoInt64(bigint)); 687 ASSERT(FitsIntoInt64(bigint));
688 int64_t value = AbsToUint64(bigint); 688 int64_t value = AbsToUint64(bigint);
689 if (bigint.IsNegative()) { 689 if (bigint.IsNegative()) {
690 value = -value; 690 value = -value;
691 } 691 }
692 return value; 692 return value;
693 } 693 }
694 694
695 695
696 uint32_t BigintOperations::TruncateToUint32(const Bigint& bigint) {
697 uint32_t value = 0;
698 for (intptr_t i = bigint.Length() - 1; i >= 0; i--) {
699 value <<= kDigitBitSize;
700 value += static_cast<uint32_t>(bigint.GetChunkAt(i));
701 }
702 return value;
703 }
704
705
696 bool BigintOperations::AbsFitsIntoUint64(const Bigint& bigint) { 706 bool BigintOperations::AbsFitsIntoUint64(const Bigint& bigint) {
697 intptr_t b_length = bigint.Length(); 707 intptr_t b_length = bigint.Length();
698 intptr_t num_bits = CountBits(bigint.GetChunkAt(b_length - 1)); 708 intptr_t num_bits = CountBits(bigint.GetChunkAt(b_length - 1));
699 num_bits += (kDigitBitSize * (b_length - 1)); 709 num_bits += (kDigitBitSize * (b_length - 1));
700 if (num_bits > 64) return false; 710 if (num_bits > 64) return false;
701 return true; 711 return true;
702 } 712 }
703 713
704 714
705 bool BigintOperations::FitsIntoUint64(const Bigint& bigint) { 715 bool BigintOperations::FitsIntoUint64(const Bigint& bigint) {
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 intptr_t BigintOperations::CountBits(Chunk digit) { 1808 intptr_t BigintOperations::CountBits(Chunk digit) {
1799 intptr_t result = 0; 1809 intptr_t result = 0;
1800 while (digit != 0) { 1810 while (digit != 0) {
1801 digit >>= 1; 1811 digit >>= 1;
1802 result++; 1812 result++;
1803 } 1813 }
1804 return result; 1814 return result;
1805 } 1815 }
1806 1816
1807 } // namespace dart 1817 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bigint_operations.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698