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

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

Issue 1016503005: Rename NoGCScope -> NoSafepointScope. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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/base_isolate.h » ('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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 103
104 104
105 // Return the bitwise-or of all characters in the slice from start to end. 105 // Return the bitwise-or of all characters in the slice from start to end.
106 static uint16_t CharacterLimit(const String& string, 106 static uint16_t CharacterLimit(const String& string,
107 intptr_t start, intptr_t end) { 107 intptr_t start, intptr_t end) {
108 ASSERT(string.IsTwoByteString() || string.IsExternalTwoByteString()); 108 ASSERT(string.IsTwoByteString() || string.IsExternalTwoByteString());
109 // Maybe do loop unrolling, and handle two uint16_t in a single uint32_t 109 // Maybe do loop unrolling, and handle two uint16_t in a single uint32_t
110 // operation. 110 // operation.
111 NoGCScope no_gc; 111 NoSafepointScope no_safepoint;
112 uint16_t result = 0; 112 uint16_t result = 0;
113 if (string.IsTwoByteString()) { 113 if (string.IsTwoByteString()) {
114 for (intptr_t i = start; i < end; i++) { 114 for (intptr_t i = start; i < end; i++) {
115 result |= TwoByteString::CharAt(string, i); 115 result |= TwoByteString::CharAt(string, i);
116 } 116 }
117 } else { 117 } else {
118 for (intptr_t i = start; i < end; i++) { 118 for (intptr_t i = start; i < end; i++) {
119 result |= ExternalTwoByteString::CharAt(string, i); 119 result |= ExternalTwoByteString::CharAt(string, i);
120 } 120 }
121 } 121 }
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1)); 599 GET_NON_NULL_NATIVE_ARGUMENT(Smi, length, arguments->NativeArgAt(1));
600 GET_NON_NULL_NATIVE_ARGUMENT(Bool, isLatin1, arguments->NativeArgAt(2)); 600 GET_NON_NULL_NATIVE_ARGUMENT(Bool, isLatin1, arguments->NativeArgAt(2));
601 intptr_t array_length = codeUnits.Length(); 601 intptr_t array_length = codeUnits.Length();
602 intptr_t length_value = length.Value(); 602 intptr_t length_value = length.Value();
603 if (length_value < 0 || length_value > array_length) { 603 if (length_value < 0 || length_value > array_length) {
604 Exceptions::ThrowRangeError("length", length, 0, array_length + 1); 604 Exceptions::ThrowRangeError("length", length, 0, array_length + 1);
605 } 605 }
606 const String& result = isLatin1.value() 606 const String& result = isLatin1.value()
607 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) 607 ? String::Handle(OneByteString::New(length_value, Heap::kNew))
608 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); 608 : String::Handle(TwoByteString::New(length_value, Heap::kNew));
609 NoGCScope no_gc; 609 NoSafepointScope no_safepoint;
610 610
611 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); 611 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0));
612 String::Copy(result, 0, data_position, length_value); 612 String::Copy(result, 0, data_position, length_value);
613 return result.raw(); 613 return result.raw();
614 } 614 }
615 615
616 } // namespace dart 616 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/base_isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698