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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // Returns false if integer is in wrong representation, e.g., as is a Bigint | 25 // Returns false if integer is in wrong representation, e.g., as is a Bigint |
26 // when it could have been a Smi. | 26 // when it could have been a Smi. |
27 static bool CheckInteger(const Integer& i) { | 27 static bool CheckInteger(const Integer& i) { |
28 if (i.IsBigint()) { | 28 if (i.IsBigint()) { |
29 const Bigint& bigint = Bigint::Cast(i); | 29 const Bigint& bigint = Bigint::Cast(i); |
30 return !BigintOperations::FitsIntoSmi(bigint) && | 30 return !BigintOperations::FitsIntoSmi(bigint) && |
31 !BigintOperations::FitsIntoInt64(bigint); | 31 !BigintOperations::FitsIntoInt64(bigint); |
32 } | 32 } |
33 if (i.IsMint()) { | 33 if (i.IsMint()) { |
34 const Mint& mint = Mint::Cast(i); | 34 const Mint& mint = Mint::Cast(i); |
35 return !Smi::IsValid64(mint.value()); | 35 return !Smi::IsValid(mint.value()); |
36 } | 36 } |
37 return true; | 37 return true; |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 static int BitLengthInt64(int64_t value) { | 41 static int BitLengthInt64(int64_t value) { |
42 value ^= value >> (8 * sizeof(value) - 1); // flip bits if negative. | 42 value ^= value >> (8 * sizeof(value) - 1); // flip bits if negative. |
43 return value == 0 ? 0 : Utils::HighestBit(value) + 1; | 43 return value == 0 ? 0 : Utils::HighestBit(value) + 1; |
44 } | 44 } |
45 | 45 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // Use the preallocated out of memory exception to avoid calling | 441 // Use the preallocated out of memory exception to avoid calling |
442 // into dart code or allocating any code. | 442 // into dart code or allocating any code. |
443 const Instance& exception = | 443 const Instance& exception = |
444 Instance::Handle(isolate->object_store()->out_of_memory()); | 444 Instance::Handle(isolate->object_store()->out_of_memory()); |
445 Exceptions::Throw(isolate, exception); | 445 Exceptions::Throw(isolate, exception); |
446 UNREACHABLE(); | 446 UNREACHABLE(); |
447 return 0; | 447 return 0; |
448 } | 448 } |
449 | 449 |
450 } // namespace dart | 450 } // namespace dart |
OLD | NEW |