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

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

Issue 2173423002: Don't throw during a disallow-heap-allocation scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 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
« no previous file with comments | « no previous file | no next file » | 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 "src/api.h" 9 #include "src/api.h"
10 #include "src/api-natives.h" 10 #include "src/api-natives.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 562
563 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); 563 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0);
564 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); 564 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1);
565 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); 565 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2);
566 566
567 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); 567 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder);
568 if (!collator) return isolate->ThrowIllegalOperation(); 568 if (!collator) return isolate->ThrowIllegalOperation();
569 569
570 string1 = String::Flatten(string1); 570 string1 = String::Flatten(string1);
571 string2 = String::Flatten(string2); 571 string2 = String::Flatten(string2);
572 DisallowHeapAllocation no_gc; 572
573 int32_t length1 = string1->length(); 573 UCollationResult result;
574 int32_t length2 = string2->length();
575 String::FlatContent flat1 = string1->GetFlatContent();
576 String::FlatContent flat2 = string2->GetFlatContent();
577 base::SmartArrayPointer<uc16> sap1;
578 base::SmartArrayPointer<uc16> sap2;
579 const UChar* string_val1 = GetUCharBufferFromFlat(flat1, &sap1, length1);
580 const UChar* string_val2 = GetUCharBufferFromFlat(flat2, &sap2, length2);
581 UErrorCode status = U_ZERO_ERROR; 574 UErrorCode status = U_ZERO_ERROR;
582 UCollationResult result = 575 {
583 collator->compare(string_val1, length1, string_val2, length2, status); 576 DisallowHeapAllocation no_gc;
577 int32_t length1 = string1->length();
578 int32_t length2 = string2->length();
579 String::FlatContent flat1 = string1->GetFlatContent();
580 String::FlatContent flat2 = string2->GetFlatContent();
581 base::SmartArrayPointer<uc16> sap1;
582 base::SmartArrayPointer<uc16> sap2;
583 const UChar* string_val1 = GetUCharBufferFromFlat(flat1, &sap1, length1);
584 const UChar* string_val2 = GetUCharBufferFromFlat(flat2, &sap2, length2);
585 result =
586 collator->compare(string_val1, length1, string_val2, length2, status);
587 }
584 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); 588 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation();
585 589
586 return *isolate->factory()->NewNumberFromInt(result); 590 return *isolate->factory()->NewNumberFromInt(result);
587 } 591 }
588 592
589 593
590 RUNTIME_FUNCTION(Runtime_StringNormalize) { 594 RUNTIME_FUNCTION(Runtime_StringNormalize) {
591 HandleScope scope(isolate); 595 HandleScope scope(isolate);
592 static const struct { 596 static const struct {
593 const char* name; 597 const char* name;
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 Handle<FixedArray> date_cache_version = 1149 Handle<FixedArray> date_cache_version =
1146 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( 1150 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton(
1147 EternalHandles::DATE_CACHE_VERSION)); 1151 EternalHandles::DATE_CACHE_VERSION));
1148 return date_cache_version->get(0); 1152 return date_cache_version->get(0);
1149 } 1153 }
1150 1154
1151 } // namespace internal 1155 } // namespace internal
1152 } // namespace v8 1156 } // namespace v8
1153 1157
1154 #endif // V8_I18N_SUPPORT 1158 #endif // V8_I18N_SUPPORT
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698