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 14015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14026 string_value1.length(), | 14026 string_value1.length(), |
14027 u_string2, | 14027 u_string2, |
14028 string_value2.length(), | 14028 string_value2.length(), |
14029 status); | 14029 status); |
14030 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); | 14030 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
14031 | 14031 |
14032 return *isolate->factory()->NewNumberFromInt(result); | 14032 return *isolate->factory()->NewNumberFromInt(result); |
14033 } | 14033 } |
14034 | 14034 |
14035 | 14035 |
| 14036 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringNormalize) { |
| 14037 HandleScope scope(isolate); |
| 14038 static const UNormalizationMode normalizationForms[] = |
| 14039 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; |
| 14040 |
| 14041 ASSERT(args.length() == 2); |
| 14042 |
| 14043 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); |
| 14044 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); |
| 14045 |
| 14046 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); |
| 14047 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value); |
| 14048 |
| 14049 // TODO(mnita): check Normalizer2 (not available in ICU 46) |
| 14050 UErrorCode status = U_ZERO_ERROR; |
| 14051 icu::UnicodeString result; |
| 14052 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, |
| 14053 result, status); |
| 14054 if (U_FAILURE(status)) { |
| 14055 return isolate->heap()->undefined_value(); |
| 14056 } |
| 14057 |
| 14058 return *isolate->factory()->NewStringFromTwoByte( |
| 14059 Vector<const uint16_t>( |
| 14060 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14061 result.length())); |
| 14062 } |
| 14063 |
| 14064 |
14036 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14065 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { |
14037 HandleScope scope(isolate); | 14066 HandleScope scope(isolate); |
14038 | 14067 |
14039 ASSERT(args.length() == 3); | 14068 ASSERT(args.length() == 3); |
14040 | 14069 |
14041 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14070 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14042 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14071 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14043 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14072 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14044 | 14073 |
14045 Handle<ObjectTemplateInfo> break_iterator_template = | 14074 Handle<ObjectTemplateInfo> break_iterator_template = |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14836 // Handle last resort GC and make sure to allow future allocations | 14865 // Handle last resort GC and make sure to allow future allocations |
14837 // to grow the heap without causing GCs (if possible). | 14866 // to grow the heap without causing GCs (if possible). |
14838 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14867 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14839 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14868 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14840 "Runtime::PerformGC"); | 14869 "Runtime::PerformGC"); |
14841 } | 14870 } |
14842 } | 14871 } |
14843 | 14872 |
14844 | 14873 |
14845 } } // namespace v8::internal | 14874 } } // namespace v8::internal |
OLD | NEW |