| 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 13959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13970 string_value1.length(), | 13970 string_value1.length(), |
| 13971 u_string2, | 13971 u_string2, |
| 13972 string_value2.length(), | 13972 string_value2.length(), |
| 13973 status); | 13973 status); |
| 13974 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); | 13974 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
| 13975 | 13975 |
| 13976 return *isolate->factory()->NewNumberFromInt(result); | 13976 return *isolate->factory()->NewNumberFromInt(result); |
| 13977 } | 13977 } |
| 13978 | 13978 |
| 13979 | 13979 |
| 13980 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringNormalize) { |
| 13981 HandleScope scope(isolate); |
| 13982 static const UNormalizationMode normalizationForms[] = |
| 13983 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; |
| 13984 |
| 13985 ASSERT(args.length() == 2); |
| 13986 |
| 13987 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); |
| 13988 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); |
| 13989 |
| 13990 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); |
| 13991 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value); |
| 13992 |
| 13993 // TODO(mnita): check Normalizer2 (not available in ICU 46) |
| 13994 UErrorCode status = U_ZERO_ERROR; |
| 13995 icu::UnicodeString result; |
| 13996 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, |
| 13997 result, status); |
| 13998 if (U_FAILURE(status)) { |
| 13999 return isolate->heap()->undefined_value(); |
| 14000 } |
| 14001 |
| 14002 return *isolate->factory()->NewStringFromTwoByte( |
| 14003 Vector<const uint16_t>( |
| 14004 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
| 14005 result.length())); |
| 14006 } |
| 14007 |
| 14008 |
| 13980 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14009 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { |
| 13981 HandleScope scope(isolate); | 14010 HandleScope scope(isolate); |
| 13982 | 14011 |
| 13983 ASSERT(args.length() == 3); | 14012 ASSERT(args.length() == 3); |
| 13984 | 14013 |
| 13985 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14014 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 13986 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14015 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| 13987 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14016 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
| 13988 | 14017 |
| 13989 Handle<ObjectTemplateInfo> break_iterator_template = | 14018 Handle<ObjectTemplateInfo> break_iterator_template = |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14828 // Handle last resort GC and make sure to allow future allocations | 14857 // Handle last resort GC and make sure to allow future allocations |
| 14829 // to grow the heap without causing GCs (if possible). | 14858 // to grow the heap without causing GCs (if possible). |
| 14830 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14859 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14831 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14860 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14832 "Runtime::PerformGC"); | 14861 "Runtime::PerformGC"); |
| 14833 } | 14862 } |
| 14834 } | 14863 } |
| 14835 | 14864 |
| 14836 | 14865 |
| 14837 } } // namespace v8::internal | 14866 } } // namespace v8::internal |
| OLD | NEW |