| 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 2787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2798 } else { | 2798 } else { |
| 2799 sliced_string->set_parent(buffer); | 2799 sliced_string->set_parent(buffer); |
| 2800 sliced_string->set_offset(start); | 2800 sliced_string->set_offset(start); |
| 2801 } | 2801 } |
| 2802 ASSERT(sliced_string->parent()->IsSeqString()); | 2802 ASSERT(sliced_string->parent()->IsSeqString()); |
| 2803 return result; | 2803 return result; |
| 2804 } | 2804 } |
| 2805 | 2805 |
| 2806 | 2806 |
| 2807 MaybeObject* Heap::AllocateExternalStringFromAscii( | 2807 MaybeObject* Heap::AllocateExternalStringFromAscii( |
| 2808 ExternalAsciiString::Resource* resource) { | 2808 const ExternalAsciiString::Resource* resource) { |
| 2809 size_t length = resource->length(); | 2809 size_t length = resource->length(); |
| 2810 if (length > static_cast<size_t>(String::kMaxLength)) { | 2810 if (length > static_cast<size_t>(String::kMaxLength)) { |
| 2811 isolate()->context()->mark_out_of_memory(); | 2811 isolate()->context()->mark_out_of_memory(); |
| 2812 return Failure::OutOfMemoryException(); | 2812 return Failure::OutOfMemoryException(); |
| 2813 } | 2813 } |
| 2814 | 2814 |
| 2815 Map* map = external_ascii_string_map(); | 2815 Map* map = external_ascii_string_map(); |
| 2816 Object* result; | 2816 Object* result; |
| 2817 { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 2817 { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); |
| 2818 if (!maybe_result->ToObject(&result)) return maybe_result; | 2818 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2819 } | 2819 } |
| 2820 | 2820 |
| 2821 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); | 2821 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); |
| 2822 external_string->set_length(static_cast<int>(length)); | 2822 external_string->set_length(static_cast<int>(length)); |
| 2823 external_string->set_hash_field(String::kEmptyHashField); | 2823 external_string->set_hash_field(String::kEmptyHashField); |
| 2824 external_string->set_resource(resource); | 2824 external_string->set_resource(resource); |
| 2825 | 2825 |
| 2826 return result; | 2826 return result; |
| 2827 } | 2827 } |
| 2828 | 2828 |
| 2829 | 2829 |
| 2830 MaybeObject* Heap::AllocateExternalStringFromTwoByte( | 2830 MaybeObject* Heap::AllocateExternalStringFromTwoByte( |
| 2831 ExternalTwoByteString::Resource* resource) { | 2831 const ExternalTwoByteString::Resource* resource) { |
| 2832 size_t length = resource->length(); | 2832 size_t length = resource->length(); |
| 2833 if (length > static_cast<size_t>(String::kMaxLength)) { | 2833 if (length > static_cast<size_t>(String::kMaxLength)) { |
| 2834 isolate()->context()->mark_out_of_memory(); | 2834 isolate()->context()->mark_out_of_memory(); |
| 2835 return Failure::OutOfMemoryException(); | 2835 return Failure::OutOfMemoryException(); |
| 2836 } | 2836 } |
| 2837 | 2837 |
| 2838 // For small strings we check whether the resource contains only | 2838 // For small strings we check whether the resource contains only |
| 2839 // ASCII characters. If yes, we use a different string map. | 2839 // ASCII characters. If yes, we use a different string map. |
| 2840 static const size_t kAsciiCheckLengthLimit = 32; | 2840 static const size_t kAsciiCheckLengthLimit = 32; |
| 2841 bool is_ascii = length <= kAsciiCheckLengthLimit && | 2841 bool is_ascii = length <= kAsciiCheckLengthLimit && |
| (...skipping 3433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6275 } | 6275 } |
| 6276 | 6276 |
| 6277 | 6277 |
| 6278 void ExternalStringTable::TearDown() { | 6278 void ExternalStringTable::TearDown() { |
| 6279 new_space_strings_.Free(); | 6279 new_space_strings_.Free(); |
| 6280 old_space_strings_.Free(); | 6280 old_space_strings_.Free(); |
| 6281 } | 6281 } |
| 6282 | 6282 |
| 6283 | 6283 |
| 6284 } } // namespace v8::internal | 6284 } } // namespace v8::internal |
| OLD | NEW |