| 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/code_generator.h" | 5 #include "vm/code_generator.h" | 
| 6 | 6 | 
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" | 
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" | 
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" | 
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 106 // Return value: newly allocated array of length arg0. | 106 // Return value: newly allocated array of length arg0. | 
| 107 DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { | 107 DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { | 
| 108   const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0)); | 108   const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0)); | 
| 109   if (!length.IsSmi()) { | 109   if (!length.IsSmi()) { | 
| 110     const String& error = String::Handle(String::NewFormatted( | 110     const String& error = String::Handle(String::NewFormatted( | 
| 111         "Length must be an integer in the range [0..%" Pd "].", | 111         "Length must be an integer in the range [0..%" Pd "].", | 
| 112         Array::kMaxElements)); | 112         Array::kMaxElements)); | 
| 113     Exceptions::ThrowArgumentError(error); | 113     Exceptions::ThrowArgumentError(error); | 
| 114   } | 114   } | 
| 115   const intptr_t len = Smi::Cast(length).Value(); | 115   const intptr_t len = Smi::Cast(length).Value(); | 
| 116   if (len < 0) { | 116   if ((len < 0) || (len > Array::kMaxElements)) { | 
| 117     const String& error = String::Handle(String::NewFormatted( | 117     const String& error = String::Handle(String::NewFormatted( | 
| 118         "Length (%" Pd ") must be an integer in the range [0..%" Pd "].", | 118         "Length (%" Pd ") must be an integer in the range [0..%" Pd "].", | 
| 119         len, Array::kMaxElements)); | 119         len, Array::kMaxElements)); | 
| 120     Exceptions::ThrowArgumentError(error); | 120     Exceptions::ThrowArgumentError(error); | 
| 121   } | 121   } | 
| 122 | 122 | 
| 123   Heap::Space space = isolate->heap()->SpaceForAllocation(kArrayCid); | 123   Heap::Space space = isolate->heap()->SpaceForAllocation(kArrayCid); | 
| 124   const Array& array = Array::Handle(Array::New(len, space)); | 124   const Array& array = Array::Handle(Array::New(len, space)); | 
| 125   arguments.SetReturn(array); | 125   arguments.SetReturn(array); | 
| 126   TypeArguments& element_type = | 126   TypeArguments& element_type = | 
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1677   const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1677   const intptr_t elm_size = old_data.ElementSizeInBytes(); | 
| 1678   const TypedData& new_data = | 1678   const TypedData& new_data = | 
| 1679       TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1679       TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 
| 1680   TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1680   TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 
| 1681   typed_data_cell.SetAt(0, new_data); | 1681   typed_data_cell.SetAt(0, new_data); | 
| 1682   arguments.SetReturn(new_data); | 1682   arguments.SetReturn(new_data); | 
| 1683 } | 1683 } | 
| 1684 | 1684 | 
| 1685 | 1685 | 
| 1686 }  // namespace dart | 1686 }  // namespace dart | 
| OLD | NEW | 
|---|