| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 const Integer& value = Integer::CheckedHandle(arguments->NativeArgAt(0)); | 315 const Integer& value = Integer::CheckedHandle(arguments->NativeArgAt(0)); |
| 316 GET_NON_NULL_NATIVE_ARGUMENT(Integer, shift_count, arguments->NativeArgAt(1)); | 316 GET_NON_NULL_NATIVE_ARGUMENT(Integer, shift_count, arguments->NativeArgAt(1)); |
| 317 GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); | 317 GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); |
| 318 ASSERT(CheckInteger(value)); | 318 ASSERT(CheckInteger(value)); |
| 319 ASSERT(CheckInteger(shift_count)); | 319 ASSERT(CheckInteger(shift_count)); |
| 320 ASSERT(CheckInteger(mask)); | 320 ASSERT(CheckInteger(mask)); |
| 321 if (!shift_count.IsSmi()) { | 321 if (!shift_count.IsSmi()) { |
| 322 // Shift count is too large.. | 322 // Shift count is too large.. |
| 323 const Instance& exception = | 323 const Instance& exception = |
| 324 Instance::Handle(isolate->object_store()->out_of_memory()); | 324 Instance::Handle(isolate->object_store()->out_of_memory()); |
| 325 Exceptions::Throw(exception); | 325 Exceptions::Throw(isolate, exception); |
| 326 } | 326 } |
| 327 const Smi& smi_shift_count = Smi::Cast(shift_count); | 327 const Smi& smi_shift_count = Smi::Cast(shift_count); |
| 328 const Integer& shift_result = Integer::Handle( | 328 const Integer& shift_result = Integer::Handle( |
| 329 ShiftOperationHelper(Token::kSHL, value, smi_shift_count, true)); | 329 ShiftOperationHelper(Token::kSHL, value, smi_shift_count, true)); |
| 330 const Integer& result = | 330 const Integer& result = |
| 331 Integer::Handle(shift_result.BitOp(Token::kBIT_AND, mask)); | 331 Integer::Handle(shift_result.BitOp(Token::kBIT_AND, mask)); |
| 332 return result.AsValidInteger(); | 332 return result.AsValidInteger(); |
| 333 } | 333 } |
| 334 | 334 |
| 335 | 335 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 ASSERT(Smi::IsValid(result)); | 407 ASSERT(Smi::IsValid(result)); |
| 408 return Smi::New(result); | 408 return Smi::New(result); |
| 409 } | 409 } |
| 410 | 410 |
| 411 | 411 |
| 412 DEFINE_NATIVE_ENTRY(Mint_shlFromInt, 2) { | 412 DEFINE_NATIVE_ENTRY(Mint_shlFromInt, 2) { |
| 413 // Use the preallocated out of memory exception to avoid calling | 413 // Use the preallocated out of memory exception to avoid calling |
| 414 // into dart code or allocating any code. | 414 // into dart code or allocating any code. |
| 415 const Instance& exception = | 415 const Instance& exception = |
| 416 Instance::Handle(isolate->object_store()->out_of_memory()); | 416 Instance::Handle(isolate->object_store()->out_of_memory()); |
| 417 Exceptions::Throw(exception); | 417 Exceptions::Throw(isolate, exception); |
| 418 UNREACHABLE(); | 418 UNREACHABLE(); |
| 419 return 0; | 419 return 0; |
| 420 } | 420 } |
| 421 | 421 |
| 422 | 422 |
| 423 // Bigint natives. | 423 // Bigint natives. |
| 424 | 424 |
| 425 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { | 425 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { |
| 426 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); | 426 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); |
| 427 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); | 427 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); |
| 428 ASSERT(CheckInteger(value)); | 428 ASSERT(CheckInteger(value)); |
| 429 ASSERT(CheckInteger(result)); | 429 ASSERT(CheckInteger(result)); |
| 430 return result.AsValidInteger(); | 430 return result.AsValidInteger(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 | 433 |
| 434 DEFINE_NATIVE_ENTRY(Bigint_bitLength, 1) { | 434 DEFINE_NATIVE_ENTRY(Bigint_bitLength, 1) { |
| 435 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); | 435 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); |
| 436 return Integer::New(BigintOperations::BitLength(value)); | 436 return Integer::New(BigintOperations::BitLength(value)); |
| 437 } | 437 } |
| 438 | 438 |
| 439 | 439 |
| 440 DEFINE_NATIVE_ENTRY(Bigint_shlFromInt, 2) { | 440 DEFINE_NATIVE_ENTRY(Bigint_shlFromInt, 2) { |
| 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(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 |