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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "unicode/dcfmtsym.h" | 76 #include "unicode/dcfmtsym.h" |
77 #include "unicode/decimfmt.h" | 77 #include "unicode/decimfmt.h" |
78 #include "unicode/dtfmtsym.h" | 78 #include "unicode/dtfmtsym.h" |
79 #include "unicode/dtptngen.h" | 79 #include "unicode/dtptngen.h" |
80 #include "unicode/locid.h" | 80 #include "unicode/locid.h" |
81 #include "unicode/numfmt.h" | 81 #include "unicode/numfmt.h" |
82 #include "unicode/numsys.h" | 82 #include "unicode/numsys.h" |
83 #include "unicode/smpdtfmt.h" | 83 #include "unicode/smpdtfmt.h" |
84 #include "unicode/timezone.h" | 84 #include "unicode/timezone.h" |
85 #include "unicode/uchar.h" | 85 #include "unicode/uchar.h" |
| 86 #include "unicode/ucol.h" |
86 #include "unicode/ucurr.h" | 87 #include "unicode/ucurr.h" |
87 #include "unicode/uloc.h" | 88 #include "unicode/uloc.h" |
88 #include "unicode/unum.h" | 89 #include "unicode/unum.h" |
89 #include "unicode/uversion.h" | 90 #include "unicode/uversion.h" |
90 #endif | 91 #endif |
91 | 92 |
92 #ifndef _STLP_VENDOR_CSTD | 93 #ifndef _STLP_VENDOR_CSTD |
93 // STLPort doesn't import fpclassify and isless into the std namespace. | 94 // STLPort doesn't import fpclassify and isless into the std namespace. |
94 using std::fpclassify; | 95 using std::fpclassify; |
95 using std::isless; | 96 using std::isless; |
(...skipping 13692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13788 return *isolate->factory()->NewNumber(result.getDouble()); | 13789 return *isolate->factory()->NewNumber(result.getDouble()); |
13789 case icu::Formattable::kLong: | 13790 case icu::Formattable::kLong: |
13790 return *isolate->factory()->NewNumberFromInt(result.getLong()); | 13791 return *isolate->factory()->NewNumberFromInt(result.getLong()); |
13791 case icu::Formattable::kInt64: | 13792 case icu::Formattable::kInt64: |
13792 return *isolate->factory()->NewNumber( | 13793 return *isolate->factory()->NewNumber( |
13793 static_cast<double>(result.getInt64())); | 13794 static_cast<double>(result.getInt64())); |
13794 default: | 13795 default: |
13795 return isolate->heap()->undefined_value(); | 13796 return isolate->heap()->undefined_value(); |
13796 } | 13797 } |
13797 } | 13798 } |
| 13799 |
| 13800 |
| 13801 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCollator) { |
| 13802 HandleScope scope(isolate); |
| 13803 |
| 13804 ASSERT(args.length() == 3); |
| 13805 |
| 13806 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
| 13807 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
| 13808 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
| 13809 |
| 13810 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); |
| 13811 |
| 13812 // Create an empty object wrapper. |
| 13813 bool has_pending_exception = false; |
| 13814 Handle<JSObject> local_object = Execution::InstantiateObject( |
| 13815 collator_template, &has_pending_exception); |
| 13816 if (has_pending_exception) { |
| 13817 ASSERT(isolate->has_pending_exception()); |
| 13818 return Failure::Exception(); |
| 13819 } |
| 13820 |
| 13821 // Set collator as internal field of the resulting JS object. |
| 13822 icu::Collator* collator = Collator::InitializeCollator( |
| 13823 isolate, locale, options, resolved); |
| 13824 |
| 13825 if (!collator) return isolate->ThrowIllegalOperation(); |
| 13826 |
| 13827 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); |
| 13828 |
| 13829 RETURN_IF_EMPTY_HANDLE(isolate, |
| 13830 JSObject::SetLocalPropertyIgnoreAttributes( |
| 13831 local_object, |
| 13832 isolate->factory()->NewStringFromAscii(CStrVector("collator")), |
| 13833 isolate->factory()->NewStringFromAscii(CStrVector("valid")), |
| 13834 NONE)); |
| 13835 |
| 13836 Persistent<v8::Object> wrapper(reinterpret_cast<v8::Isolate*>(isolate), |
| 13837 v8::Utils::ToLocal(local_object)); |
| 13838 // Make object handle weak so we can delete the collator once GC kicks in. |
| 13839 wrapper.MakeWeak<void>(NULL, &Collator::DeleteCollator); |
| 13840 Handle<Object> result = Utils::OpenPersistent(wrapper); |
| 13841 wrapper.ClearAndLeak(); |
| 13842 return *result; |
| 13843 } |
| 13844 |
| 13845 |
| 13846 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalCompare) { |
| 13847 HandleScope scope(isolate); |
| 13848 |
| 13849 ASSERT(args.length() == 3); |
| 13850 |
| 13851 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); |
| 13852 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); |
| 13853 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); |
| 13854 |
| 13855 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); |
| 13856 if (!collator) return isolate->ThrowIllegalOperation(); |
| 13857 |
| 13858 v8::String::Value string_value1(v8::Utils::ToLocal(string1)); |
| 13859 v8::String::Value string_value2(v8::Utils::ToLocal(string2)); |
| 13860 const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1); |
| 13861 const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2); |
| 13862 UErrorCode status = U_ZERO_ERROR; |
| 13863 UCollationResult result = collator->compare(u_string1, |
| 13864 string_value1.length(), |
| 13865 u_string2, |
| 13866 string_value2.length(), |
| 13867 status); |
| 13868 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
| 13869 |
| 13870 return *isolate->factory()->NewNumberFromInt(result); |
| 13871 } |
13798 #endif // V8_I18N_SUPPORT | 13872 #endif // V8_I18N_SUPPORT |
13799 | 13873 |
13800 | 13874 |
13801 // Finds the script object from the script data. NOTE: This operation uses | 13875 // Finds the script object from the script data. NOTE: This operation uses |
13802 // heap traversal to find the function generated for the source position | 13876 // heap traversal to find the function generated for the source position |
13803 // for the requested break point. For lazily compiled functions several heap | 13877 // for the requested break point. For lazily compiled functions several heap |
13804 // traversals might be required rendering this operation as a rather slow | 13878 // traversals might be required rendering this operation as a rather slow |
13805 // operation. However for setting break points which is normally done through | 13879 // operation. However for setting break points which is normally done through |
13806 // some kind of user interaction the performance is not crucial. | 13880 // some kind of user interaction the performance is not crucial. |
13807 static Handle<Object> Runtime_GetScriptFromScriptName( | 13881 static Handle<Object> Runtime_GetScriptFromScriptName( |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14404 // Handle last resort GC and make sure to allow future allocations | 14478 // Handle last resort GC and make sure to allow future allocations |
14405 // to grow the heap without causing GCs (if possible). | 14479 // to grow the heap without causing GCs (if possible). |
14406 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14480 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14407 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14481 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14408 "Runtime::PerformGC"); | 14482 "Runtime::PerformGC"); |
14409 } | 14483 } |
14410 } | 14484 } |
14411 | 14485 |
14412 | 14486 |
14413 } } // namespace v8::internal | 14487 } } // namespace v8::internal |
OLD | NEW |