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

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

Issue 14862006: Improve performance of String.fromCharCodes by implementing it in Dart. Add tow internal natives to… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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/lib/string_patch.dart » ('j') | runtime/vm/intrinsifier_x64.cc » ('J')
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"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 str = OneByteString::SubStringUnchecked(receiver, 115 str = OneByteString::SubStringUnchecked(receiver,
116 start, 116 start,
117 (i - start), 117 (i - start),
118 Heap::kNew); 118 Heap::kNew);
119 result.Add(str); 119 result.Add(str);
120 return result.raw(); 120 return result.raw();
121 } 121 }
122 122
123 123
124 DEFINE_NATIVE_ENTRY(OneByteString_allocate, 1) {
125 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length_obj, arguments->NativeArgAt(0));
126 return OneByteString::New(length_obj.Value(), Heap::kNew);
127 }
128
129
130 DEFINE_NATIVE_ENTRY(OneByteString_setAt, 3) {
131 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
siva 2013/05/03 23:05:01 May be do a GET_NON_NULL_NATIVE_ARGUMENT(...)
srdjan 2013/05/03 23:36:37 Done.
132 ASSERT(receiver.IsOneByteString());
133 GET_NON_NULL_NATIVE_ARGUMENT(Smi, index_obj, arguments->NativeArgAt(1));
134 GET_NON_NULL_NATIVE_ARGUMENT(Smi, code_point_obj, arguments->NativeArgAt(2));
135 ASSERT((0 <= code_point_obj.Value()) && (code_point_obj.Value() <= 0xFF);
136 OneByteString::SetCharAt(receiver, index_obj.Value(), code_point_obj.Value());
137 return Object::null();
138 }
139
140
124 DEFINE_NATIVE_ENTRY(String_getHashCode, 1) { 141 DEFINE_NATIVE_ENTRY(String_getHashCode, 1) {
125 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); 142 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
126 intptr_t hash_val = receiver.Hash(); 143 intptr_t hash_val = receiver.Hash();
127 ASSERT(hash_val > 0); 144 ASSERT(hash_val > 0);
128 ASSERT(Smi::IsValid(hash_val)); 145 ASSERT(Smi::IsValid(hash_val));
129 return Smi::New(hash_val); 146 return Smi::New(hash_val);
130 } 147 }
131 148
132 149
133 DEFINE_NATIVE_ENTRY(String_getLength, 1) { 150 DEFINE_NATIVE_ENTRY(String_getLength, 1) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) 245 ? String::Handle(OneByteString::New(length_value, Heap::kNew))
229 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); 246 : String::Handle(TwoByteString::New(length_value, Heap::kNew));
230 NoGCScope no_gc; 247 NoGCScope no_gc;
231 248
232 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); 249 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0));
233 String::Copy(result, 0, data_position, length_value); 250 String::Copy(result, 0, data_position, length_value);
234 return result.raw(); 251 return result.raw();
235 } 252 }
236 253
237 } // namespace dart 254 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/string_patch.dart » ('j') | runtime/vm/intrinsifier_x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698