| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 8 |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 (length_in_bytes / element_size_in_bytes))); | 35 (length_in_bytes / element_size_in_bytes))); |
| 36 const Array& args = Array::Handle(Array::New(1)); | 36 const Array& args = Array::Handle(Array::New(1)); |
| 37 args.SetAt(0, error); | 37 args.SetAt(0, error); |
| 38 Exceptions::ThrowByType(Exceptions::kRange, args); | 38 Exceptions::ThrowByType(Exceptions::kRange, args); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 // Checks to see if a length will not result in an OOM error. | 43 // Checks to see if a length will not result in an OOM error. |
| 44 static void LengthCheck(intptr_t len, intptr_t max) { | 44 static void LengthCheck(intptr_t len, intptr_t max) { |
| 45 ASSERT(len >= 0); | |
| 46 if (len > max) { | 45 if (len > max) { |
| 47 const String& error = String::Handle(String::NewFormatted( | 46 const String& error = String::Handle(String::NewFormatted( |
| 48 "insufficient memory to allocate a TypedData object of length (%"Pd")", | 47 "insufficient memory to allocate a TypedData object of length (%"Pd")", |
| 49 len)); | 48 len)); |
| 50 const Array& args = Array::Handle(Array::New(1)); | 49 const Array& args = Array::Handle(Array::New(1)); |
| 51 args.SetAt(0, error); | 50 args.SetAt(0, error); |
| 52 Exceptions::ThrowByType(Exceptions::kOutOfMemory, args); | 51 Exceptions::ThrowByType(Exceptions::kOutOfMemory, args); |
| 52 } else if (len < 0) { |
| 53 const String& error = String::Handle(String::NewFormatted( |
| 54 "%"Pd" must be greater than 0", len)); |
| 55 const Array& args = Array::Handle(Array::New(1)); |
| 56 args.SetAt(0, error); |
| 57 Exceptions::ThrowByType(Exceptions::kArgument, args); |
| 53 } | 58 } |
| 54 } | 59 } |
| 55 | 60 |
| 56 | 61 |
| 57 static void PeerFinalizer(Dart_Handle handle, void* peer) { | 62 static void PeerFinalizer(Dart_Handle handle, void* peer) { |
| 58 Dart_DeletePersistentHandle(handle); | 63 Dart_DeletePersistentHandle(handle); |
| 59 OS::AlignedFree(peer); | 64 OS::AlignedFree(peer); |
| 60 } | 65 } |
| 61 | 66 |
| 62 | 67 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 value = bit_cast<double>( | 439 value = bit_cast<double>( |
| 435 Utils::HostToLittleEndian64(bit_cast<uint64_t>(value))); | 440 Utils::HostToLittleEndian64(bit_cast<uint64_t>(value))); |
| 436 } else { | 441 } else { |
| 437 value = bit_cast<double>( | 442 value = bit_cast<double>( |
| 438 Utils::HostToBigEndian64(bit_cast<uint64_t>(value))); | 443 Utils::HostToBigEndian64(bit_cast<uint64_t>(value))); |
| 439 } | 444 } |
| 440 return Double::New(value); | 445 return Double::New(value); |
| 441 } | 446 } |
| 442 | 447 |
| 443 } // namespace dart | 448 } // namespace dart |
| OLD | NEW |