OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 4661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4673 ASSERT_EQ(static_cast<int>(subject->hash_field()), | 4673 ASSERT_EQ(static_cast<int>(subject->hash_field()), |
4674 static_cast<int>(hash)); | 4674 static_cast<int>(hash)); |
4675 #endif | 4675 #endif |
4676 subject->set_hash_field(hash); | 4676 subject->set_hash_field(hash); |
4677 } | 4677 } |
4678 return Smi::FromInt(d); | 4678 return Smi::FromInt(d); |
4679 } | 4679 } |
4680 } | 4680 } |
4681 | 4681 |
4682 // Slower case. | 4682 // Slower case. |
4683 return isolate->heap()->NumberFromDouble(StringToDouble(subject, ALLOW_HEX)); | 4683 return isolate->heap()->NumberFromDouble( |
| 4684 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX)); |
4684 } | 4685 } |
4685 | 4686 |
4686 | 4687 |
4687 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) { | 4688 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) { |
4688 NoHandleAllocation ha; | 4689 NoHandleAllocation ha; |
4689 ASSERT(args.length() == 1); | 4690 ASSERT(args.length() == 1); |
4690 | 4691 |
4691 CONVERT_CHECKED(JSArray, codes, args[0]); | 4692 CONVERT_CHECKED(JSArray, codes, args[0]); |
4692 int length = Smi::cast(codes->length())->value(); | 4693 int length = Smi::cast(codes->length())->value(); |
4693 | 4694 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5172 | 5173 |
5173 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { | 5174 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { |
5174 NoHandleAllocation ha; | 5175 NoHandleAllocation ha; |
5175 | 5176 |
5176 CONVERT_CHECKED(String, s, args[0]); | 5177 CONVERT_CHECKED(String, s, args[0]); |
5177 CONVERT_SMI_CHECKED(radix, args[1]); | 5178 CONVERT_SMI_CHECKED(radix, args[1]); |
5178 | 5179 |
5179 s->TryFlatten(); | 5180 s->TryFlatten(); |
5180 | 5181 |
5181 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 5182 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
5182 double value = StringToInt(s, radix); | 5183 double value = StringToInt(isolate->unicode_cache(), s, radix); |
5183 return isolate->heap()->NumberFromDouble(value); | 5184 return isolate->heap()->NumberFromDouble(value); |
5184 } | 5185 } |
5185 | 5186 |
5186 | 5187 |
5187 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { | 5188 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { |
5188 NoHandleAllocation ha; | 5189 NoHandleAllocation ha; |
5189 CONVERT_CHECKED(String, str, args[0]); | 5190 CONVERT_CHECKED(String, str, args[0]); |
5190 | 5191 |
5191 // ECMA-262 section 15.1.2.3, empty string is NaN | 5192 // ECMA-262 section 15.1.2.3, empty string is NaN |
5192 double value = StringToDouble(str, ALLOW_TRAILING_JUNK, OS::nan_value()); | 5193 double value = StringToDouble(isolate->unicode_cache(), |
| 5194 str, ALLOW_TRAILING_JUNK, OS::nan_value()); |
5193 | 5195 |
5194 // Create a number object from the value. | 5196 // Create a number object from the value. |
5195 return isolate->heap()->NumberFromDouble(value); | 5197 return isolate->heap()->NumberFromDouble(value); |
5196 } | 5198 } |
5197 | 5199 |
5198 | 5200 |
5199 template <class Converter> | 5201 template <class Converter> |
5200 MUST_USE_RESULT static MaybeObject* ConvertCaseHelper( | 5202 MUST_USE_RESULT static MaybeObject* ConvertCaseHelper( |
5201 Isolate* isolate, | 5203 Isolate* isolate, |
5202 String* s, | 5204 String* s, |
(...skipping 2869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8072 | 8074 |
8073 CONVERT_ARG_CHECKED(JSArray, output, 1); | 8075 CONVERT_ARG_CHECKED(JSArray, output, 1); |
8074 RUNTIME_ASSERT(output->HasFastElements()); | 8076 RUNTIME_ASSERT(output->HasFastElements()); |
8075 | 8077 |
8076 AssertNoAllocation no_allocation; | 8078 AssertNoAllocation no_allocation; |
8077 | 8079 |
8078 FixedArray* output_array = FixedArray::cast(output->elements()); | 8080 FixedArray* output_array = FixedArray::cast(output->elements()); |
8079 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); | 8081 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); |
8080 bool result; | 8082 bool result; |
8081 if (str->IsAsciiRepresentation()) { | 8083 if (str->IsAsciiRepresentation()) { |
8082 result = DateParser::Parse(str->ToAsciiVector(), output_array); | 8084 result = DateParser::Parse(str->ToAsciiVector(), |
| 8085 output_array, |
| 8086 isolate->unicode_cache()); |
8083 } else { | 8087 } else { |
8084 ASSERT(str->IsTwoByteRepresentation()); | 8088 ASSERT(str->IsTwoByteRepresentation()); |
8085 result = DateParser::Parse(str->ToUC16Vector(), output_array); | 8089 result = DateParser::Parse(str->ToUC16Vector(), |
| 8090 output_array, |
| 8091 isolate->unicode_cache()); |
8086 } | 8092 } |
8087 | 8093 |
8088 if (result) { | 8094 if (result) { |
8089 return *output; | 8095 return *output; |
8090 } else { | 8096 } else { |
8091 return isolate->heap()->null_value(); | 8097 return isolate->heap()->null_value(); |
8092 } | 8098 } |
8093 } | 8099 } |
8094 | 8100 |
8095 | 8101 |
(...skipping 3866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11962 } else { | 11968 } else { |
11963 // Handle last resort GC and make sure to allow future allocations | 11969 // Handle last resort GC and make sure to allow future allocations |
11964 // to grow the heap without causing GCs (if possible). | 11970 // to grow the heap without causing GCs (if possible). |
11965 isolate->counters()->gc_last_resort_from_js()->Increment(); | 11971 isolate->counters()->gc_last_resort_from_js()->Increment(); |
11966 isolate->heap()->CollectAllGarbage(false); | 11972 isolate->heap()->CollectAllGarbage(false); |
11967 } | 11973 } |
11968 } | 11974 } |
11969 | 11975 |
11970 | 11976 |
11971 } } // namespace v8::internal | 11977 } } // namespace v8::internal |
OLD | NEW |