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 14046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14057 string_value1.length(), | 14057 string_value1.length(), |
14058 u_string2, | 14058 u_string2, |
14059 string_value2.length(), | 14059 string_value2.length(), |
14060 status); | 14060 status); |
14061 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); | 14061 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
14062 | 14062 |
14063 return *isolate->factory()->NewNumberFromInt(result); | 14063 return *isolate->factory()->NewNumberFromInt(result); |
14064 } | 14064 } |
14065 | 14065 |
14066 | 14066 |
| 14067 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringNormalize) { |
| 14068 HandleScope scope(isolate); |
| 14069 static const UNormalizationMode normalizationForms[] = |
| 14070 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; |
| 14071 |
| 14072 ASSERT(args.length() == 2); |
| 14073 |
| 14074 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); |
| 14075 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); |
| 14076 |
| 14077 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); |
| 14078 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value); |
| 14079 |
| 14080 // TODO(mnita): check Normalizer2 (not available in ICU 46) |
| 14081 UErrorCode status = U_ZERO_ERROR; |
| 14082 icu::UnicodeString result; |
| 14083 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, |
| 14084 result, status); |
| 14085 if (U_FAILURE(status)) { |
| 14086 return isolate->heap()->undefined_value(); |
| 14087 } |
| 14088 |
| 14089 return *isolate->factory()->NewStringFromTwoByte( |
| 14090 Vector<const uint16_t>( |
| 14091 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14092 result.length())); |
| 14093 } |
| 14094 |
| 14095 |
14067 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14096 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { |
14068 HandleScope scope(isolate); | 14097 HandleScope scope(isolate); |
14069 | 14098 |
14070 ASSERT(args.length() == 3); | 14099 ASSERT(args.length() == 3); |
14071 | 14100 |
14072 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14101 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14073 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14102 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14074 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14103 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14075 | 14104 |
14076 Handle<ObjectTemplateInfo> break_iterator_template = | 14105 Handle<ObjectTemplateInfo> break_iterator_template = |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14867 // Handle last resort GC and make sure to allow future allocations | 14896 // Handle last resort GC and make sure to allow future allocations |
14868 // to grow the heap without causing GCs (if possible). | 14897 // to grow the heap without causing GCs (if possible). |
14869 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14898 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14870 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14899 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14871 "Runtime::PerformGC"); | 14900 "Runtime::PerformGC"); |
14872 } | 14901 } |
14873 } | 14902 } |
14874 | 14903 |
14875 | 14904 |
14876 } } // namespace v8::internal | 14905 } } // namespace v8::internal |
OLD | NEW |