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

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

Issue 10836061: Change the zone allocation api. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « runtime/lib/regexp_jsc.cc ('k') | runtime/tests/vm/vm.status » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/native_entry.h" 8 #include "vm/native_entry.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { 14 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) {
15 GET_NATIVE_ARGUMENT(Array, a, arguments->At(0)); 15 GET_NATIVE_ARGUMENT(Array, a, arguments->At(0));
16 // TODO(srdjan): Check that parameterized type is an int. 16 // TODO(srdjan): Check that parameterized type is an int.
17 Zone* zone = Isolate::Current()->current_zone(); 17 Zone* zone = Isolate::Current()->current_zone();
18 intptr_t len = a.Length(); 18 intptr_t len = a.Length();
19 19
20 // Unbox the array and determine the maximum element width. 20 // Unbox the array and determine the maximum element width.
21 bool is_one_byte_string = true; 21 bool is_one_byte_string = true;
22 bool is_two_byte_string = true; 22 bool is_two_byte_string = true;
23 uint32_t* temp = reinterpret_cast<uint32_t*>( 23 uint32_t* temp = zone->Alloc<uint32_t>(len);
24 zone->Allocate(len * sizeof(uint32_t))); // NOLINT
25 Smi& element = Smi::Handle(); 24 Smi& element = Smi::Handle();
26 for (intptr_t i = 0; i < len; i++) { 25 for (intptr_t i = 0; i < len; i++) {
27 const Object& index_object = Object::Handle(a.At(i)); 26 const Object& index_object = Object::Handle(a.At(i));
28 if (!index_object.IsSmi()) { 27 if (!index_object.IsSmi()) {
29 GrowableArray<const Object*> args; 28 GrowableArray<const Object*> args;
30 args.Add(&index_object); 29 args.Add(&index_object);
31 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 30 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
32 } 31 }
33 element ^= index_object.raw(); 32 element ^= index_object.raw();
34 intptr_t value = element.Value(); 33 intptr_t value = element.Value();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 GrowableArray<const Object*> args; 148 GrowableArray<const Object*> args;
150 args.Add(&elem); 149 args.Add(&elem);
151 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 150 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
152 } 151 }
153 } 152 }
154 const String& result = String::Handle(String::ConcatAll(strings)); 153 const String& result = String::Handle(String::ConcatAll(strings));
155 arguments->SetReturn(result); 154 arguments->SetReturn(result);
156 } 155 }
157 156
158 } // namespace dart 157 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/regexp_jsc.cc ('k') | runtime/tests/vm/vm.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698