| OLD | NEW |
| 1 // Copyright 2011 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 |
| (...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2811 sliced_string->set_parent(buffer); | 2811 sliced_string->set_parent(buffer); |
| 2812 sliced_string->set_offset(start); | 2812 sliced_string->set_offset(start); |
| 2813 } | 2813 } |
| 2814 ASSERT(sliced_string->parent()->IsSeqString() || | 2814 ASSERT(sliced_string->parent()->IsSeqString() || |
| 2815 sliced_string->parent()->IsExternalString()); | 2815 sliced_string->parent()->IsExternalString()); |
| 2816 return result; | 2816 return result; |
| 2817 } | 2817 } |
| 2818 | 2818 |
| 2819 | 2819 |
| 2820 MaybeObject* Heap::AllocateExternalStringFromAscii( | 2820 MaybeObject* Heap::AllocateExternalStringFromAscii( |
| 2821 ExternalAsciiString::Resource* resource) { | 2821 const ExternalAsciiString::Resource* resource) { |
| 2822 size_t length = resource->length(); | 2822 size_t length = resource->length(); |
| 2823 if (length > static_cast<size_t>(String::kMaxLength)) { | 2823 if (length > static_cast<size_t>(String::kMaxLength)) { |
| 2824 isolate()->context()->mark_out_of_memory(); | 2824 isolate()->context()->mark_out_of_memory(); |
| 2825 return Failure::OutOfMemoryException(); | 2825 return Failure::OutOfMemoryException(); |
| 2826 } | 2826 } |
| 2827 | 2827 |
| 2828 Map* map = external_ascii_string_map(); | 2828 Map* map = external_ascii_string_map(); |
| 2829 Object* result; | 2829 Object* result; |
| 2830 { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 2830 { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); |
| 2831 if (!maybe_result->ToObject(&result)) return maybe_result; | 2831 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2832 } | 2832 } |
| 2833 | 2833 |
| 2834 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); | 2834 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); |
| 2835 external_string->set_length(static_cast<int>(length)); | 2835 external_string->set_length(static_cast<int>(length)); |
| 2836 external_string->set_hash_field(String::kEmptyHashField); | 2836 external_string->set_hash_field(String::kEmptyHashField); |
| 2837 external_string->set_resource(resource); | 2837 external_string->set_resource(resource); |
| 2838 | 2838 |
| 2839 return result; | 2839 return result; |
| 2840 } | 2840 } |
| 2841 | 2841 |
| 2842 | 2842 |
| 2843 MaybeObject* Heap::AllocateExternalStringFromTwoByte( | 2843 MaybeObject* Heap::AllocateExternalStringFromTwoByte( |
| 2844 ExternalTwoByteString::Resource* resource) { | 2844 const ExternalTwoByteString::Resource* resource) { |
| 2845 size_t length = resource->length(); | 2845 size_t length = resource->length(); |
| 2846 if (length > static_cast<size_t>(String::kMaxLength)) { | 2846 if (length > static_cast<size_t>(String::kMaxLength)) { |
| 2847 isolate()->context()->mark_out_of_memory(); | 2847 isolate()->context()->mark_out_of_memory(); |
| 2848 return Failure::OutOfMemoryException(); | 2848 return Failure::OutOfMemoryException(); |
| 2849 } | 2849 } |
| 2850 | 2850 |
| 2851 // For small strings we check whether the resource contains only | 2851 // For small strings we check whether the resource contains only |
| 2852 // ASCII characters. If yes, we use a different string map. | 2852 // ASCII characters. If yes, we use a different string map. |
| 2853 static const size_t kAsciiCheckLengthLimit = 32; | 2853 static const size_t kAsciiCheckLengthLimit = 32; |
| 2854 bool is_ascii = length <= kAsciiCheckLengthLimit && | 2854 bool is_ascii = length <= kAsciiCheckLengthLimit && |
| (...skipping 3434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6289 } | 6289 } |
| 6290 | 6290 |
| 6291 | 6291 |
| 6292 void ExternalStringTable::TearDown() { | 6292 void ExternalStringTable::TearDown() { |
| 6293 new_space_strings_.Free(); | 6293 new_space_strings_.Free(); |
| 6294 old_space_strings_.Free(); | 6294 old_space_strings_.Free(); |
| 6295 } | 6295 } |
| 6296 | 6296 |
| 6297 | 6297 |
| 6298 } } // namespace v8::internal | 6298 } } // namespace v8::internal |
| OLD | NEW |