OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 27 matching lines...) Expand all Loading... |
38 bigits_[i] = 0; | 38 bigits_[i] = 0; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 template<typename S> | 43 template<typename S> |
44 static int BitSize(S value) { | 44 static int BitSize(S value) { |
45 return 8 * sizeof(value); | 45 return 8 * sizeof(value); |
46 } | 46 } |
47 | 47 |
| 48 |
48 // Guaranteed to lie in one Bigit. | 49 // Guaranteed to lie in one Bigit. |
49 void Bignum::AssignUInt16(uint16_t value) { | 50 void Bignum::AssignUInt16(uint16_t value) { |
50 ASSERT(kBigitSize >= BitSize(value)); | 51 ASSERT(kBigitSize >= BitSize(value)); |
51 Zero(); | 52 Zero(); |
52 if (value == 0) return; | 53 if (value == 0) return; |
53 | 54 |
54 EnsureCapacity(1); | 55 EnsureCapacity(1); |
55 bigits_[0] = value; | 56 bigits_[0] = value; |
56 used_digits_ = 1; | 57 used_digits_ = 1; |
57 } | 58 } |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 Chunk difference = bigits_[i] - borrow; | 766 Chunk difference = bigits_[i] - borrow; |
766 bigits_[i] = difference & kBigitMask; | 767 bigits_[i] = difference & kBigitMask; |
767 borrow = difference >> (kChunkSize - 1); | 768 borrow = difference >> (kChunkSize - 1); |
768 } | 769 } |
769 Clamp(); | 770 Clamp(); |
770 ASSERT(Bignum::Equal(a, *this)); | 771 ASSERT(Bignum::Equal(a, *this)); |
771 } | 772 } |
772 | 773 |
773 | 774 |
774 } } // namespace v8::internal | 775 } } // namespace v8::internal |
OLD | NEW |