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

Side by Side Diff: src/runtime/runtime-i18n.cc

Issue 2625073002: Revert of Internalize strings in-place (Closed)
Patch Set: Created 3 years, 11 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 | « src/regexp/regexp-macro-assembler.cc ('k') | src/runtime/runtime-internal.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #ifdef V8_I18N_SUPPORT 6 #ifdef V8_I18N_SUPPORT
7 #include "src/runtime/runtime-utils.h" 7 #include "src/runtime/runtime-utils.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 namespace { 878 namespace {
879 MUST_USE_RESULT Object* LocaleConvertCase(Handle<String> s, Isolate* isolate, 879 MUST_USE_RESULT Object* LocaleConvertCase(Handle<String> s, Isolate* isolate,
880 bool is_to_upper, const char* lang) { 880 bool is_to_upper, const char* lang) {
881 auto case_converter = is_to_upper ? u_strToUpper : u_strToLower; 881 auto case_converter = is_to_upper ? u_strToUpper : u_strToLower;
882 int32_t src_length = s->length(); 882 int32_t src_length = s->length();
883 int32_t dest_length = src_length; 883 int32_t dest_length = src_length;
884 UErrorCode status; 884 UErrorCode status;
885 Handle<SeqTwoByteString> result; 885 Handle<SeqTwoByteString> result;
886 std::unique_ptr<uc16[]> sap; 886 std::unique_ptr<uc16[]> sap;
887 887
888 if (dest_length == 0) return isolate->heap()->empty_string();
889
890 // This is not a real loop. It'll be executed only once (no overflow) or 888 // This is not a real loop. It'll be executed only once (no overflow) or
891 // twice (overflow). 889 // twice (overflow).
892 for (int i = 0; i < 2; ++i) { 890 for (int i = 0; i < 2; ++i) {
893 // Case conversion can increase the string length (e.g. sharp-S => SS) so 891 // Case conversion can increase the string length (e.g. sharp-S => SS) so
894 // that we have to handle RangeError exceptions here. 892 // that we have to handle RangeError exceptions here.
895 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 893 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
896 isolate, result, isolate->factory()->NewRawTwoByteString(dest_length)); 894 isolate, result, isolate->factory()->NewRawTwoByteString(dest_length));
897 DisallowHeapAllocation no_gc; 895 DisallowHeapAllocation no_gc;
898 String::FlatContent flat = s->GetFlatContent(); 896 String::FlatContent flat = s->GetFlatContent();
899 const UChar* src = GetUCharBufferFromFlat(flat, &sap, src_length); 897 const UChar* src = GetUCharBufferFromFlat(flat, &sap, src_length);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 } 1099 }
1102 1100
1103 RUNTIME_FUNCTION(Runtime_StringToUpperCaseI18N) { 1101 RUNTIME_FUNCTION(Runtime_StringToUpperCaseI18N) {
1104 HandleScope scope(isolate); 1102 HandleScope scope(isolate);
1105 DCHECK_EQ(args.length(), 1); 1103 DCHECK_EQ(args.length(), 1);
1106 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); 1104 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
1107 1105
1108 int32_t length = s->length(); 1106 int32_t length = s->length();
1109 s = String::Flatten(s); 1107 s = String::Flatten(s);
1110 1108
1111 if (s->HasOnlyOneByteChars() && length > 0) { 1109 if (s->HasOnlyOneByteChars()) {
1112 Handle<SeqOneByteString> result = 1110 Handle<SeqOneByteString> result =
1113 isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); 1111 isolate->factory()->NewRawOneByteString(length).ToHandleChecked();
1114 1112
1115 int sharp_s_count; 1113 int sharp_s_count;
1116 bool is_result_single_byte; 1114 bool is_result_single_byte;
1117 { 1115 {
1118 DisallowHeapAllocation no_gc; 1116 DisallowHeapAllocation no_gc;
1119 String::FlatContent flat = s->GetFlatContent(); 1117 String::FlatContent flat = s->GetFlatContent();
1120 uint8_t* dest = result->GetChars(); 1118 uint8_t* dest = result->GetChars();
1121 if (flat.IsOneByte()) { 1119 if (flat.IsOneByte()) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 Handle<FixedArray> date_cache_version = 1201 Handle<FixedArray> date_cache_version =
1204 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( 1202 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton(
1205 EternalHandles::DATE_CACHE_VERSION)); 1203 EternalHandles::DATE_CACHE_VERSION));
1206 return date_cache_version->get(0); 1204 return date_cache_version->get(0);
1207 } 1205 }
1208 1206
1209 } // namespace internal 1207 } // namespace internal
1210 } // namespace v8 1208 } // namespace v8
1211 1209
1212 #endif // V8_I18N_SUPPORT 1210 #endif // V8_I18N_SUPPORT
OLDNEW
« no previous file with comments | « src/regexp/regexp-macro-assembler.cc ('k') | src/runtime/runtime-internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698