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

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

Issue 2613723002: [runtime] Use DCHECK_EQ instead of DCHECK for number of args. (Closed)
Patch Set: Rebase. 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/runtime/runtime-generator.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 // ECMA 402 6.2.3 70 // ECMA 402 6.2.3
71 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) { 71 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
72 HandleScope scope(isolate); 72 HandleScope scope(isolate);
73 Factory* factory = isolate->factory(); 73 Factory* factory = isolate->factory();
74 74
75 DCHECK(args.length() == 1); 75 DCHECK_EQ(1, args.length());
76 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); 76 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0);
77 77
78 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); 78 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str));
79 79
80 // Return value which denotes invalid language tag. 80 // Return value which denotes invalid language tag.
81 // TODO(jshin): Can uloc_{for,to}TanguageTag fail even for structually valid 81 // TODO(jshin): Can uloc_{for,to}TanguageTag fail even for structually valid
82 // language tags? If not, just add CHECK instead of returning 'invalid-tag'. 82 // language tags? If not, just add CHECK instead of returning 'invalid-tag'.
83 const char* const kInvalidTag = "invalid-tag"; 83 const char* const kInvalidTag = "invalid-tag";
84 84
85 UErrorCode error = U_ZERO_ERROR; 85 UErrorCode error = U_ZERO_ERROR;
(...skipping 16 matching lines...) Expand all
102 } 102 }
103 103
104 return *factory->NewStringFromAsciiChecked(result); 104 return *factory->NewStringFromAsciiChecked(result);
105 } 105 }
106 106
107 107
108 RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) { 108 RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) {
109 HandleScope scope(isolate); 109 HandleScope scope(isolate);
110 Factory* factory = isolate->factory(); 110 Factory* factory = isolate->factory();
111 111
112 DCHECK(args.length() == 1); 112 DCHECK_EQ(1, args.length());
113 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); 113 CONVERT_ARG_HANDLE_CHECKED(String, service, 0);
114 114
115 const icu::Locale* available_locales = NULL; 115 const icu::Locale* available_locales = NULL;
116 int32_t count = 0; 116 int32_t count = 0;
117 117
118 if (service->IsUtf8EqualTo(CStrVector("collator"))) { 118 if (service->IsUtf8EqualTo(CStrVector("collator"))) {
119 available_locales = icu::Collator::getAvailableLocales(count); 119 available_locales = icu::Collator::getAvailableLocales(count);
120 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) { 120 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) {
121 available_locales = icu::NumberFormat::getAvailableLocales(count); 121 available_locales = icu::NumberFormat::getAvailableLocales(count);
122 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) { 122 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) {
(...skipping 24 matching lines...) Expand all
147 } 147 }
148 148
149 return *locales; 149 return *locales;
150 } 150 }
151 151
152 152
153 RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) { 153 RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) {
154 HandleScope scope(isolate); 154 HandleScope scope(isolate);
155 Factory* factory = isolate->factory(); 155 Factory* factory = isolate->factory();
156 156
157 DCHECK(args.length() == 0); 157 DCHECK_EQ(0, args.length());
158 158
159 icu::Locale default_locale; 159 icu::Locale default_locale;
160 160
161 // Set the locale 161 // Set the locale
162 char result[ULOC_FULLNAME_CAPACITY]; 162 char result[ULOC_FULLNAME_CAPACITY];
163 UErrorCode status = U_ZERO_ERROR; 163 UErrorCode status = U_ZERO_ERROR;
164 uloc_toLanguageTag(default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, 164 uloc_toLanguageTag(default_locale.getName(), result, ULOC_FULLNAME_CAPACITY,
165 FALSE, &status); 165 FALSE, &status);
166 if (U_SUCCESS(status)) { 166 if (U_SUCCESS(status)) {
167 return *factory->NewStringFromAsciiChecked(result); 167 return *factory->NewStringFromAsciiChecked(result);
168 } 168 }
169 169
170 return *factory->NewStringFromStaticChars("und"); 170 return *factory->NewStringFromStaticChars("und");
171 } 171 }
172 172
173 173
174 RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) { 174 RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) {
175 HandleScope scope(isolate); 175 HandleScope scope(isolate);
176 Factory* factory = isolate->factory(); 176 Factory* factory = isolate->factory();
177 177
178 DCHECK(args.length() == 1); 178 DCHECK_EQ(1, args.length());
179 179
180 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); 180 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0);
181 181
182 uint32_t length = static_cast<uint32_t>(input->length()->Number()); 182 uint32_t length = static_cast<uint32_t>(input->length()->Number());
183 // Set some limit to prevent fuzz tests from going OOM. 183 // Set some limit to prevent fuzz tests from going OOM.
184 // Can be bumped when callers' requirements change. 184 // Can be bumped when callers' requirements change.
185 if (length >= 100) return isolate->ThrowIllegalOperation(); 185 if (length >= 100) return isolate->ThrowIllegalOperation();
186 Handle<FixedArray> output = factory->NewFixedArray(length); 186 Handle<FixedArray> output = factory->NewFixedArray(length);
187 Handle<Name> maximized = factory->NewStringFromStaticChars("maximized"); 187 Handle<Name> maximized = factory->NewStringFromStaticChars("maximized");
188 Handle<Name> base = factory->NewStringFromStaticChars("base"); 188 Handle<Name> base = factory->NewStringFromStaticChars("base");
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 Handle<JSArray> result = factory->NewJSArrayWithElements(output); 253 Handle<JSArray> result = factory->NewJSArrayWithElements(output);
254 result->set_length(Smi::FromInt(length)); 254 result->set_length(Smi::FromInt(length));
255 return *result; 255 return *result;
256 } 256 }
257 257
258 258
259 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) { 259 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) {
260 HandleScope scope(isolate); 260 HandleScope scope(isolate);
261 261
262 DCHECK(args.length() == 1); 262 DCHECK_EQ(1, args.length());
263 263
264 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); 264 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
265 265
266 if (!input->IsJSObject()) return isolate->heap()->false_value(); 266 if (!input->IsJSObject()) return isolate->heap()->false_value();
267 Handle<JSObject> obj = Handle<JSObject>::cast(input); 267 Handle<JSObject> obj = Handle<JSObject>::cast(input);
268 268
269 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); 269 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
270 Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker); 270 Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker);
271 return isolate->heap()->ToBoolean(!tag->IsUndefined(isolate)); 271 return isolate->heap()->ToBoolean(!tag->IsUndefined(isolate));
272 } 272 }
273 273
274 274
275 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { 275 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) {
276 HandleScope scope(isolate); 276 HandleScope scope(isolate);
277 277
278 DCHECK(args.length() == 2); 278 DCHECK_EQ(2, args.length());
279 279
280 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); 280 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
281 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); 281 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1);
282 282
283 if (!input->IsJSObject()) return isolate->heap()->false_value(); 283 if (!input->IsJSObject()) return isolate->heap()->false_value();
284 Handle<JSObject> obj = Handle<JSObject>::cast(input); 284 Handle<JSObject> obj = Handle<JSObject>::cast(input);
285 285
286 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); 286 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
287 Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker); 287 Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker);
288 return isolate->heap()->ToBoolean(tag->IsString() && 288 return isolate->heap()->ToBoolean(tag->IsString() &&
289 String::cast(*tag)->Equals(*expected_type)); 289 String::cast(*tag)->Equals(*expected_type));
290 } 290 }
291 291
292 292
293 RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { 293 RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
294 HandleScope scope(isolate); 294 HandleScope scope(isolate);
295 295
296 DCHECK(args.length() == 3); 296 DCHECK_EQ(3, args.length());
297 297
298 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); 298 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
299 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); 299 CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
300 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); 300 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2);
301 301
302 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); 302 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
303 JSObject::SetProperty(input, marker, type, STRICT).Assert(); 303 JSObject::SetProperty(input, marker, type, STRICT).Assert();
304 304
305 marker = isolate->factory()->intl_impl_object_symbol(); 305 marker = isolate->factory()->intl_impl_object_symbol();
306 JSObject::SetProperty(input, marker, impl, STRICT).Assert(); 306 JSObject::SetProperty(input, marker, impl, STRICT).Assert();
307 307
308 return isolate->heap()->undefined_value(); 308 return isolate->heap()->undefined_value();
309 } 309 }
310 310
311 311
312 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { 312 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) {
313 HandleScope scope(isolate); 313 HandleScope scope(isolate);
314 314
315 DCHECK(args.length() == 1); 315 DCHECK_EQ(1, args.length());
316 316
317 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); 317 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
318 318
319 if (!input->IsJSObject()) { 319 if (!input->IsJSObject()) {
320 THROW_NEW_ERROR_RETURN_FAILURE( 320 THROW_NEW_ERROR_RETURN_FAILURE(
321 isolate, NewTypeError(MessageTemplate::kNotIntlObject, input)); 321 isolate, NewTypeError(MessageTemplate::kNotIntlObject, input));
322 } 322 }
323 323
324 Handle<JSObject> obj = Handle<JSObject>::cast(input); 324 Handle<JSObject> obj = Handle<JSObject>::cast(input);
325 325
326 Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol(); 326 Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol();
327 327
328 Handle<Object> impl = JSReceiver::GetDataProperty(obj, marker); 328 Handle<Object> impl = JSReceiver::GetDataProperty(obj, marker);
329 if (!impl->IsJSObject()) { 329 if (!impl->IsJSObject()) {
330 THROW_NEW_ERROR_RETURN_FAILURE( 330 THROW_NEW_ERROR_RETURN_FAILURE(
331 isolate, NewTypeError(MessageTemplate::kNotIntlObject, obj)); 331 isolate, NewTypeError(MessageTemplate::kNotIntlObject, obj));
332 } 332 }
333 return *impl; 333 return *impl;
334 } 334 }
335 335
336 336
337 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { 337 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
338 HandleScope scope(isolate); 338 HandleScope scope(isolate);
339 339
340 DCHECK(args.length() == 3); 340 DCHECK_EQ(3, args.length());
341 341
342 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 342 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
343 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 343 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
344 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 344 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
345 345
346 Handle<ObjectTemplateInfo> date_format_template = I18N::GetTemplate(isolate); 346 Handle<ObjectTemplateInfo> date_format_template = I18N::GetTemplate(isolate);
347 347
348 // Create an empty object wrapper. 348 // Create an empty object wrapper.
349 Handle<JSObject> local_object; 349 Handle<JSObject> local_object;
350 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 350 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
(...skipping 18 matching lines...) Expand all
369 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), 369 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(),
370 DateFormat::DeleteDateFormat, 370 DateFormat::DeleteDateFormat,
371 WeakCallbackType::kInternalFields); 371 WeakCallbackType::kInternalFields);
372 return *local_object; 372 return *local_object;
373 } 373 }
374 374
375 375
376 RUNTIME_FUNCTION(Runtime_InternalDateFormat) { 376 RUNTIME_FUNCTION(Runtime_InternalDateFormat) {
377 HandleScope scope(isolate); 377 HandleScope scope(isolate);
378 378
379 DCHECK(args.length() == 2); 379 DCHECK_EQ(2, args.length());
380 380
381 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); 381 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
382 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); 382 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
383 383
384 Handle<Object> value; 384 Handle<Object> value;
385 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date)); 385 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date));
386 386
387 icu::SimpleDateFormat* date_format = 387 icu::SimpleDateFormat* date_format =
388 DateFormat::UnpackDateFormat(isolate, date_format_holder); 388 DateFormat::UnpackDateFormat(isolate, date_format_holder);
389 if (!date_format) return isolate->ThrowIllegalOperation(); 389 if (!date_format) return isolate->ThrowIllegalOperation();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 isolate, JSObject::AddDataElement(array, index, element, NONE), false); 470 isolate, JSObject::AddDataElement(array, index, element, NONE), false);
471 return true; 471 return true;
472 } 472 }
473 473
474 } // namespace 474 } // namespace
475 475
476 RUNTIME_FUNCTION(Runtime_InternalDateFormatToParts) { 476 RUNTIME_FUNCTION(Runtime_InternalDateFormatToParts) {
477 HandleScope scope(isolate); 477 HandleScope scope(isolate);
478 Factory* factory = isolate->factory(); 478 Factory* factory = isolate->factory();
479 479
480 DCHECK(args.length() == 2); 480 DCHECK_EQ(2, args.length());
481 481
482 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); 482 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
483 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); 483 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
484 484
485 Handle<Object> value; 485 Handle<Object> value;
486 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date)); 486 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(date));
487 487
488 icu::SimpleDateFormat* date_format = 488 icu::SimpleDateFormat* date_format =
489 DateFormat::UnpackDateFormat(isolate, date_format_holder); 489 DateFormat::UnpackDateFormat(isolate, date_format_holder);
490 if (!date_format) return isolate->ThrowIllegalOperation(); 490 if (!date_format) return isolate->ThrowIllegalOperation();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return isolate->heap()->undefined_value(); 526 return isolate->heap()->undefined_value();
527 } 527 }
528 } 528 }
529 JSObject::ValidateElements(result); 529 JSObject::ValidateElements(result);
530 return *result; 530 return *result;
531 } 531 }
532 532
533 RUNTIME_FUNCTION(Runtime_CreateNumberFormat) { 533 RUNTIME_FUNCTION(Runtime_CreateNumberFormat) {
534 HandleScope scope(isolate); 534 HandleScope scope(isolate);
535 535
536 DCHECK(args.length() == 3); 536 DCHECK_EQ(3, args.length());
537 537
538 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 538 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
539 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 539 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
540 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 540 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
541 541
542 Handle<ObjectTemplateInfo> number_format_template = 542 Handle<ObjectTemplateInfo> number_format_template =
543 I18N::GetTemplate(isolate); 543 I18N::GetTemplate(isolate);
544 544
545 // Create an empty object wrapper. 545 // Create an empty object wrapper.
546 Handle<JSObject> local_object; 546 Handle<JSObject> local_object;
(...skipping 18 matching lines...) Expand all
565 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), 565 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(),
566 NumberFormat::DeleteNumberFormat, 566 NumberFormat::DeleteNumberFormat,
567 WeakCallbackType::kInternalFields); 567 WeakCallbackType::kInternalFields);
568 return *local_object; 568 return *local_object;
569 } 569 }
570 570
571 571
572 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { 572 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) {
573 HandleScope scope(isolate); 573 HandleScope scope(isolate);
574 574
575 DCHECK(args.length() == 2); 575 DCHECK_EQ(2, args.length());
576 576
577 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); 577 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
578 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); 578 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
579 579
580 Handle<Object> value; 580 Handle<Object> value;
581 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(number)); 581 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, Object::ToNumber(number));
582 582
583 icu::DecimalFormat* number_format = 583 icu::DecimalFormat* number_format =
584 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); 584 NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
585 if (!number_format) return isolate->ThrowIllegalOperation(); 585 if (!number_format) return isolate->ThrowIllegalOperation();
586 586
587 icu::UnicodeString result; 587 icu::UnicodeString result;
588 number_format->format(value->Number(), result); 588 number_format->format(value->Number(), result);
589 589
590 RETURN_RESULT_OR_FAILURE( 590 RETURN_RESULT_OR_FAILURE(
591 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( 591 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
592 reinterpret_cast<const uint16_t*>(result.getBuffer()), 592 reinterpret_cast<const uint16_t*>(result.getBuffer()),
593 result.length()))); 593 result.length())));
594 } 594 }
595 595
596 596
597 RUNTIME_FUNCTION(Runtime_CreateCollator) { 597 RUNTIME_FUNCTION(Runtime_CreateCollator) {
598 HandleScope scope(isolate); 598 HandleScope scope(isolate);
599 599
600 DCHECK(args.length() == 3); 600 DCHECK_EQ(3, args.length());
601 601
602 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 602 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
603 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 603 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
604 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 604 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
605 605
606 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); 606 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate);
607 607
608 // Create an empty object wrapper. 608 // Create an empty object wrapper.
609 Handle<JSObject> local_object; 609 Handle<JSObject> local_object;
610 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 610 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
(...skipping 16 matching lines...) Expand all
627 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), 627 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(),
628 Collator::DeleteCollator, 628 Collator::DeleteCollator,
629 WeakCallbackType::kInternalFields); 629 WeakCallbackType::kInternalFields);
630 return *local_object; 630 return *local_object;
631 } 631 }
632 632
633 633
634 RUNTIME_FUNCTION(Runtime_InternalCompare) { 634 RUNTIME_FUNCTION(Runtime_InternalCompare) {
635 HandleScope scope(isolate); 635 HandleScope scope(isolate);
636 636
637 DCHECK(args.length() == 3); 637 DCHECK_EQ(3, args.length());
638 638
639 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); 639 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0);
640 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); 640 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1);
641 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); 641 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2);
642 642
643 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); 643 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder);
644 if (!collator) return isolate->ThrowIllegalOperation(); 644 if (!collator) return isolate->ThrowIllegalOperation();
645 645
646 string1 = String::Flatten(string1); 646 string1 = String::Flatten(string1);
647 string2 = String::Flatten(string2); 647 string2 = String::Flatten(string2);
(...skipping 24 matching lines...) Expand all
672 static const struct { 672 static const struct {
673 const char* name; 673 const char* name;
674 UNormalization2Mode mode; 674 UNormalization2Mode mode;
675 } normalizationForms[] = { 675 } normalizationForms[] = {
676 {"nfc", UNORM2_COMPOSE}, 676 {"nfc", UNORM2_COMPOSE},
677 {"nfc", UNORM2_DECOMPOSE}, 677 {"nfc", UNORM2_DECOMPOSE},
678 {"nfkc", UNORM2_COMPOSE}, 678 {"nfkc", UNORM2_COMPOSE},
679 {"nfkc", UNORM2_DECOMPOSE}, 679 {"nfkc", UNORM2_DECOMPOSE},
680 }; 680 };
681 681
682 DCHECK(args.length() == 2); 682 DCHECK_EQ(2, args.length());
683 683
684 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); 684 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
685 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); 685 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]);
686 CHECK(form_id >= 0 && 686 CHECK(form_id >= 0 &&
687 static_cast<size_t>(form_id) < arraysize(normalizationForms)); 687 static_cast<size_t>(form_id) < arraysize(normalizationForms));
688 688
689 int length = s->length(); 689 int length = s->length();
690 s = String::Flatten(s); 690 s = String::Flatten(s);
691 icu::UnicodeString result; 691 icu::UnicodeString result;
692 std::unique_ptr<uc16[]> sap; 692 std::unique_ptr<uc16[]> sap;
(...skipping 28 matching lines...) Expand all
721 RETURN_RESULT_OR_FAILURE( 721 RETURN_RESULT_OR_FAILURE(
722 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( 722 isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
723 reinterpret_cast<const uint16_t*>(result.getBuffer()), 723 reinterpret_cast<const uint16_t*>(result.getBuffer()),
724 result.length()))); 724 result.length())));
725 } 725 }
726 726
727 727
728 RUNTIME_FUNCTION(Runtime_CreateBreakIterator) { 728 RUNTIME_FUNCTION(Runtime_CreateBreakIterator) {
729 HandleScope scope(isolate); 729 HandleScope scope(isolate);
730 730
731 DCHECK(args.length() == 3); 731 DCHECK_EQ(3, args.length());
732 732
733 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 733 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
734 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 734 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
735 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 735 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
736 736
737 Handle<ObjectTemplateInfo> break_iterator_template = 737 Handle<ObjectTemplateInfo> break_iterator_template =
738 I18N::GetTemplate2(isolate); 738 I18N::GetTemplate2(isolate);
739 739
740 // Create an empty object wrapper. 740 // Create an empty object wrapper.
741 Handle<JSObject> local_object; 741 Handle<JSObject> local_object;
(...skipping 22 matching lines...) Expand all
764 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(), 764 GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(),
765 BreakIterator::DeleteBreakIterator, 765 BreakIterator::DeleteBreakIterator,
766 WeakCallbackType::kInternalFields); 766 WeakCallbackType::kInternalFields);
767 return *local_object; 767 return *local_object;
768 } 768 }
769 769
770 770
771 RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { 771 RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) {
772 HandleScope scope(isolate); 772 HandleScope scope(isolate);
773 773
774 DCHECK(args.length() == 2); 774 DCHECK_EQ(2, args.length());
775 775
776 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); 776 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
777 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); 777 CONVERT_ARG_HANDLE_CHECKED(String, text, 1);
778 778
779 icu::BreakIterator* break_iterator = 779 icu::BreakIterator* break_iterator =
780 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); 780 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
781 if (!break_iterator) return isolate->ThrowIllegalOperation(); 781 if (!break_iterator) return isolate->ThrowIllegalOperation();
782 782
783 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( 783 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>(
784 break_iterator_holder->GetInternalField(1)); 784 break_iterator_holder->GetInternalField(1));
(...skipping 10 matching lines...) Expand all
795 795
796 break_iterator->setText(*u_text); 796 break_iterator->setText(*u_text);
797 797
798 return isolate->heap()->undefined_value(); 798 return isolate->heap()->undefined_value();
799 } 799 }
800 800
801 801
802 RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { 802 RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) {
803 HandleScope scope(isolate); 803 HandleScope scope(isolate);
804 804
805 DCHECK(args.length() == 1); 805 DCHECK_EQ(1, args.length());
806 806
807 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); 807 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
808 808
809 icu::BreakIterator* break_iterator = 809 icu::BreakIterator* break_iterator =
810 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); 810 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
811 if (!break_iterator) return isolate->ThrowIllegalOperation(); 811 if (!break_iterator) return isolate->ThrowIllegalOperation();
812 812
813 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); 813 return *isolate->factory()->NewNumberFromInt(break_iterator->first());
814 } 814 }
815 815
816 816
817 RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { 817 RUNTIME_FUNCTION(Runtime_BreakIteratorNext) {
818 HandleScope scope(isolate); 818 HandleScope scope(isolate);
819 819
820 DCHECK(args.length() == 1); 820 DCHECK_EQ(1, args.length());
821 821
822 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); 822 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
823 823
824 icu::BreakIterator* break_iterator = 824 icu::BreakIterator* break_iterator =
825 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); 825 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
826 if (!break_iterator) return isolate->ThrowIllegalOperation(); 826 if (!break_iterator) return isolate->ThrowIllegalOperation();
827 827
828 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); 828 return *isolate->factory()->NewNumberFromInt(break_iterator->next());
829 } 829 }
830 830
831 831
832 RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { 832 RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) {
833 HandleScope scope(isolate); 833 HandleScope scope(isolate);
834 834
835 DCHECK(args.length() == 1); 835 DCHECK_EQ(1, args.length());
836 836
837 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); 837 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
838 838
839 icu::BreakIterator* break_iterator = 839 icu::BreakIterator* break_iterator =
840 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); 840 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
841 if (!break_iterator) return isolate->ThrowIllegalOperation(); 841 if (!break_iterator) return isolate->ThrowIllegalOperation();
842 842
843 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); 843 return *isolate->factory()->NewNumberFromInt(break_iterator->current());
844 } 844 }
845 845
846 846
847 RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { 847 RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) {
848 HandleScope scope(isolate); 848 HandleScope scope(isolate);
849 849
850 DCHECK(args.length() == 1); 850 DCHECK_EQ(1, args.length());
851 851
852 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); 852 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
853 853
854 icu::BreakIterator* break_iterator = 854 icu::BreakIterator* break_iterator =
855 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); 855 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
856 if (!break_iterator) return isolate->ThrowIllegalOperation(); 856 if (!break_iterator) return isolate->ThrowIllegalOperation();
857 857
858 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. 858 // TODO(cira): Remove cast once ICU fixes base BreakIterator class.
859 icu::RuleBasedBreakIterator* rule_based_iterator = 859 icu::RuleBasedBreakIterator* rule_based_iterator =
860 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); 860 static_cast<icu::RuleBasedBreakIterator*>(break_iterator);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 Handle<FixedArray> date_cache_version = 1201 Handle<FixedArray> date_cache_version =
1202 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( 1202 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton(
1203 EternalHandles::DATE_CACHE_VERSION)); 1203 EternalHandles::DATE_CACHE_VERSION));
1204 return date_cache_version->get(0); 1204 return date_cache_version->get(0);
1205 } 1205 }
1206 1206
1207 } // namespace internal 1207 } // namespace internal
1208 } // namespace v8 1208 } // namespace v8
1209 1209
1210 #endif // V8_I18N_SUPPORT 1210 #endif // V8_I18N_SUPPORT
OLDNEW
« no previous file with comments | « src/runtime/runtime-generator.cc ('k') | src/runtime/runtime-internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698