| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // Array index (uint32). | 308 // Array index (uint32). |
| 309 maybe_result = JSObject::SetOwnElement( | 309 maybe_result = JSObject::SetOwnElement( |
| 310 boilerplate, element_index, value, SLOPPY); | 310 boilerplate, element_index, value, SLOPPY); |
| 311 } else { | 311 } else { |
| 312 // Non-uint32 number. | 312 // Non-uint32 number. |
| 313 ASSERT(key->IsNumber()); | 313 ASSERT(key->IsNumber()); |
| 314 double num = key->Number(); | 314 double num = key->Number(); |
| 315 char arr[100]; | 315 char arr[100]; |
| 316 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 316 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 317 const char* str = DoubleToCString(num, buffer); | 317 const char* str = DoubleToCString(num, buffer); |
| 318 Handle<String> name = | 318 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); |
| 319 isolate->factory()->NewStringFromAscii(CStrVector(str)); | |
| 320 maybe_result = JSObject::SetLocalPropertyIgnoreAttributes( | 319 maybe_result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 321 boilerplate, name, value, NONE, | 320 boilerplate, name, value, NONE, |
| 322 Object::OPTIMAL_REPRESENTATION, mode); | 321 Object::OPTIMAL_REPRESENTATION, mode); |
| 323 } | 322 } |
| 324 // If setting the property on the boilerplate throws an | 323 // If setting the property on the boilerplate throws an |
| 325 // exception, the exception is converted to an empty handle in | 324 // exception, the exception is converted to an empty handle in |
| 326 // the handle based operations. In that case, we need to | 325 // the handle based operations. In that case, we need to |
| 327 // convert back to an exception. | 326 // convert back to an exception. |
| 328 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); | 327 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); |
| 329 } | 328 } |
| (...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); | 2017 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
| 2019 } | 2018 } |
| 2020 | 2019 |
| 2021 | 2020 |
| 2022 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { | 2021 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { |
| 2023 HandleScope scope(isolate); | 2022 HandleScope scope(isolate); |
| 2024 ASSERT(args.length() == 3); | 2023 ASSERT(args.length() == 3); |
| 2025 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); | 2024 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); |
| 2026 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 2025 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
| 2027 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); | 2026 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); |
| 2028 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); | 2027 Handle<Object> result; |
| 2029 RETURN_IF_EMPTY_HANDLE(isolate, result); | 2028 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2029 isolate, result, RegExpImpl::Compile(re, pattern, flags)); |
| 2030 return *result; | 2030 return *result; |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 | 2033 |
| 2034 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { | 2034 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { |
| 2035 HandleScope scope(isolate); | 2035 HandleScope scope(isolate); |
| 2036 ASSERT(args.length() == 1); | 2036 ASSERT(args.length() == 1); |
| 2037 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); | 2037 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); |
| 2038 return *isolate->factory()->CreateApiFunction(data); | 2038 return *isolate->factory()->CreateApiFunction(data); |
| 2039 } | 2039 } |
| (...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4794 if (std::isnan(value)) { | 4794 if (std::isnan(value)) { |
| 4795 return isolate->heap()->nan_string(); | 4795 return isolate->heap()->nan_string(); |
| 4796 } | 4796 } |
| 4797 if (std::isinf(value)) { | 4797 if (std::isinf(value)) { |
| 4798 if (value < 0) { | 4798 if (value < 0) { |
| 4799 return isolate->heap()->minus_infinity_string(); | 4799 return isolate->heap()->minus_infinity_string(); |
| 4800 } | 4800 } |
| 4801 return isolate->heap()->infinity_string(); | 4801 return isolate->heap()->infinity_string(); |
| 4802 } | 4802 } |
| 4803 char* str = DoubleToRadixCString(value, radix); | 4803 char* str = DoubleToRadixCString(value, radix); |
| 4804 Handle<String> result = | 4804 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4805 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | |
| 4806 DeleteArray(str); | 4805 DeleteArray(str); |
| 4807 return *result; | 4806 return *result; |
| 4808 } | 4807 } |
| 4809 | 4808 |
| 4810 | 4809 |
| 4811 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { | 4810 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { |
| 4812 HandleScope scope(isolate); | 4811 HandleScope scope(isolate); |
| 4813 ASSERT(args.length() == 2); | 4812 ASSERT(args.length() == 2); |
| 4814 | 4813 |
| 4815 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4814 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4816 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4815 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4817 int f = FastD2IChecked(f_number); | 4816 int f = FastD2IChecked(f_number); |
| 4818 RUNTIME_ASSERT(f >= 0); | 4817 RUNTIME_ASSERT(f >= 0); |
| 4819 char* str = DoubleToFixedCString(value, f); | 4818 char* str = DoubleToFixedCString(value, f); |
| 4820 Handle<String> result = | 4819 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4821 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | |
| 4822 DeleteArray(str); | 4820 DeleteArray(str); |
| 4823 return *result; | 4821 return *result; |
| 4824 } | 4822 } |
| 4825 | 4823 |
| 4826 | 4824 |
| 4827 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 4825 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { |
| 4828 HandleScope scope(isolate); | 4826 HandleScope scope(isolate); |
| 4829 ASSERT(args.length() == 2); | 4827 ASSERT(args.length() == 2); |
| 4830 | 4828 |
| 4831 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4829 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4832 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4830 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4833 int f = FastD2IChecked(f_number); | 4831 int f = FastD2IChecked(f_number); |
| 4834 RUNTIME_ASSERT(f >= -1 && f <= 20); | 4832 RUNTIME_ASSERT(f >= -1 && f <= 20); |
| 4835 char* str = DoubleToExponentialCString(value, f); | 4833 char* str = DoubleToExponentialCString(value, f); |
| 4836 Handle<String> result = | 4834 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4837 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | |
| 4838 DeleteArray(str); | 4835 DeleteArray(str); |
| 4839 return *result; | 4836 return *result; |
| 4840 } | 4837 } |
| 4841 | 4838 |
| 4842 | 4839 |
| 4843 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 4840 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { |
| 4844 HandleScope scope(isolate); | 4841 HandleScope scope(isolate); |
| 4845 ASSERT(args.length() == 2); | 4842 ASSERT(args.length() == 2); |
| 4846 | 4843 |
| 4847 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4844 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4848 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4845 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4849 int f = FastD2IChecked(f_number); | 4846 int f = FastD2IChecked(f_number); |
| 4850 RUNTIME_ASSERT(f >= 1 && f <= 21); | 4847 RUNTIME_ASSERT(f >= 1 && f <= 21); |
| 4851 char* str = DoubleToPrecisionCString(value, f); | 4848 char* str = DoubleToPrecisionCString(value, f); |
| 4852 Handle<String> result = | 4849 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
| 4853 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | |
| 4854 DeleteArray(str); | 4850 DeleteArray(str); |
| 4855 return *result; | 4851 return *result; |
| 4856 } | 4852 } |
| 4857 | 4853 |
| 4858 | 4854 |
| 4859 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsValidSmi) { | 4855 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsValidSmi) { |
| 4860 SealHandleScope shs(isolate); | 4856 SealHandleScope shs(isolate); |
| 4861 ASSERT(args.length() == 1); | 4857 ASSERT(args.length() == 1); |
| 4862 | 4858 |
| 4863 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); | 4859 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); |
| (...skipping 4565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9429 } | 9425 } |
| 9430 | 9426 |
| 9431 | 9427 |
| 9432 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowMessage) { | 9428 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowMessage) { |
| 9433 HandleScope scope(isolate); | 9429 HandleScope scope(isolate); |
| 9434 ASSERT(args.length() == 1); | 9430 ASSERT(args.length() == 1); |
| 9435 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 9431 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
| 9436 const char* message = GetBailoutReason( | 9432 const char* message = GetBailoutReason( |
| 9437 static_cast<BailoutReason>(message_id)); | 9433 static_cast<BailoutReason>(message_id)); |
| 9438 Handle<String> message_handle = | 9434 Handle<String> message_handle = |
| 9439 isolate->factory()->NewStringFromAscii(CStrVector(message)); | 9435 isolate->factory()->NewStringFromAsciiChecked(message); |
| 9440 RETURN_IF_EMPTY_HANDLE(isolate, message_handle); | |
| 9441 return isolate->Throw(*message_handle); | 9436 return isolate->Throw(*message_handle); |
| 9442 } | 9437 } |
| 9443 | 9438 |
| 9444 | 9439 |
| 9445 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StackGuard) { | 9440 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StackGuard) { |
| 9446 SealHandleScope shs(isolate); | 9441 SealHandleScope shs(isolate); |
| 9447 ASSERT(args.length() == 0); | 9442 ASSERT(args.length() == 0); |
| 9448 | 9443 |
| 9449 // First check if this is a real stack overflow. | 9444 // First check if this is a real stack overflow. |
| 9450 if (isolate->stack_guard()->IsStackOverflow()) { | 9445 if (isolate->stack_guard()->IsStackOverflow()) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9612 } | 9607 } |
| 9613 | 9608 |
| 9614 | 9609 |
| 9615 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 9610 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { |
| 9616 HandleScope scope(isolate); | 9611 HandleScope scope(isolate); |
| 9617 ASSERT(args.length() == 1); | 9612 ASSERT(args.length() == 1); |
| 9618 | 9613 |
| 9619 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9614 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9620 const char* zone = | 9615 const char* zone = |
| 9621 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); | 9616 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); |
| 9622 return *isolate->factory()->NewStringFromUtf8(CStrVector(zone)); | 9617 Handle<String> result = isolate->factory()->NewStringFromUtf8( |
| 9618 CStrVector(zone)).ToHandleChecked(); |
| 9619 return *result; |
| 9623 } | 9620 } |
| 9624 | 9621 |
| 9625 | 9622 |
| 9626 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9623 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { |
| 9627 HandleScope scope(isolate); | 9624 HandleScope scope(isolate); |
| 9628 ASSERT(args.length() == 1); | 9625 ASSERT(args.length() == 1); |
| 9629 | 9626 |
| 9630 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9627 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9631 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9628 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
| 9632 | 9629 |
| (...skipping 4009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13642 // Return value which denotes invalid language tag. | 13639 // Return value which denotes invalid language tag. |
| 13643 const char* const kInvalidTag = "invalid-tag"; | 13640 const char* const kInvalidTag = "invalid-tag"; |
| 13644 | 13641 |
| 13645 UErrorCode error = U_ZERO_ERROR; | 13642 UErrorCode error = U_ZERO_ERROR; |
| 13646 char icu_result[ULOC_FULLNAME_CAPACITY]; | 13643 char icu_result[ULOC_FULLNAME_CAPACITY]; |
| 13647 int icu_length = 0; | 13644 int icu_length = 0; |
| 13648 | 13645 |
| 13649 uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY, | 13646 uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY, |
| 13650 &icu_length, &error); | 13647 &icu_length, &error); |
| 13651 if (U_FAILURE(error) || icu_length == 0) { | 13648 if (U_FAILURE(error) || icu_length == 0) { |
| 13652 return *factory->NewStringFromOneByte(OneByteVector(kInvalidTag)); | 13649 return *factory->NewStringFromAsciiChecked(kInvalidTag); |
| 13653 } | 13650 } |
| 13654 | 13651 |
| 13655 char result[ULOC_FULLNAME_CAPACITY]; | 13652 char result[ULOC_FULLNAME_CAPACITY]; |
| 13656 | 13653 |
| 13657 // Force strict BCP47 rules. | 13654 // Force strict BCP47 rules. |
| 13658 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); | 13655 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); |
| 13659 | 13656 |
| 13660 if (U_FAILURE(error)) { | 13657 if (U_FAILURE(error)) { |
| 13661 return *factory->NewStringFromOneByte(OneByteVector(kInvalidTag)); | 13658 return *factory->NewStringFromAsciiChecked(kInvalidTag); |
| 13662 } | 13659 } |
| 13663 | 13660 |
| 13664 return *factory->NewStringFromOneByte(OneByteVector(result)); | 13661 return *factory->NewStringFromAsciiChecked(result); |
| 13665 } | 13662 } |
| 13666 | 13663 |
| 13667 | 13664 |
| 13668 RUNTIME_FUNCTION(MaybeObject*, Runtime_AvailableLocalesOf) { | 13665 RUNTIME_FUNCTION(MaybeObject*, Runtime_AvailableLocalesOf) { |
| 13669 HandleScope scope(isolate); | 13666 HandleScope scope(isolate); |
| 13667 Factory* factory = isolate->factory(); |
| 13670 | 13668 |
| 13671 ASSERT(args.length() == 1); | 13669 ASSERT(args.length() == 1); |
| 13672 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); | 13670 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); |
| 13673 | 13671 |
| 13674 const icu::Locale* available_locales = NULL; | 13672 const icu::Locale* available_locales = NULL; |
| 13675 int32_t count = 0; | 13673 int32_t count = 0; |
| 13676 | 13674 |
| 13677 if (service->IsUtf8EqualTo(CStrVector("collator"))) { | 13675 if (service->IsUtf8EqualTo(CStrVector("collator"))) { |
| 13678 available_locales = icu::Collator::getAvailableLocales(count); | 13676 available_locales = icu::Collator::getAvailableLocales(count); |
| 13679 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) { | 13677 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) { |
| 13680 available_locales = icu::NumberFormat::getAvailableLocales(count); | 13678 available_locales = icu::NumberFormat::getAvailableLocales(count); |
| 13681 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) { | 13679 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) { |
| 13682 available_locales = icu::DateFormat::getAvailableLocales(count); | 13680 available_locales = icu::DateFormat::getAvailableLocales(count); |
| 13683 } else if (service->IsUtf8EqualTo(CStrVector("breakiterator"))) { | 13681 } else if (service->IsUtf8EqualTo(CStrVector("breakiterator"))) { |
| 13684 available_locales = icu::BreakIterator::getAvailableLocales(count); | 13682 available_locales = icu::BreakIterator::getAvailableLocales(count); |
| 13685 } | 13683 } |
| 13686 | 13684 |
| 13687 UErrorCode error = U_ZERO_ERROR; | 13685 UErrorCode error = U_ZERO_ERROR; |
| 13688 char result[ULOC_FULLNAME_CAPACITY]; | 13686 char result[ULOC_FULLNAME_CAPACITY]; |
| 13689 Handle<JSObject> locales = | 13687 Handle<JSObject> locales = |
| 13690 isolate->factory()->NewJSObject(isolate->object_function()); | 13688 factory->NewJSObject(isolate->object_function()); |
| 13691 | 13689 |
| 13692 for (int32_t i = 0; i < count; ++i) { | 13690 for (int32_t i = 0; i < count; ++i) { |
| 13693 const char* icu_name = available_locales[i].getName(); | 13691 const char* icu_name = available_locales[i].getName(); |
| 13694 | 13692 |
| 13695 error = U_ZERO_ERROR; | 13693 error = U_ZERO_ERROR; |
| 13696 // No need to force strict BCP47 rules. | 13694 // No need to force strict BCP47 rules. |
| 13697 uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13695 uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error); |
| 13698 if (U_FAILURE(error)) { | 13696 if (U_FAILURE(error)) { |
| 13699 // This shouldn't happen, but lets not break the user. | 13697 // This shouldn't happen, but lets not break the user. |
| 13700 continue; | 13698 continue; |
| 13701 } | 13699 } |
| 13702 | 13700 |
| 13703 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13701 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 13704 JSObject::SetLocalPropertyIgnoreAttributes( | 13702 JSObject::SetLocalPropertyIgnoreAttributes( |
| 13705 locales, | 13703 locales, |
| 13706 isolate->factory()->NewStringFromAscii(CStrVector(result)), | 13704 factory->NewStringFromAsciiChecked(result), |
| 13707 isolate->factory()->NewNumber(i), | 13705 factory->NewNumber(i), |
| 13708 NONE)); | 13706 NONE)); |
| 13709 } | 13707 } |
| 13710 | 13708 |
| 13711 return *locales; | 13709 return *locales; |
| 13712 } | 13710 } |
| 13713 | 13711 |
| 13714 | 13712 |
| 13715 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultICULocale) { | 13713 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultICULocale) { |
| 13716 HandleScope scope(isolate); | 13714 HandleScope scope(isolate); |
| 13717 Factory* factory = isolate->factory(); | 13715 Factory* factory = isolate->factory(); |
| 13718 | 13716 |
| 13719 ASSERT(args.length() == 0); | 13717 ASSERT(args.length() == 0); |
| 13720 | 13718 |
| 13721 icu::Locale default_locale; | 13719 icu::Locale default_locale; |
| 13722 | 13720 |
| 13723 // Set the locale | 13721 // Set the locale |
| 13724 char result[ULOC_FULLNAME_CAPACITY]; | 13722 char result[ULOC_FULLNAME_CAPACITY]; |
| 13725 UErrorCode status = U_ZERO_ERROR; | 13723 UErrorCode status = U_ZERO_ERROR; |
| 13726 uloc_toLanguageTag( | 13724 uloc_toLanguageTag( |
| 13727 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 13725 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
| 13728 if (U_SUCCESS(status)) { | 13726 if (U_SUCCESS(status)) { |
| 13729 return *factory->NewStringFromOneByte(OneByteVector(result)); | 13727 return *factory->NewStringFromAsciiChecked(result); |
| 13730 } | 13728 } |
| 13731 | 13729 |
| 13732 return *factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("und")); | 13730 return *factory->NewStringFromStaticAscii("und"); |
| 13733 } | 13731 } |
| 13734 | 13732 |
| 13735 | 13733 |
| 13736 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) { | 13734 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) { |
| 13737 HandleScope scope(isolate); | 13735 HandleScope scope(isolate); |
| 13736 Factory* factory = isolate->factory(); |
| 13738 | 13737 |
| 13739 ASSERT(args.length() == 1); | 13738 ASSERT(args.length() == 1); |
| 13740 | 13739 |
| 13741 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); | 13740 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); |
| 13742 | 13741 |
| 13743 uint32_t length = static_cast<uint32_t>(input->length()->Number()); | 13742 uint32_t length = static_cast<uint32_t>(input->length()->Number()); |
| 13744 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length); | 13743 Handle<FixedArray> output = factory->NewFixedArray(length); |
| 13745 Handle<Name> maximized = | 13744 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); |
| 13746 isolate->factory()->NewStringFromAscii(CStrVector("maximized")); | 13745 Handle<Name> base = factory->NewStringFromStaticAscii("base"); |
| 13747 Handle<Name> base = | |
| 13748 isolate->factory()->NewStringFromAscii(CStrVector("base")); | |
| 13749 for (unsigned int i = 0; i < length; ++i) { | 13746 for (unsigned int i = 0; i < length; ++i) { |
| 13750 Handle<Object> locale_id; | 13747 Handle<Object> locale_id; |
| 13751 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13748 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13752 isolate, locale_id, Object::GetElement(isolate, input, i)); | 13749 isolate, locale_id, Object::GetElement(isolate, input, i)); |
| 13753 if (!locale_id->IsString()) { | 13750 if (!locale_id->IsString()) { |
| 13754 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 13751 return isolate->Throw(*factory->illegal_argument_string()); |
| 13755 } | 13752 } |
| 13756 | 13753 |
| 13757 v8::String::Utf8Value utf8_locale_id( | 13754 v8::String::Utf8Value utf8_locale_id( |
| 13758 v8::Utils::ToLocal(Handle<String>::cast(locale_id))); | 13755 v8::Utils::ToLocal(Handle<String>::cast(locale_id))); |
| 13759 | 13756 |
| 13760 UErrorCode error = U_ZERO_ERROR; | 13757 UErrorCode error = U_ZERO_ERROR; |
| 13761 | 13758 |
| 13762 // Convert from BCP47 to ICU format. | 13759 // Convert from BCP47 to ICU format. |
| 13763 // de-DE-u-co-phonebk -> de_DE@collation=phonebook | 13760 // de-DE-u-co-phonebk -> de_DE@collation=phonebook |
| 13764 char icu_locale[ULOC_FULLNAME_CAPACITY]; | 13761 char icu_locale[ULOC_FULLNAME_CAPACITY]; |
| 13765 int icu_locale_length = 0; | 13762 int icu_locale_length = 0; |
| 13766 uloc_forLanguageTag(*utf8_locale_id, icu_locale, ULOC_FULLNAME_CAPACITY, | 13763 uloc_forLanguageTag(*utf8_locale_id, icu_locale, ULOC_FULLNAME_CAPACITY, |
| 13767 &icu_locale_length, &error); | 13764 &icu_locale_length, &error); |
| 13768 if (U_FAILURE(error) || icu_locale_length == 0) { | 13765 if (U_FAILURE(error) || icu_locale_length == 0) { |
| 13769 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 13766 return isolate->Throw(*factory->illegal_argument_string()); |
| 13770 } | 13767 } |
| 13771 | 13768 |
| 13772 // Maximize the locale. | 13769 // Maximize the locale. |
| 13773 // de_DE@collation=phonebook -> de_Latn_DE@collation=phonebook | 13770 // de_DE@collation=phonebook -> de_Latn_DE@collation=phonebook |
| 13774 char icu_max_locale[ULOC_FULLNAME_CAPACITY]; | 13771 char icu_max_locale[ULOC_FULLNAME_CAPACITY]; |
| 13775 uloc_addLikelySubtags( | 13772 uloc_addLikelySubtags( |
| 13776 icu_locale, icu_max_locale, ULOC_FULLNAME_CAPACITY, &error); | 13773 icu_locale, icu_max_locale, ULOC_FULLNAME_CAPACITY, &error); |
| 13777 | 13774 |
| 13778 // Remove extensions from maximized locale. | 13775 // Remove extensions from maximized locale. |
| 13779 // de_Latn_DE@collation=phonebook -> de_Latn_DE | 13776 // de_Latn_DE@collation=phonebook -> de_Latn_DE |
| (...skipping 12 matching lines...) Expand all Loading... |
| 13792 char base_max_locale[ULOC_FULLNAME_CAPACITY]; | 13789 char base_max_locale[ULOC_FULLNAME_CAPACITY]; |
| 13793 uloc_toLanguageTag(icu_base_max_locale, base_max_locale, | 13790 uloc_toLanguageTag(icu_base_max_locale, base_max_locale, |
| 13794 ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13791 ULOC_FULLNAME_CAPACITY, FALSE, &error); |
| 13795 | 13792 |
| 13796 // de_DE -> de-DE | 13793 // de_DE -> de-DE |
| 13797 char base_locale[ULOC_FULLNAME_CAPACITY]; | 13794 char base_locale[ULOC_FULLNAME_CAPACITY]; |
| 13798 uloc_toLanguageTag( | 13795 uloc_toLanguageTag( |
| 13799 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13796 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error); |
| 13800 | 13797 |
| 13801 if (U_FAILURE(error)) { | 13798 if (U_FAILURE(error)) { |
| 13802 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 13799 return isolate->Throw(*factory->illegal_argument_string()); |
| 13803 } | 13800 } |
| 13804 | 13801 |
| 13805 Handle<JSObject> result = | 13802 Handle<JSObject> result = factory->NewJSObject(isolate->object_function()); |
| 13806 isolate->factory()->NewJSObject(isolate->object_function()); | |
| 13807 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13803 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 13808 JSObject::SetLocalPropertyIgnoreAttributes( | 13804 JSObject::SetLocalPropertyIgnoreAttributes( |
| 13809 result, | 13805 result, |
| 13810 maximized, | 13806 maximized, |
| 13811 isolate->factory()->NewStringFromAscii(CStrVector(base_max_locale)), | 13807 factory->NewStringFromAsciiChecked(base_max_locale), |
| 13812 NONE)); | 13808 NONE)); |
| 13813 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13809 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 13814 JSObject::SetLocalPropertyIgnoreAttributes( | 13810 JSObject::SetLocalPropertyIgnoreAttributes( |
| 13815 result, | 13811 result, |
| 13816 base, | 13812 base, |
| 13817 isolate->factory()->NewStringFromAscii(CStrVector(base_locale)), | 13813 factory->NewStringFromAsciiChecked(base_locale), |
| 13818 NONE)); | 13814 NONE)); |
| 13819 output->set(i, *result); | 13815 output->set(i, *result); |
| 13820 } | 13816 } |
| 13821 | 13817 |
| 13822 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(output); | 13818 Handle<JSArray> result = factory->NewJSArrayWithElements(output); |
| 13823 result->set_length(Smi::FromInt(length)); | 13819 result->set_length(Smi::FromInt(length)); |
| 13824 return *result; | 13820 return *result; |
| 13825 } | 13821 } |
| 13826 | 13822 |
| 13827 | 13823 |
| 13828 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObject) { | 13824 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObject) { |
| 13829 HandleScope scope(isolate); | 13825 HandleScope scope(isolate); |
| 13830 | 13826 |
| 13831 ASSERT(args.length() == 1); | 13827 ASSERT(args.length() == 1); |
| 13832 | 13828 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13928 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( | 13924 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( |
| 13929 isolate, locale, options, resolved); | 13925 isolate, locale, options, resolved); |
| 13930 | 13926 |
| 13931 if (!date_format) return isolate->ThrowIllegalOperation(); | 13927 if (!date_format) return isolate->ThrowIllegalOperation(); |
| 13932 | 13928 |
| 13933 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); | 13929 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); |
| 13934 | 13930 |
| 13935 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13931 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 13936 JSObject::SetLocalPropertyIgnoreAttributes( | 13932 JSObject::SetLocalPropertyIgnoreAttributes( |
| 13937 local_object, | 13933 local_object, |
| 13938 isolate->factory()->NewStringFromAscii(CStrVector("dateFormat")), | 13934 isolate->factory()->NewStringFromStaticAscii("dateFormat"), |
| 13939 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 13935 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 13940 NONE)); | 13936 NONE)); |
| 13941 | 13937 |
| 13942 // Make object handle weak so we can delete the data format once GC kicks in. | 13938 // Make object handle weak so we can delete the data format once GC kicks in. |
| 13943 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 13939 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 13944 GlobalHandles::MakeWeak(wrapper.location(), | 13940 GlobalHandles::MakeWeak(wrapper.location(), |
| 13945 reinterpret_cast<void*>(wrapper.location()), | 13941 reinterpret_cast<void*>(wrapper.location()), |
| 13946 DateFormat::DeleteDateFormat); | 13942 DateFormat::DeleteDateFormat); |
| 13947 return *local_object; | 13943 return *local_object; |
| 13948 } | 13944 } |
| 13949 | 13945 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 13960 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13956 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13961 isolate, value, Execution::ToNumber(isolate, date)); | 13957 isolate, value, Execution::ToNumber(isolate, date)); |
| 13962 | 13958 |
| 13963 icu::SimpleDateFormat* date_format = | 13959 icu::SimpleDateFormat* date_format = |
| 13964 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 13960 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
| 13965 if (!date_format) return isolate->ThrowIllegalOperation(); | 13961 if (!date_format) return isolate->ThrowIllegalOperation(); |
| 13966 | 13962 |
| 13967 icu::UnicodeString result; | 13963 icu::UnicodeString result; |
| 13968 date_format->format(value->Number(), result); | 13964 date_format->format(value->Number(), result); |
| 13969 | 13965 |
| 13970 return *isolate->factory()->NewStringFromTwoByte( | 13966 Handle<String> result_str; |
| 13971 Vector<const uint16_t>( | 13967 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13972 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 13968 isolate, result_str, |
| 13973 result.length())); | 13969 isolate->factory()->NewStringFromTwoByte( |
| 13970 Vector<const uint16_t>( |
| 13971 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 13972 result.length()))); |
| 13973 return *result_str; |
| 13974 } | 13974 } |
| 13975 | 13975 |
| 13976 | 13976 |
| 13977 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateParse) { | 13977 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateParse) { |
| 13978 HandleScope scope(isolate); | 13978 HandleScope scope(isolate); |
| 13979 | 13979 |
| 13980 ASSERT(args.length() == 2); | 13980 ASSERT(args.length() == 2); |
| 13981 | 13981 |
| 13982 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 13982 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
| 13983 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); | 13983 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14023 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat( | 14023 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat( |
| 14024 isolate, locale, options, resolved); | 14024 isolate, locale, options, resolved); |
| 14025 | 14025 |
| 14026 if (!number_format) return isolate->ThrowIllegalOperation(); | 14026 if (!number_format) return isolate->ThrowIllegalOperation(); |
| 14027 | 14027 |
| 14028 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); | 14028 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); |
| 14029 | 14029 |
| 14030 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14030 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 14031 JSObject::SetLocalPropertyIgnoreAttributes( | 14031 JSObject::SetLocalPropertyIgnoreAttributes( |
| 14032 local_object, | 14032 local_object, |
| 14033 isolate->factory()->NewStringFromAscii(CStrVector("numberFormat")), | 14033 isolate->factory()->NewStringFromStaticAscii("numberFormat"), |
| 14034 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 14034 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 14035 NONE)); | 14035 NONE)); |
| 14036 | 14036 |
| 14037 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14037 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14038 GlobalHandles::MakeWeak(wrapper.location(), | 14038 GlobalHandles::MakeWeak(wrapper.location(), |
| 14039 reinterpret_cast<void*>(wrapper.location()), | 14039 reinterpret_cast<void*>(wrapper.location()), |
| 14040 NumberFormat::DeleteNumberFormat); | 14040 NumberFormat::DeleteNumberFormat); |
| 14041 return *local_object; | 14041 return *local_object; |
| 14042 } | 14042 } |
| 14043 | 14043 |
| 14044 | 14044 |
| 14045 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { | 14045 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { |
| 14046 HandleScope scope(isolate); | 14046 HandleScope scope(isolate); |
| 14047 | 14047 |
| 14048 ASSERT(args.length() == 2); | 14048 ASSERT(args.length() == 2); |
| 14049 | 14049 |
| 14050 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14050 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
| 14051 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); | 14051 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); |
| 14052 | 14052 |
| 14053 Handle<Object> value; | 14053 Handle<Object> value; |
| 14054 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14054 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14055 isolate, value, Execution::ToNumber(isolate, number)); | 14055 isolate, value, Execution::ToNumber(isolate, number)); |
| 14056 | 14056 |
| 14057 icu::DecimalFormat* number_format = | 14057 icu::DecimalFormat* number_format = |
| 14058 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); | 14058 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); |
| 14059 if (!number_format) return isolate->ThrowIllegalOperation(); | 14059 if (!number_format) return isolate->ThrowIllegalOperation(); |
| 14060 | 14060 |
| 14061 icu::UnicodeString result; | 14061 icu::UnicodeString result; |
| 14062 number_format->format(value->Number(), result); | 14062 number_format->format(value->Number(), result); |
| 14063 | 14063 |
| 14064 return *isolate->factory()->NewStringFromTwoByte( | 14064 Handle<String> result_str; |
| 14065 Vector<const uint16_t>( | 14065 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14066 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14066 isolate, result_str, |
| 14067 result.length())); | 14067 isolate->factory()->NewStringFromTwoByte( |
| 14068 Vector<const uint16_t>( |
| 14069 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14070 result.length()))); |
| 14071 return *result_str; |
| 14068 } | 14072 } |
| 14069 | 14073 |
| 14070 | 14074 |
| 14071 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) { | 14075 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) { |
| 14072 HandleScope scope(isolate); | 14076 HandleScope scope(isolate); |
| 14073 | 14077 |
| 14074 ASSERT(args.length() == 2); | 14078 ASSERT(args.length() == 2); |
| 14075 | 14079 |
| 14076 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14080 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
| 14077 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); | 14081 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14127 icu::Collator* collator = Collator::InitializeCollator( | 14131 icu::Collator* collator = Collator::InitializeCollator( |
| 14128 isolate, locale, options, resolved); | 14132 isolate, locale, options, resolved); |
| 14129 | 14133 |
| 14130 if (!collator) return isolate->ThrowIllegalOperation(); | 14134 if (!collator) return isolate->ThrowIllegalOperation(); |
| 14131 | 14135 |
| 14132 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); | 14136 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); |
| 14133 | 14137 |
| 14134 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14138 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 14135 JSObject::SetLocalPropertyIgnoreAttributes( | 14139 JSObject::SetLocalPropertyIgnoreAttributes( |
| 14136 local_object, | 14140 local_object, |
| 14137 isolate->factory()->NewStringFromAscii(CStrVector("collator")), | 14141 isolate->factory()->NewStringFromStaticAscii("collator"), |
| 14138 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 14142 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 14139 NONE)); | 14143 NONE)); |
| 14140 | 14144 |
| 14141 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14145 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14142 GlobalHandles::MakeWeak(wrapper.location(), | 14146 GlobalHandles::MakeWeak(wrapper.location(), |
| 14143 reinterpret_cast<void*>(wrapper.location()), | 14147 reinterpret_cast<void*>(wrapper.location()), |
| 14144 Collator::DeleteCollator); | 14148 Collator::DeleteCollator); |
| 14145 return *local_object; | 14149 return *local_object; |
| 14146 } | 14150 } |
| 14147 | 14151 |
| 14148 | 14152 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14189 | 14193 |
| 14190 // TODO(mnita): check Normalizer2 (not available in ICU 46) | 14194 // TODO(mnita): check Normalizer2 (not available in ICU 46) |
| 14191 UErrorCode status = U_ZERO_ERROR; | 14195 UErrorCode status = U_ZERO_ERROR; |
| 14192 icu::UnicodeString result; | 14196 icu::UnicodeString result; |
| 14193 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, | 14197 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, |
| 14194 result, status); | 14198 result, status); |
| 14195 if (U_FAILURE(status)) { | 14199 if (U_FAILURE(status)) { |
| 14196 return isolate->heap()->undefined_value(); | 14200 return isolate->heap()->undefined_value(); |
| 14197 } | 14201 } |
| 14198 | 14202 |
| 14199 return *isolate->factory()->NewStringFromTwoByte( | 14203 Handle<String> result_str; |
| 14200 Vector<const uint16_t>( | 14204 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 14201 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14205 isolate, result_str, |
| 14202 result.length())); | 14206 isolate->factory()->NewStringFromTwoByte( |
| 14207 Vector<const uint16_t>( |
| 14208 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14209 result.length()))); |
| 14210 return *result_str; |
| 14203 } | 14211 } |
| 14204 | 14212 |
| 14205 | 14213 |
| 14206 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14214 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { |
| 14207 HandleScope scope(isolate); | 14215 HandleScope scope(isolate); |
| 14208 | 14216 |
| 14209 ASSERT(args.length() == 3); | 14217 ASSERT(args.length() == 3); |
| 14210 | 14218 |
| 14211 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14219 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 14212 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14220 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 14227 | 14235 |
| 14228 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14236 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14229 | 14237 |
| 14230 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); | 14238 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); |
| 14231 // Make sure that the pointer to adopted text is NULL. | 14239 // Make sure that the pointer to adopted text is NULL. |
| 14232 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); | 14240 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); |
| 14233 | 14241 |
| 14234 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14242 RETURN_FAILURE_ON_EXCEPTION(isolate, |
| 14235 JSObject::SetLocalPropertyIgnoreAttributes( | 14243 JSObject::SetLocalPropertyIgnoreAttributes( |
| 14236 local_object, | 14244 local_object, |
| 14237 isolate->factory()->NewStringFromAscii(CStrVector("breakIterator")), | 14245 isolate->factory()->NewStringFromStaticAscii("breakIterator"), |
| 14238 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 14246 isolate->factory()->NewStringFromStaticAscii("valid"), |
| 14239 NONE)); | 14247 NONE)); |
| 14240 | 14248 |
| 14241 // Make object handle weak so we can delete the break iterator once GC kicks | 14249 // Make object handle weak so we can delete the break iterator once GC kicks |
| 14242 // in. | 14250 // in. |
| 14243 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14251 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
| 14244 GlobalHandles::MakeWeak(wrapper.location(), | 14252 GlobalHandles::MakeWeak(wrapper.location(), |
| 14245 reinterpret_cast<void*>(wrapper.location()), | 14253 reinterpret_cast<void*>(wrapper.location()), |
| 14246 BreakIterator::DeleteBreakIterator); | 14254 BreakIterator::DeleteBreakIterator); |
| 14247 return *local_object; | 14255 return *local_object; |
| 14248 } | 14256 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14330 icu::BreakIterator* break_iterator = | 14338 icu::BreakIterator* break_iterator = |
| 14331 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14339 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
| 14332 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14340 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
| 14333 | 14341 |
| 14334 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. | 14342 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. |
| 14335 icu::RuleBasedBreakIterator* rule_based_iterator = | 14343 icu::RuleBasedBreakIterator* rule_based_iterator = |
| 14336 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); | 14344 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); |
| 14337 int32_t status = rule_based_iterator->getRuleStatus(); | 14345 int32_t status = rule_based_iterator->getRuleStatus(); |
| 14338 // Keep return values in sync with JavaScript BreakType enum. | 14346 // Keep return values in sync with JavaScript BreakType enum. |
| 14339 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { | 14347 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { |
| 14340 return *isolate->factory()->NewStringFromAscii(CStrVector("none")); | 14348 return *isolate->factory()->NewStringFromStaticAscii("none"); |
| 14341 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { | 14349 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { |
| 14342 return *isolate->factory()->NewStringFromAscii(CStrVector("number")); | 14350 return *isolate->factory()->NewStringFromStaticAscii("number"); |
| 14343 } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) { | 14351 } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) { |
| 14344 return *isolate->factory()->NewStringFromAscii(CStrVector("letter")); | 14352 return *isolate->factory()->NewStringFromStaticAscii("letter"); |
| 14345 } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) { | 14353 } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) { |
| 14346 return *isolate->factory()->NewStringFromAscii(CStrVector("kana")); | 14354 return *isolate->factory()->NewStringFromStaticAscii("kana"); |
| 14347 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { | 14355 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { |
| 14348 return *isolate->factory()->NewStringFromAscii(CStrVector("ideo")); | 14356 return *isolate->factory()->NewStringFromStaticAscii("ideo"); |
| 14349 } else { | 14357 } else { |
| 14350 return *isolate->factory()->NewStringFromAscii(CStrVector("unknown")); | 14358 return *isolate->factory()->NewStringFromStaticAscii("unknown"); |
| 14351 } | 14359 } |
| 14352 } | 14360 } |
| 14353 #endif // V8_I18N_SUPPORT | 14361 #endif // V8_I18N_SUPPORT |
| 14354 | 14362 |
| 14355 | 14363 |
| 14356 // Finds the script object from the script data. NOTE: This operation uses | 14364 // Finds the script object from the script data. NOTE: This operation uses |
| 14357 // heap traversal to find the function generated for the source position | 14365 // heap traversal to find the function generated for the source position |
| 14358 // for the requested break point. For lazily compiled functions several heap | 14366 // for the requested break point. For lazily compiled functions several heap |
| 14359 // traversals might be required rendering this operation as a rather slow | 14367 // traversals might be required rendering this operation as a rather slow |
| 14360 // operation. However for setting break points which is normally done through | 14368 // operation. However for setting break points which is normally done through |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14438 } | 14446 } |
| 14439 | 14447 |
| 14440 | 14448 |
| 14441 // Returns V8 version as a string. | 14449 // Returns V8 version as a string. |
| 14442 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 14450 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
| 14443 HandleScope scope(isolate); | 14451 HandleScope scope(isolate); |
| 14444 ASSERT(args.length() == 0); | 14452 ASSERT(args.length() == 0); |
| 14445 | 14453 |
| 14446 const char* version_string = v8::V8::GetVersion(); | 14454 const char* version_string = v8::V8::GetVersion(); |
| 14447 | 14455 |
| 14448 return *isolate->factory()->NewStringFromOneByte( | 14456 return *isolate->factory()->NewStringFromAsciiChecked(version_string); |
| 14449 OneByteVector(version_string), NOT_TENURED); | |
| 14450 } | 14457 } |
| 14451 | 14458 |
| 14452 | 14459 |
| 14453 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { | 14460 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { |
| 14454 SealHandleScope shs(isolate); | 14461 SealHandleScope shs(isolate); |
| 14455 ASSERT(args.length() == 1); | 14462 ASSERT(args.length() == 1); |
| 14456 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 14463 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
| 14457 const char* message = GetBailoutReason( | 14464 const char* message = GetBailoutReason( |
| 14458 static_cast<BailoutReason>(message_id)); | 14465 static_cast<BailoutReason>(message_id)); |
| 14459 OS::PrintError("abort: %s\n", message); | 14466 OS::PrintError("abort: %s\n", message); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14651 Factory* factory = isolate->factory(); | 14658 Factory* factory = isolate->factory(); |
| 14652 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 14659 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
| 14653 int index = 0; | 14660 int index = 0; |
| 14654 bool inline_runtime_functions = false; | 14661 bool inline_runtime_functions = false; |
| 14655 #define ADD_ENTRY(Name, argc, ressize) \ | 14662 #define ADD_ENTRY(Name, argc, ressize) \ |
| 14656 { \ | 14663 { \ |
| 14657 HandleScope inner(isolate); \ | 14664 HandleScope inner(isolate); \ |
| 14658 Handle<String> name; \ | 14665 Handle<String> name; \ |
| 14659 /* Inline runtime functions have an underscore in front of the name. */ \ | 14666 /* Inline runtime functions have an underscore in front of the name. */ \ |
| 14660 if (inline_runtime_functions) { \ | 14667 if (inline_runtime_functions) { \ |
| 14661 name = factory->NewStringFromAscii( \ | 14668 name = factory->NewStringFromStaticAscii("_" #Name); \ |
| 14662 Vector<const char>("_" #Name, StrLength("_" #Name))); \ | |
| 14663 } else { \ | 14669 } else { \ |
| 14664 name = factory->NewStringFromAscii( \ | 14670 name = factory->NewStringFromStaticAscii(#Name); \ |
| 14665 Vector<const char>(#Name, StrLength(#Name))); \ | |
| 14666 } \ | 14671 } \ |
| 14667 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ | 14672 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ |
| 14668 pair_elements->set(0, *name); \ | 14673 pair_elements->set(0, *name); \ |
| 14669 pair_elements->set(1, Smi::FromInt(argc)); \ | 14674 pair_elements->set(1, Smi::FromInt(argc)); \ |
| 14670 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ | 14675 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ |
| 14671 elements->set(index++, *pair); \ | 14676 elements->set(index++, *pair); \ |
| 14672 } | 14677 } |
| 14673 inline_runtime_functions = false; | 14678 inline_runtime_functions = false; |
| 14674 RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 14679 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
| 14675 // Calling hidden runtime functions should just throw. | 14680 // Calling hidden runtime functions should just throw. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15108 } | 15113 } |
| 15109 } | 15114 } |
| 15110 | 15115 |
| 15111 | 15116 |
| 15112 void Runtime::OutOfMemory() { | 15117 void Runtime::OutOfMemory() { |
| 15113 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15118 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
| 15114 UNREACHABLE(); | 15119 UNREACHABLE(); |
| 15115 } | 15120 } |
| 15116 | 15121 |
| 15117 } } // namespace v8::internal | 15122 } } // namespace v8::internal |
| OLD | NEW |