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; |
4805 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | 4805 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 4806 isolate, result, |
| 4807 isolate->factory()->NewStringFromOneByte(OneByteVector(str))); |
4806 DeleteArray(str); | 4808 DeleteArray(str); |
4807 return *result; | 4809 return *result; |
4808 } | 4810 } |
4809 | 4811 |
4810 | 4812 |
4811 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { | 4813 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { |
4812 HandleScope scope(isolate); | 4814 HandleScope scope(isolate); |
4813 ASSERT(args.length() == 2); | 4815 ASSERT(args.length() == 2); |
4814 | 4816 |
4815 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4817 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4816 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4818 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4817 int f = FastD2IChecked(f_number); | 4819 int f = FastD2IChecked(f_number); |
4818 RUNTIME_ASSERT(f >= 0); | 4820 RUNTIME_ASSERT(f >= 0); |
4819 char* str = DoubleToFixedCString(value, f); | 4821 char* str = DoubleToFixedCString(value, f); |
4820 Handle<String> result = | 4822 Handle<String> result; |
4821 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | 4823 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 4824 isolate, result, |
| 4825 isolate->factory()->NewStringFromOneByte(OneByteVector(str))); |
4822 DeleteArray(str); | 4826 DeleteArray(str); |
4823 return *result; | 4827 return *result; |
4824 } | 4828 } |
4825 | 4829 |
4826 | 4830 |
4827 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 4831 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { |
4828 HandleScope scope(isolate); | 4832 HandleScope scope(isolate); |
4829 ASSERT(args.length() == 2); | 4833 ASSERT(args.length() == 2); |
4830 | 4834 |
4831 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4835 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4832 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4836 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4833 int f = FastD2IChecked(f_number); | 4837 int f = FastD2IChecked(f_number); |
4834 RUNTIME_ASSERT(f >= -1 && f <= 20); | 4838 RUNTIME_ASSERT(f >= -1 && f <= 20); |
4835 char* str = DoubleToExponentialCString(value, f); | 4839 char* str = DoubleToExponentialCString(value, f); |
4836 Handle<String> result = | 4840 Handle<String> result; |
4837 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | 4841 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 4842 isolate, result, |
| 4843 isolate->factory()->NewStringFromOneByte(OneByteVector(str))); |
4838 DeleteArray(str); | 4844 DeleteArray(str); |
4839 return *result; | 4845 return *result; |
4840 } | 4846 } |
4841 | 4847 |
4842 | 4848 |
4843 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 4849 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { |
4844 HandleScope scope(isolate); | 4850 HandleScope scope(isolate); |
4845 ASSERT(args.length() == 2); | 4851 ASSERT(args.length() == 2); |
4846 | 4852 |
4847 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4853 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4848 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4854 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4849 int f = FastD2IChecked(f_number); | 4855 int f = FastD2IChecked(f_number); |
4850 RUNTIME_ASSERT(f >= 1 && f <= 21); | 4856 RUNTIME_ASSERT(f >= 1 && f <= 21); |
4851 char* str = DoubleToPrecisionCString(value, f); | 4857 char* str = DoubleToPrecisionCString(value, f); |
4852 Handle<String> result = | 4858 Handle<String> result; |
4853 isolate->factory()->NewStringFromOneByte(OneByteVector(str)); | 4859 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 4860 isolate, result, |
| 4861 isolate->factory()->NewStringFromOneByte(OneByteVector(str))); |
4854 DeleteArray(str); | 4862 DeleteArray(str); |
4855 return *result; | 4863 return *result; |
4856 } | 4864 } |
4857 | 4865 |
4858 | 4866 |
4859 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsValidSmi) { | 4867 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsValidSmi) { |
4860 SealHandleScope shs(isolate); | 4868 SealHandleScope shs(isolate); |
4861 ASSERT(args.length() == 1); | 4869 ASSERT(args.length() == 1); |
4862 | 4870 |
4863 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); | 4871 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); |
(...skipping 4565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9429 } | 9437 } |
9430 | 9438 |
9431 | 9439 |
9432 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowMessage) { | 9440 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowMessage) { |
9433 HandleScope scope(isolate); | 9441 HandleScope scope(isolate); |
9434 ASSERT(args.length() == 1); | 9442 ASSERT(args.length() == 1); |
9435 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 9443 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
9436 const char* message = GetBailoutReason( | 9444 const char* message = GetBailoutReason( |
9437 static_cast<BailoutReason>(message_id)); | 9445 static_cast<BailoutReason>(message_id)); |
9438 Handle<String> message_handle = | 9446 Handle<String> message_handle = |
9439 isolate->factory()->NewStringFromAscii(CStrVector(message)); | 9447 isolate->factory()->NewStringFromAsciiChecked(message); |
9440 RETURN_IF_EMPTY_HANDLE(isolate, message_handle); | |
9441 return isolate->Throw(*message_handle); | 9448 return isolate->Throw(*message_handle); |
9442 } | 9449 } |
9443 | 9450 |
9444 | 9451 |
9445 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StackGuard) { | 9452 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StackGuard) { |
9446 SealHandleScope shs(isolate); | 9453 SealHandleScope shs(isolate); |
9447 ASSERT(args.length() == 0); | 9454 ASSERT(args.length() == 0); |
9448 | 9455 |
9449 // First check if this is a real stack overflow. | 9456 // First check if this is a real stack overflow. |
9450 if (isolate->stack_guard()->IsStackOverflow()) { | 9457 if (isolate->stack_guard()->IsStackOverflow()) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9612 } | 9619 } |
9613 | 9620 |
9614 | 9621 |
9615 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 9622 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { |
9616 HandleScope scope(isolate); | 9623 HandleScope scope(isolate); |
9617 ASSERT(args.length() == 1); | 9624 ASSERT(args.length() == 1); |
9618 | 9625 |
9619 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9626 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9620 const char* zone = | 9627 const char* zone = |
9621 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); | 9628 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); |
9622 return *isolate->factory()->NewStringFromUtf8(CStrVector(zone)); | 9629 Handle<String> result; |
| 9630 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 9631 isolate, result, |
| 9632 isolate->factory()->NewStringFromUtf8(CStrVector(zone))); |
| 9633 return *result; |
9623 } | 9634 } |
9624 | 9635 |
9625 | 9636 |
9626 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9637 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { |
9627 HandleScope scope(isolate); | 9638 HandleScope scope(isolate); |
9628 ASSERT(args.length() == 1); | 9639 ASSERT(args.length() == 1); |
9629 | 9640 |
9630 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9641 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9631 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9642 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
9632 | 9643 |
(...skipping 4000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13633 RUNTIME_FUNCTION(MaybeObject*, Runtime_CanonicalizeLanguageTag) { | 13644 RUNTIME_FUNCTION(MaybeObject*, Runtime_CanonicalizeLanguageTag) { |
13634 HandleScope scope(isolate); | 13645 HandleScope scope(isolate); |
13635 Factory* factory = isolate->factory(); | 13646 Factory* factory = isolate->factory(); |
13636 | 13647 |
13637 ASSERT(args.length() == 1); | 13648 ASSERT(args.length() == 1); |
13638 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); | 13649 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); |
13639 | 13650 |
13640 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); | 13651 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); |
13641 | 13652 |
13642 // Return value which denotes invalid language tag. | 13653 // Return value which denotes invalid language tag. |
13643 const char* const kInvalidTag = "invalid-tag"; | 13654 #define kInvalidTag "invalid-tag" |
13644 | 13655 |
13645 UErrorCode error = U_ZERO_ERROR; | 13656 UErrorCode error = U_ZERO_ERROR; |
13646 char icu_result[ULOC_FULLNAME_CAPACITY]; | 13657 char icu_result[ULOC_FULLNAME_CAPACITY]; |
13647 int icu_length = 0; | 13658 int icu_length = 0; |
13648 | 13659 |
13649 uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY, | 13660 uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY, |
13650 &icu_length, &error); | 13661 &icu_length, &error); |
13651 if (U_FAILURE(error) || icu_length == 0) { | 13662 if (U_FAILURE(error) || icu_length == 0) { |
13652 return *factory->NewStringFromOneByte(OneByteVector(kInvalidTag)); | 13663 return *factory->NewStringFromStaticAscii(kInvalidTag); |
13653 } | 13664 } |
13654 | 13665 |
13655 char result[ULOC_FULLNAME_CAPACITY]; | 13666 char result[ULOC_FULLNAME_CAPACITY]; |
13656 | 13667 |
13657 // Force strict BCP47 rules. | 13668 // Force strict BCP47 rules. |
13658 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); | 13669 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); |
13659 | 13670 |
13660 if (U_FAILURE(error)) { | 13671 if (U_FAILURE(error)) { |
13661 return *factory->NewStringFromOneByte(OneByteVector(kInvalidTag)); | 13672 return *factory->NewStringFromStaticAscii(kInvalidTag); |
13662 } | 13673 } |
| 13674 #undef kInvalidTag |
13663 | 13675 |
13664 return *factory->NewStringFromOneByte(OneByteVector(result)); | 13676 return *factory->NewStringFromOneByte( |
| 13677 OneByteVector(result)).ToHandleChecked(); |
13665 } | 13678 } |
13666 | 13679 |
13667 | 13680 |
13668 RUNTIME_FUNCTION(MaybeObject*, Runtime_AvailableLocalesOf) { | 13681 RUNTIME_FUNCTION(MaybeObject*, Runtime_AvailableLocalesOf) { |
13669 HandleScope scope(isolate); | 13682 HandleScope scope(isolate); |
| 13683 Factory* factory = isolate->factory(); |
13670 | 13684 |
13671 ASSERT(args.length() == 1); | 13685 ASSERT(args.length() == 1); |
13672 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); | 13686 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); |
13673 | 13687 |
13674 const icu::Locale* available_locales = NULL; | 13688 const icu::Locale* available_locales = NULL; |
13675 int32_t count = 0; | 13689 int32_t count = 0; |
13676 | 13690 |
13677 if (service->IsUtf8EqualTo(CStrVector("collator"))) { | 13691 if (service->IsUtf8EqualTo(CStrVector("collator"))) { |
13678 available_locales = icu::Collator::getAvailableLocales(count); | 13692 available_locales = icu::Collator::getAvailableLocales(count); |
13679 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) { | 13693 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) { |
13680 available_locales = icu::NumberFormat::getAvailableLocales(count); | 13694 available_locales = icu::NumberFormat::getAvailableLocales(count); |
13681 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) { | 13695 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) { |
13682 available_locales = icu::DateFormat::getAvailableLocales(count); | 13696 available_locales = icu::DateFormat::getAvailableLocales(count); |
13683 } else if (service->IsUtf8EqualTo(CStrVector("breakiterator"))) { | 13697 } else if (service->IsUtf8EqualTo(CStrVector("breakiterator"))) { |
13684 available_locales = icu::BreakIterator::getAvailableLocales(count); | 13698 available_locales = icu::BreakIterator::getAvailableLocales(count); |
13685 } | 13699 } |
13686 | 13700 |
13687 UErrorCode error = U_ZERO_ERROR; | 13701 UErrorCode error = U_ZERO_ERROR; |
13688 char result[ULOC_FULLNAME_CAPACITY]; | 13702 char result[ULOC_FULLNAME_CAPACITY]; |
13689 Handle<JSObject> locales = | 13703 Handle<JSObject> locales = |
13690 isolate->factory()->NewJSObject(isolate->object_function()); | 13704 factory->NewJSObject(isolate->object_function()); |
13691 | 13705 |
13692 for (int32_t i = 0; i < count; ++i) { | 13706 for (int32_t i = 0; i < count; ++i) { |
13693 const char* icu_name = available_locales[i].getName(); | 13707 const char* icu_name = available_locales[i].getName(); |
13694 | 13708 |
13695 error = U_ZERO_ERROR; | 13709 error = U_ZERO_ERROR; |
13696 // No need to force strict BCP47 rules. | 13710 // No need to force strict BCP47 rules. |
13697 uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13711 uloc_toLanguageTag(icu_name, result, ULOC_FULLNAME_CAPACITY, FALSE, &error); |
13698 if (U_FAILURE(error)) { | 13712 if (U_FAILURE(error)) { |
13699 // This shouldn't happen, but lets not break the user. | 13713 // This shouldn't happen, but lets not break the user. |
13700 continue; | 13714 continue; |
13701 } | 13715 } |
13702 | 13716 |
13703 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13717 RETURN_FAILURE_ON_EXCEPTION(isolate, |
13704 JSObject::SetLocalPropertyIgnoreAttributes( | 13718 JSObject::SetLocalPropertyIgnoreAttributes( |
13705 locales, | 13719 locales, |
13706 isolate->factory()->NewStringFromAscii(CStrVector(result)), | 13720 factory->NewStringFromAsciiChecked(result), |
13707 isolate->factory()->NewNumber(i), | 13721 factory->NewNumber(i), |
13708 NONE)); | 13722 NONE)); |
13709 } | 13723 } |
13710 | 13724 |
13711 return *locales; | 13725 return *locales; |
13712 } | 13726 } |
13713 | 13727 |
13714 | 13728 |
13715 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultICULocale) { | 13729 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultICULocale) { |
13716 HandleScope scope(isolate); | 13730 HandleScope scope(isolate); |
13717 Factory* factory = isolate->factory(); | 13731 Factory* factory = isolate->factory(); |
13718 | 13732 |
13719 ASSERT(args.length() == 0); | 13733 ASSERT(args.length() == 0); |
13720 | 13734 |
13721 icu::Locale default_locale; | 13735 icu::Locale default_locale; |
13722 | 13736 |
13723 // Set the locale | 13737 // Set the locale |
13724 char result[ULOC_FULLNAME_CAPACITY]; | 13738 char result[ULOC_FULLNAME_CAPACITY]; |
13725 UErrorCode status = U_ZERO_ERROR; | 13739 UErrorCode status = U_ZERO_ERROR; |
13726 uloc_toLanguageTag( | 13740 uloc_toLanguageTag( |
13727 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 13741 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
13728 if (U_SUCCESS(status)) { | 13742 if (U_SUCCESS(status)) { |
13729 return *factory->NewStringFromOneByte(OneByteVector(result)); | 13743 return *factory->NewStringFromOneByte( |
| 13744 OneByteVector(result)).ToHandleChecked(); |
13730 } | 13745 } |
13731 | 13746 |
13732 return *factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("und")); | 13747 return *factory->NewStringFromStaticAscii("und"); |
13733 } | 13748 } |
13734 | 13749 |
13735 | 13750 |
13736 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) { | 13751 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) { |
13737 HandleScope scope(isolate); | 13752 HandleScope scope(isolate); |
| 13753 Factory* factory = isolate->factory(); |
13738 | 13754 |
13739 ASSERT(args.length() == 1); | 13755 ASSERT(args.length() == 1); |
13740 | 13756 |
13741 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); | 13757 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); |
13742 | 13758 |
13743 uint32_t length = static_cast<uint32_t>(input->length()->Number()); | 13759 uint32_t length = static_cast<uint32_t>(input->length()->Number()); |
13744 Handle<FixedArray> output = isolate->factory()->NewFixedArray(length); | 13760 Handle<FixedArray> output = factory->NewFixedArray(length); |
13745 Handle<Name> maximized = | 13761 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); |
13746 isolate->factory()->NewStringFromAscii(CStrVector("maximized")); | 13762 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) { | 13763 for (unsigned int i = 0; i < length; ++i) { |
13750 Handle<Object> locale_id; | 13764 Handle<Object> locale_id; |
13751 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13765 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13752 isolate, locale_id, Object::GetElement(isolate, input, i)); | 13766 isolate, locale_id, Object::GetElement(isolate, input, i)); |
13753 if (!locale_id->IsString()) { | 13767 if (!locale_id->IsString()) { |
13754 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 13768 return isolate->Throw(*factory->illegal_argument_string()); |
13755 } | 13769 } |
13756 | 13770 |
13757 v8::String::Utf8Value utf8_locale_id( | 13771 v8::String::Utf8Value utf8_locale_id( |
13758 v8::Utils::ToLocal(Handle<String>::cast(locale_id))); | 13772 v8::Utils::ToLocal(Handle<String>::cast(locale_id))); |
13759 | 13773 |
13760 UErrorCode error = U_ZERO_ERROR; | 13774 UErrorCode error = U_ZERO_ERROR; |
13761 | 13775 |
13762 // Convert from BCP47 to ICU format. | 13776 // Convert from BCP47 to ICU format. |
13763 // de-DE-u-co-phonebk -> de_DE@collation=phonebook | 13777 // de-DE-u-co-phonebk -> de_DE@collation=phonebook |
13764 char icu_locale[ULOC_FULLNAME_CAPACITY]; | 13778 char icu_locale[ULOC_FULLNAME_CAPACITY]; |
13765 int icu_locale_length = 0; | 13779 int icu_locale_length = 0; |
13766 uloc_forLanguageTag(*utf8_locale_id, icu_locale, ULOC_FULLNAME_CAPACITY, | 13780 uloc_forLanguageTag(*utf8_locale_id, icu_locale, ULOC_FULLNAME_CAPACITY, |
13767 &icu_locale_length, &error); | 13781 &icu_locale_length, &error); |
13768 if (U_FAILURE(error) || icu_locale_length == 0) { | 13782 if (U_FAILURE(error) || icu_locale_length == 0) { |
13769 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 13783 return isolate->Throw(*factory->illegal_argument_string()); |
13770 } | 13784 } |
13771 | 13785 |
13772 // Maximize the locale. | 13786 // Maximize the locale. |
13773 // de_DE@collation=phonebook -> de_Latn_DE@collation=phonebook | 13787 // de_DE@collation=phonebook -> de_Latn_DE@collation=phonebook |
13774 char icu_max_locale[ULOC_FULLNAME_CAPACITY]; | 13788 char icu_max_locale[ULOC_FULLNAME_CAPACITY]; |
13775 uloc_addLikelySubtags( | 13789 uloc_addLikelySubtags( |
13776 icu_locale, icu_max_locale, ULOC_FULLNAME_CAPACITY, &error); | 13790 icu_locale, icu_max_locale, ULOC_FULLNAME_CAPACITY, &error); |
13777 | 13791 |
13778 // Remove extensions from maximized locale. | 13792 // Remove extensions from maximized locale. |
13779 // de_Latn_DE@collation=phonebook -> de_Latn_DE | 13793 // de_Latn_DE@collation=phonebook -> de_Latn_DE |
(...skipping 12 matching lines...) Expand all Loading... |
13792 char base_max_locale[ULOC_FULLNAME_CAPACITY]; | 13806 char base_max_locale[ULOC_FULLNAME_CAPACITY]; |
13793 uloc_toLanguageTag(icu_base_max_locale, base_max_locale, | 13807 uloc_toLanguageTag(icu_base_max_locale, base_max_locale, |
13794 ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13808 ULOC_FULLNAME_CAPACITY, FALSE, &error); |
13795 | 13809 |
13796 // de_DE -> de-DE | 13810 // de_DE -> de-DE |
13797 char base_locale[ULOC_FULLNAME_CAPACITY]; | 13811 char base_locale[ULOC_FULLNAME_CAPACITY]; |
13798 uloc_toLanguageTag( | 13812 uloc_toLanguageTag( |
13799 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error); | 13813 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error); |
13800 | 13814 |
13801 if (U_FAILURE(error)) { | 13815 if (U_FAILURE(error)) { |
13802 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 13816 return isolate->Throw(*factory->illegal_argument_string()); |
13803 } | 13817 } |
13804 | 13818 |
13805 Handle<JSObject> result = | 13819 Handle<JSObject> result = factory->NewJSObject(isolate->object_function()); |
13806 isolate->factory()->NewJSObject(isolate->object_function()); | |
13807 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13820 RETURN_FAILURE_ON_EXCEPTION(isolate, |
13808 JSObject::SetLocalPropertyIgnoreAttributes( | 13821 JSObject::SetLocalPropertyIgnoreAttributes( |
13809 result, | 13822 result, |
13810 maximized, | 13823 maximized, |
13811 isolate->factory()->NewStringFromAscii(CStrVector(base_max_locale)), | 13824 factory->NewStringFromAsciiChecked(base_max_locale), |
13812 NONE)); | 13825 NONE)); |
13813 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13826 RETURN_FAILURE_ON_EXCEPTION(isolate, |
13814 JSObject::SetLocalPropertyIgnoreAttributes( | 13827 JSObject::SetLocalPropertyIgnoreAttributes( |
13815 result, | 13828 result, |
13816 base, | 13829 base, |
13817 isolate->factory()->NewStringFromAscii(CStrVector(base_locale)), | 13830 factory->NewStringFromAsciiChecked(base_locale), |
13818 NONE)); | 13831 NONE)); |
13819 output->set(i, *result); | 13832 output->set(i, *result); |
13820 } | 13833 } |
13821 | 13834 |
13822 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(output); | 13835 Handle<JSArray> result = factory->NewJSArrayWithElements(output); |
13823 result->set_length(Smi::FromInt(length)); | 13836 result->set_length(Smi::FromInt(length)); |
13824 return *result; | 13837 return *result; |
13825 } | 13838 } |
13826 | 13839 |
13827 | 13840 |
13828 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObject) { | 13841 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObject) { |
13829 HandleScope scope(isolate); | 13842 HandleScope scope(isolate); |
13830 | 13843 |
13831 ASSERT(args.length() == 1); | 13844 ASSERT(args.length() == 1); |
13832 | 13845 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13928 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( | 13941 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( |
13929 isolate, locale, options, resolved); | 13942 isolate, locale, options, resolved); |
13930 | 13943 |
13931 if (!date_format) return isolate->ThrowIllegalOperation(); | 13944 if (!date_format) return isolate->ThrowIllegalOperation(); |
13932 | 13945 |
13933 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); | 13946 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); |
13934 | 13947 |
13935 RETURN_FAILURE_ON_EXCEPTION(isolate, | 13948 RETURN_FAILURE_ON_EXCEPTION(isolate, |
13936 JSObject::SetLocalPropertyIgnoreAttributes( | 13949 JSObject::SetLocalPropertyIgnoreAttributes( |
13937 local_object, | 13950 local_object, |
13938 isolate->factory()->NewStringFromAscii(CStrVector("dateFormat")), | 13951 isolate->factory()->NewStringFromStaticAscii("dateFormat"), |
13939 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 13952 isolate->factory()->NewStringFromStaticAscii("valid"), |
13940 NONE)); | 13953 NONE)); |
13941 | 13954 |
13942 // Make object handle weak so we can delete the data format once GC kicks in. | 13955 // 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); | 13956 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
13944 GlobalHandles::MakeWeak(wrapper.location(), | 13957 GlobalHandles::MakeWeak(wrapper.location(), |
13945 reinterpret_cast<void*>(wrapper.location()), | 13958 reinterpret_cast<void*>(wrapper.location()), |
13946 DateFormat::DeleteDateFormat); | 13959 DateFormat::DeleteDateFormat); |
13947 return *local_object; | 13960 return *local_object; |
13948 } | 13961 } |
13949 | 13962 |
(...skipping 10 matching lines...) Expand all Loading... |
13960 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13973 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13961 isolate, value, Execution::ToNumber(isolate, date)); | 13974 isolate, value, Execution::ToNumber(isolate, date)); |
13962 | 13975 |
13963 icu::SimpleDateFormat* date_format = | 13976 icu::SimpleDateFormat* date_format = |
13964 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 13977 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
13965 if (!date_format) return isolate->ThrowIllegalOperation(); | 13978 if (!date_format) return isolate->ThrowIllegalOperation(); |
13966 | 13979 |
13967 icu::UnicodeString result; | 13980 icu::UnicodeString result; |
13968 date_format->format(value->Number(), result); | 13981 date_format->format(value->Number(), result); |
13969 | 13982 |
13970 return *isolate->factory()->NewStringFromTwoByte( | 13983 Handle<String> result_str; |
13971 Vector<const uint16_t>( | 13984 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13972 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 13985 isolate, result_str, |
13973 result.length())); | 13986 isolate->factory()->NewStringFromTwoByte( |
| 13987 Vector<const uint16_t>( |
| 13988 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 13989 result.length()))); |
| 13990 return *result_str; |
13974 } | 13991 } |
13975 | 13992 |
13976 | 13993 |
13977 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateParse) { | 13994 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateParse) { |
13978 HandleScope scope(isolate); | 13995 HandleScope scope(isolate); |
13979 | 13996 |
13980 ASSERT(args.length() == 2); | 13997 ASSERT(args.length() == 2); |
13981 | 13998 |
13982 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 13999 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
13983 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); | 14000 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( | 14040 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat( |
14024 isolate, locale, options, resolved); | 14041 isolate, locale, options, resolved); |
14025 | 14042 |
14026 if (!number_format) return isolate->ThrowIllegalOperation(); | 14043 if (!number_format) return isolate->ThrowIllegalOperation(); |
14027 | 14044 |
14028 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); | 14045 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); |
14029 | 14046 |
14030 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14047 RETURN_FAILURE_ON_EXCEPTION(isolate, |
14031 JSObject::SetLocalPropertyIgnoreAttributes( | 14048 JSObject::SetLocalPropertyIgnoreAttributes( |
14032 local_object, | 14049 local_object, |
14033 isolate->factory()->NewStringFromAscii(CStrVector("numberFormat")), | 14050 isolate->factory()->NewStringFromStaticAscii("numberFormat"), |
14034 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 14051 isolate->factory()->NewStringFromStaticAscii("valid"), |
14035 NONE)); | 14052 NONE)); |
14036 | 14053 |
14037 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14054 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
14038 GlobalHandles::MakeWeak(wrapper.location(), | 14055 GlobalHandles::MakeWeak(wrapper.location(), |
14039 reinterpret_cast<void*>(wrapper.location()), | 14056 reinterpret_cast<void*>(wrapper.location()), |
14040 NumberFormat::DeleteNumberFormat); | 14057 NumberFormat::DeleteNumberFormat); |
14041 return *local_object; | 14058 return *local_object; |
14042 } | 14059 } |
14043 | 14060 |
14044 | 14061 |
14045 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { | 14062 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { |
14046 HandleScope scope(isolate); | 14063 HandleScope scope(isolate); |
14047 | 14064 |
14048 ASSERT(args.length() == 2); | 14065 ASSERT(args.length() == 2); |
14049 | 14066 |
14050 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14067 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
14051 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); | 14068 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); |
14052 | 14069 |
14053 Handle<Object> value; | 14070 Handle<Object> value; |
14054 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14071 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14055 isolate, value, Execution::ToNumber(isolate, number)); | 14072 isolate, value, Execution::ToNumber(isolate, number)); |
14056 | 14073 |
14057 icu::DecimalFormat* number_format = | 14074 icu::DecimalFormat* number_format = |
14058 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); | 14075 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); |
14059 if (!number_format) return isolate->ThrowIllegalOperation(); | 14076 if (!number_format) return isolate->ThrowIllegalOperation(); |
14060 | 14077 |
14061 icu::UnicodeString result; | 14078 icu::UnicodeString result; |
14062 number_format->format(value->Number(), result); | 14079 number_format->format(value->Number(), result); |
14063 | 14080 |
14064 return *isolate->factory()->NewStringFromTwoByte( | 14081 Handle<String> result_str; |
14065 Vector<const uint16_t>( | 14082 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14066 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14083 isolate, result_str, |
14067 result.length())); | 14084 isolate->factory()->NewStringFromTwoByte( |
| 14085 Vector<const uint16_t>( |
| 14086 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14087 result.length()))); |
| 14088 return *result_str; |
14068 } | 14089 } |
14069 | 14090 |
14070 | 14091 |
14071 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) { | 14092 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) { |
14072 HandleScope scope(isolate); | 14093 HandleScope scope(isolate); |
14073 | 14094 |
14074 ASSERT(args.length() == 2); | 14095 ASSERT(args.length() == 2); |
14075 | 14096 |
14076 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14097 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
14077 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); | 14098 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( | 14148 icu::Collator* collator = Collator::InitializeCollator( |
14128 isolate, locale, options, resolved); | 14149 isolate, locale, options, resolved); |
14129 | 14150 |
14130 if (!collator) return isolate->ThrowIllegalOperation(); | 14151 if (!collator) return isolate->ThrowIllegalOperation(); |
14131 | 14152 |
14132 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); | 14153 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); |
14133 | 14154 |
14134 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14155 RETURN_FAILURE_ON_EXCEPTION(isolate, |
14135 JSObject::SetLocalPropertyIgnoreAttributes( | 14156 JSObject::SetLocalPropertyIgnoreAttributes( |
14136 local_object, | 14157 local_object, |
14137 isolate->factory()->NewStringFromAscii(CStrVector("collator")), | 14158 isolate->factory()->NewStringFromStaticAscii("collator"), |
14138 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 14159 isolate->factory()->NewStringFromStaticAscii("valid"), |
14139 NONE)); | 14160 NONE)); |
14140 | 14161 |
14141 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14162 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
14142 GlobalHandles::MakeWeak(wrapper.location(), | 14163 GlobalHandles::MakeWeak(wrapper.location(), |
14143 reinterpret_cast<void*>(wrapper.location()), | 14164 reinterpret_cast<void*>(wrapper.location()), |
14144 Collator::DeleteCollator); | 14165 Collator::DeleteCollator); |
14145 return *local_object; | 14166 return *local_object; |
14146 } | 14167 } |
14147 | 14168 |
14148 | 14169 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14189 | 14210 |
14190 // TODO(mnita): check Normalizer2 (not available in ICU 46) | 14211 // TODO(mnita): check Normalizer2 (not available in ICU 46) |
14191 UErrorCode status = U_ZERO_ERROR; | 14212 UErrorCode status = U_ZERO_ERROR; |
14192 icu::UnicodeString result; | 14213 icu::UnicodeString result; |
14193 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, | 14214 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, |
14194 result, status); | 14215 result, status); |
14195 if (U_FAILURE(status)) { | 14216 if (U_FAILURE(status)) { |
14196 return isolate->heap()->undefined_value(); | 14217 return isolate->heap()->undefined_value(); |
14197 } | 14218 } |
14198 | 14219 |
14199 return *isolate->factory()->NewStringFromTwoByte( | 14220 Handle<String> result_str; |
14200 Vector<const uint16_t>( | 14221 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14201 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14222 isolate, result_str, |
14202 result.length())); | 14223 isolate->factory()->NewStringFromTwoByte( |
| 14224 Vector<const uint16_t>( |
| 14225 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14226 result.length()))); |
| 14227 return *result_str; |
14203 } | 14228 } |
14204 | 14229 |
14205 | 14230 |
14206 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14231 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { |
14207 HandleScope scope(isolate); | 14232 HandleScope scope(isolate); |
14208 | 14233 |
14209 ASSERT(args.length() == 3); | 14234 ASSERT(args.length() == 3); |
14210 | 14235 |
14211 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14236 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14212 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14237 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
(...skipping 14 matching lines...) Expand all Loading... |
14227 | 14252 |
14228 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14253 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14229 | 14254 |
14230 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); | 14255 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); |
14231 // Make sure that the pointer to adopted text is NULL. | 14256 // Make sure that the pointer to adopted text is NULL. |
14232 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); | 14257 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); |
14233 | 14258 |
14234 RETURN_FAILURE_ON_EXCEPTION(isolate, | 14259 RETURN_FAILURE_ON_EXCEPTION(isolate, |
14235 JSObject::SetLocalPropertyIgnoreAttributes( | 14260 JSObject::SetLocalPropertyIgnoreAttributes( |
14236 local_object, | 14261 local_object, |
14237 isolate->factory()->NewStringFromAscii(CStrVector("breakIterator")), | 14262 isolate->factory()->NewStringFromStaticAscii("breakIterator"), |
14238 isolate->factory()->NewStringFromAscii(CStrVector("valid")), | 14263 isolate->factory()->NewStringFromStaticAscii("valid"), |
14239 NONE)); | 14264 NONE)); |
14240 | 14265 |
14241 // Make object handle weak so we can delete the break iterator once GC kicks | 14266 // Make object handle weak so we can delete the break iterator once GC kicks |
14242 // in. | 14267 // in. |
14243 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14268 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
14244 GlobalHandles::MakeWeak(wrapper.location(), | 14269 GlobalHandles::MakeWeak(wrapper.location(), |
14245 reinterpret_cast<void*>(wrapper.location()), | 14270 reinterpret_cast<void*>(wrapper.location()), |
14246 BreakIterator::DeleteBreakIterator); | 14271 BreakIterator::DeleteBreakIterator); |
14247 return *local_object; | 14272 return *local_object; |
14248 } | 14273 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14330 icu::BreakIterator* break_iterator = | 14355 icu::BreakIterator* break_iterator = |
14331 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14356 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14332 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14357 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14333 | 14358 |
14334 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. | 14359 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. |
14335 icu::RuleBasedBreakIterator* rule_based_iterator = | 14360 icu::RuleBasedBreakIterator* rule_based_iterator = |
14336 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); | 14361 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); |
14337 int32_t status = rule_based_iterator->getRuleStatus(); | 14362 int32_t status = rule_based_iterator->getRuleStatus(); |
14338 // Keep return values in sync with JavaScript BreakType enum. | 14363 // Keep return values in sync with JavaScript BreakType enum. |
14339 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { | 14364 if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) { |
14340 return *isolate->factory()->NewStringFromAscii(CStrVector("none")); | 14365 return *isolate->factory()->NewStringFromStaticAscii("none"); |
14341 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { | 14366 } else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) { |
14342 return *isolate->factory()->NewStringFromAscii(CStrVector("number")); | 14367 return *isolate->factory()->NewStringFromStaticAscii("number"); |
14343 } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) { | 14368 } else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) { |
14344 return *isolate->factory()->NewStringFromAscii(CStrVector("letter")); | 14369 return *isolate->factory()->NewStringFromStaticAscii("letter"); |
14345 } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) { | 14370 } else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) { |
14346 return *isolate->factory()->NewStringFromAscii(CStrVector("kana")); | 14371 return *isolate->factory()->NewStringFromStaticAscii("kana"); |
14347 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { | 14372 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { |
14348 return *isolate->factory()->NewStringFromAscii(CStrVector("ideo")); | 14373 return *isolate->factory()->NewStringFromStaticAscii("ideo"); |
14349 } else { | 14374 } else { |
14350 return *isolate->factory()->NewStringFromAscii(CStrVector("unknown")); | 14375 return *isolate->factory()->NewStringFromStaticAscii("unknown"); |
14351 } | 14376 } |
14352 } | 14377 } |
14353 #endif // V8_I18N_SUPPORT | 14378 #endif // V8_I18N_SUPPORT |
14354 | 14379 |
14355 | 14380 |
14356 // Finds the script object from the script data. NOTE: This operation uses | 14381 // Finds the script object from the script data. NOTE: This operation uses |
14357 // heap traversal to find the function generated for the source position | 14382 // heap traversal to find the function generated for the source position |
14358 // for the requested break point. For lazily compiled functions several heap | 14383 // for the requested break point. For lazily compiled functions several heap |
14359 // traversals might be required rendering this operation as a rather slow | 14384 // traversals might be required rendering this operation as a rather slow |
14360 // operation. However for setting break points which is normally done through | 14385 // operation. However for setting break points which is normally done through |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14439 | 14464 |
14440 | 14465 |
14441 // Returns V8 version as a string. | 14466 // Returns V8 version as a string. |
14442 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 14467 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
14443 HandleScope scope(isolate); | 14468 HandleScope scope(isolate); |
14444 ASSERT(args.length() == 0); | 14469 ASSERT(args.length() == 0); |
14445 | 14470 |
14446 const char* version_string = v8::V8::GetVersion(); | 14471 const char* version_string = v8::V8::GetVersion(); |
14447 | 14472 |
14448 return *isolate->factory()->NewStringFromOneByte( | 14473 return *isolate->factory()->NewStringFromOneByte( |
14449 OneByteVector(version_string), NOT_TENURED); | 14474 OneByteVector(version_string), NOT_TENURED).ToHandleChecked(); |
14450 } | 14475 } |
14451 | 14476 |
14452 | 14477 |
14453 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { | 14478 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { |
14454 SealHandleScope shs(isolate); | 14479 SealHandleScope shs(isolate); |
14455 ASSERT(args.length() == 1); | 14480 ASSERT(args.length() == 1); |
14456 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 14481 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
14457 const char* message = GetBailoutReason( | 14482 const char* message = GetBailoutReason( |
14458 static_cast<BailoutReason>(message_id)); | 14483 static_cast<BailoutReason>(message_id)); |
14459 OS::PrintError("abort: %s\n", message); | 14484 OS::PrintError("abort: %s\n", message); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14651 Factory* factory = isolate->factory(); | 14676 Factory* factory = isolate->factory(); |
14652 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 14677 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
14653 int index = 0; | 14678 int index = 0; |
14654 bool inline_runtime_functions = false; | 14679 bool inline_runtime_functions = false; |
14655 #define ADD_ENTRY(Name, argc, ressize) \ | 14680 #define ADD_ENTRY(Name, argc, ressize) \ |
14656 { \ | 14681 { \ |
14657 HandleScope inner(isolate); \ | 14682 HandleScope inner(isolate); \ |
14658 Handle<String> name; \ | 14683 Handle<String> name; \ |
14659 /* Inline runtime functions have an underscore in front of the name. */ \ | 14684 /* Inline runtime functions have an underscore in front of the name. */ \ |
14660 if (inline_runtime_functions) { \ | 14685 if (inline_runtime_functions) { \ |
14661 name = factory->NewStringFromAscii( \ | 14686 name = factory->NewStringFromOneByte( \ |
14662 Vector<const char>("_" #Name, StrLength("_" #Name))); \ | 14687 STATIC_ASCII_VECTOR("_" #Name)).ToHandleChecked(); \ |
14663 } else { \ | 14688 } else { \ |
14664 name = factory->NewStringFromAscii( \ | 14689 name = factory->NewStringFromOneByte( \ |
14665 Vector<const char>(#Name, StrLength(#Name))); \ | 14690 STATIC_ASCII_VECTOR(#Name)).ToHandleChecked(); \ |
14666 } \ | 14691 } \ |
14667 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ | 14692 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ |
14668 pair_elements->set(0, *name); \ | 14693 pair_elements->set(0, *name); \ |
14669 pair_elements->set(1, Smi::FromInt(argc)); \ | 14694 pair_elements->set(1, Smi::FromInt(argc)); \ |
14670 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ | 14695 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ |
14671 elements->set(index++, *pair); \ | 14696 elements->set(index++, *pair); \ |
14672 } | 14697 } |
14673 inline_runtime_functions = false; | 14698 inline_runtime_functions = false; |
14674 RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 14699 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
14675 // Calling hidden runtime functions should just throw. | 14700 // Calling hidden runtime functions should just throw. |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15108 } | 15133 } |
15109 } | 15134 } |
15110 | 15135 |
15111 | 15136 |
15112 void Runtime::OutOfMemory() { | 15137 void Runtime::OutOfMemory() { |
15113 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15138 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15114 UNREACHABLE(); | 15139 UNREACHABLE(); |
15115 } | 15140 } |
15116 | 15141 |
15117 } } // namespace v8::internal | 15142 } } // namespace v8::internal |
OLD | NEW |