| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/bigint_operations.h" | 5 #include "vm/bigint_operations.h" |
| 6 | 6 |
| 7 #include <openssl/crypto.h> | 7 #include <openssl/crypto.h> |
| 8 | 8 |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 #include "vm/bigint_store.h" | 10 #include "vm/bigint_store.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 const char* BigintOperations::ToHexCString(const Bigint& bigint, | 241 const char* BigintOperations::ToHexCString(const Bigint& bigint, |
| 242 uword (*allocator)(intptr_t size)) { | 242 uword (*allocator)(intptr_t size)) { |
| 243 return ToHexCString(bigint.BNAddr(), allocator); | 243 return ToHexCString(bigint.BNAddr(), allocator); |
| 244 } | 244 } |
| 245 | 245 |
| 246 | 246 |
| 247 bool BigintOperations::FitsIntoSmi(const Bigint& bigint) { | 247 bool BigintOperations::FitsIntoSmi(const Bigint& bigint) { |
| 248 ASSERT(!bigint.IsNull()); |
| 248 const BIGNUM *bn = bigint.BNAddr(); | 249 const BIGNUM *bn = bigint.BNAddr(); |
| 249 int bits = BN_num_bits(bn); | 250 int bits = BN_num_bits(bn); |
| 250 // Special case for kMinValue as the absolute value is 1 bit longer | 251 // Special case for kMinValue as the absolute value is 1 bit longer |
| 251 // than anything else | 252 // than anything else |
| 252 if (bits == Smi::kBits + 1 && BN_abs_is_word(bn, -Smi::kMinValue) | 253 if (bits == Smi::kBits + 1 && BN_abs_is_word(bn, -Smi::kMinValue) |
| 253 && bigint.IsNegative()) { | 254 && bigint.IsNegative()) { |
| 254 return true; | 255 return true; |
| 255 } | 256 } |
| 256 // All other cases must have no more bits than the size of an Smi | 257 // All other cases must have no more bits than the size of an Smi |
| 257 if (bits > Smi::kBits) { | 258 if (bits > Smi::kBits) { |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 result.ToggleSign(); | 628 result.ToggleSign(); |
| 628 return result.raw(); | 629 return result.raw(); |
| 629 } | 630 } |
| 630 | 631 |
| 631 | 632 |
| 632 int BigintOperations::Compare(const Bigint& a, const Bigint& b) { | 633 int BigintOperations::Compare(const Bigint& a, const Bigint& b) { |
| 633 return BN_cmp(a.BNAddr(), b.BNAddr()); | 634 return BN_cmp(a.BNAddr(), b.BNAddr()); |
| 634 } | 635 } |
| 635 | 636 |
| 636 } // namespace dart | 637 } // namespace dart |
| OLD | NEW |