| 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
| 10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
| 11 #include "vm/object.h" | 11 #include "vm/object.h" |
| 12 #include "vm/symbols.h" | 12 #include "vm/symbols.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 DEFINE_FLAG(bool, trace_intrinsified_natives, false, | 16 DEFINE_FLAG(bool, trace_intrinsified_natives, false, |
| 17 "Report if any of the intrinsified natives are called"); | 17 "Report if any of the intrinsified natives are called"); |
| 18 | 18 |
| 19 // Smi natives. | 19 // Smi natives. |
| 20 | 20 |
| 21 // Returns false if integer is in wrong representation, e.g., as is a Bigint | 21 // Returns false if integer is in wrong representation, e.g., as is a Bigint |
| 22 // when it could have been a Smi. | 22 // when it could have been a Smi. |
| 23 static bool CheckInteger(const Integer& i) { | 23 static bool CheckInteger(const Integer& i) { |
| 24 if (i.IsBigint()) { | 24 if (i.IsBigint()) { |
| 25 const Bigint& bigint = Bigint::Cast(i); | 25 const Bigint& bigint = Bigint::Cast(i); |
| 26 return !BigintOperations::FitsIntoSmi(bigint) && | 26 return !BigintOperations::FitsIntoSmi(bigint) && |
| 27 !BigintOperations::FitsIntoMint(bigint); | 27 !BigintOperations::FitsIntoInt64(bigint); |
| 28 } | 28 } |
| 29 if (i.IsMint()) { | 29 if (i.IsMint()) { |
| 30 const Mint& mint = Mint::Cast(i); | 30 const Mint& mint = Mint::Cast(i); |
| 31 return !Smi::IsValid64(mint.value()); | 31 return !Smi::IsValid64(mint.value()); |
| 32 } | 32 } |
| 33 return true; | 33 return true; |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 DEFINE_NATIVE_ENTRY(Integer_bitAndFromInteger, 2) { | 37 DEFINE_NATIVE_ENTRY(Integer_bitAndFromInteger, 2) { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { | 321 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { |
| 322 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); | 322 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); |
| 323 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); | 323 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); |
| 324 ASSERT(CheckInteger(value)); | 324 ASSERT(CheckInteger(value)); |
| 325 ASSERT(CheckInteger(result)); | 325 ASSERT(CheckInteger(result)); |
| 326 return result.AsValidInteger(); | 326 return result.AsValidInteger(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace dart | 329 } // namespace dart |
| OLD | NEW |