Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: runtime/lib/growable_array.cc

Issue 2968003004: Revert "The current growth strategy for growable arrays allocates a backing array of size 2 at (emp… (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/lib/array_patch.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.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 12
13 namespace dart { 13 namespace dart {
14 14
15 DEFINE_NATIVE_ENTRY(GrowableList_allocate, 2) { 15 DEFINE_NATIVE_ENTRY(GrowableList_allocate, 2) {
16 const TypeArguments& type_arguments = 16 const TypeArguments& type_arguments =
17 TypeArguments::CheckedHandle(arguments->NativeArgAt(0)); 17 TypeArguments::CheckedHandle(arguments->NativeArgAt(0));
18 GET_NON_NULL_NATIVE_ARGUMENT(Array, data, arguments->NativeArgAt(1)); 18 GET_NON_NULL_NATIVE_ARGUMENT(Array, data, arguments->NativeArgAt(1));
19 if (data.Length() < 0) { 19 if (data.Length() <= 0) {
20 Exceptions::ThrowRangeError("length", 20 Exceptions::ThrowRangeError("length",
21 Integer::Handle(Integer::New(data.Length())), 21 Integer::Handle(Integer::New(data.Length())),
22 0, // This is the limit the user sees. 22 0, // This is the limit the user sees.
23 Array::kMaxElements); 23 Array::kMaxElements);
24 } 24 }
25 const GrowableObjectArray& new_array = 25 const GrowableObjectArray& new_array =
26 GrowableObjectArray::Handle(GrowableObjectArray::New(data)); 26 GrowableObjectArray::Handle(GrowableObjectArray::New(data));
27 new_array.SetTypeArguments(type_arguments); 27 new_array.SetTypeArguments(type_arguments);
28 return new_array.raw(); 28 return new_array.raw();
29 } 29 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ASSERT((length.Value() >= 0) && (length.Value() <= array.Capacity())); 75 ASSERT((length.Value() >= 0) && (length.Value() <= array.Capacity()));
76 array.SetLength(length.Value()); 76 array.SetLength(length.Value());
77 return Object::null(); 77 return Object::null();
78 } 78 }
79 79
80 80
81 DEFINE_NATIVE_ENTRY(GrowableList_setData, 2) { 81 DEFINE_NATIVE_ENTRY(GrowableList_setData, 2) {
82 const GrowableObjectArray& array = 82 const GrowableObjectArray& array =
83 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); 83 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
84 GET_NON_NULL_NATIVE_ARGUMENT(Array, data, arguments->NativeArgAt(1)); 84 GET_NON_NULL_NATIVE_ARGUMENT(Array, data, arguments->NativeArgAt(1));
85 ASSERT(data.Length() >= 0); 85 ASSERT(data.Length() > 0);
86 array.SetData(data); 86 array.SetData(data);
87 return Object::null(); 87 return Object::null();
88 } 88 }
89 89
90 90
91 DEFINE_NATIVE_ENTRY(Internal_makeListFixedLength, 1) { 91 DEFINE_NATIVE_ENTRY(Internal_makeListFixedLength, 1) {
92 GET_NON_NULL_NATIVE_ARGUMENT(GrowableObjectArray, array, 92 GET_NON_NULL_NATIVE_ARGUMENT(GrowableObjectArray, array,
93 arguments->NativeArgAt(0)); 93 arguments->NativeArgAt(0));
94 return Array::MakeFixedLength(array, /* unique = */ true); 94 return Array::MakeArray(array);
95 } 95 }
96 96
97 97
98 DEFINE_NATIVE_ENTRY(Internal_makeFixedListUnmodifiable, 1) { 98 DEFINE_NATIVE_ENTRY(Internal_makeFixedListUnmodifiable, 1) {
99 GET_NON_NULL_NATIVE_ARGUMENT(Array, array, arguments->NativeArgAt(0)); 99 GET_NON_NULL_NATIVE_ARGUMENT(Array, array, arguments->NativeArgAt(0));
100 array.MakeImmutable(); 100 array.MakeImmutable();
101 return array.raw(); 101 return array.raw();
102 } 102 }
103 103
104 } // namespace dart 104 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/array_patch.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698