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

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

Issue 18292003: Inline native setters for length and data in the optimizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | runtime/vm/flow_graph_optimizer.cc » ('J')
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"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const GrowableObjectArray& array = 69 const GrowableObjectArray& array =
70 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); 70 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
71 return Smi::New(array.Capacity()); 71 return Smi::New(array.Capacity());
72 } 72 }
73 73
74 74
75 DEFINE_NATIVE_ENTRY(GrowableObjectArray_setLength, 2) { 75 DEFINE_NATIVE_ENTRY(GrowableObjectArray_setLength, 2) {
76 const GrowableObjectArray& array = 76 const GrowableObjectArray& array =
77 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); 77 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
78 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1)); 78 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1));
79 if ((length.Value() < 0) || (length.Value() > array.Capacity())) { 79 ASSERT((length.Value() >= 0) && (length.Value() <= array.Capacity()));
80 const Array& args = Array::Handle(Array::New(1));
81 args.SetAt(0, length);
82 Exceptions::ThrowByType(Exceptions::kRange, args);
83 }
84 array.SetLength(length.Value()); 80 array.SetLength(length.Value());
85 return Object::null(); 81 return Object::null();
86 } 82 }
87 83
88 84
89 DEFINE_NATIVE_ENTRY(GrowableObjectArray_setData, 2) { 85 DEFINE_NATIVE_ENTRY(GrowableObjectArray_setData, 2) {
90 const GrowableObjectArray& array = 86 const GrowableObjectArray& array =
91 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0)); 87 GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
92 GET_NON_NULL_NATIVE_ARGUMENT(Array, data, arguments->NativeArgAt(1)); 88 GET_NON_NULL_NATIVE_ARGUMENT(Array, data, arguments->NativeArgAt(1));
93 ASSERT(data.Length() > 0); 89 ASSERT(data.Length() > 0);
94 array.SetData(data); 90 array.SetData(data);
95 return Object::null(); 91 return Object::null();
96 } 92 }
97 93
98 } // namespace dart 94 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | runtime/vm/flow_graph_optimizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698