| 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 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2912     sliced_string->set_parent(buffer); | 2912     sliced_string->set_parent(buffer); | 
| 2913     sliced_string->set_offset(start); | 2913     sliced_string->set_offset(start); | 
| 2914   } | 2914   } | 
| 2915   ASSERT(sliced_string->parent()->IsSeqString() || | 2915   ASSERT(sliced_string->parent()->IsSeqString() || | 
| 2916          sliced_string->parent()->IsExternalString()); | 2916          sliced_string->parent()->IsExternalString()); | 
| 2917   return result; | 2917   return result; | 
| 2918 } | 2918 } | 
| 2919 | 2919 | 
| 2920 | 2920 | 
| 2921 MaybeObject* Heap::AllocateExternalStringFromAscii( | 2921 MaybeObject* Heap::AllocateExternalStringFromAscii( | 
| 2922     ExternalAsciiString::Resource* resource) { | 2922     const ExternalAsciiString::Resource* resource) { | 
| 2923   size_t length = resource->length(); | 2923   size_t length = resource->length(); | 
| 2924   if (length > static_cast<size_t>(String::kMaxLength)) { | 2924   if (length > static_cast<size_t>(String::kMaxLength)) { | 
| 2925     isolate()->context()->mark_out_of_memory(); | 2925     isolate()->context()->mark_out_of_memory(); | 
| 2926     return Failure::OutOfMemoryException(); | 2926     return Failure::OutOfMemoryException(); | 
| 2927   } | 2927   } | 
| 2928 | 2928 | 
| 2929   Map* map = external_ascii_string_map(); | 2929   Map* map = external_ascii_string_map(); | 
| 2930   Object* result; | 2930   Object* result; | 
| 2931   { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 2931   { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); | 
| 2932     if (!maybe_result->ToObject(&result)) return maybe_result; | 2932     if (!maybe_result->ToObject(&result)) return maybe_result; | 
| 2933   } | 2933   } | 
| 2934 | 2934 | 
| 2935   ExternalAsciiString* external_string = ExternalAsciiString::cast(result); | 2935   ExternalAsciiString* external_string = ExternalAsciiString::cast(result); | 
| 2936   external_string->set_length(static_cast<int>(length)); | 2936   external_string->set_length(static_cast<int>(length)); | 
| 2937   external_string->set_hash_field(String::kEmptyHashField); | 2937   external_string->set_hash_field(String::kEmptyHashField); | 
| 2938   external_string->set_resource(resource); | 2938   external_string->set_resource(resource); | 
| 2939 | 2939 | 
| 2940   return result; | 2940   return result; | 
| 2941 } | 2941 } | 
| 2942 | 2942 | 
| 2943 | 2943 | 
| 2944 MaybeObject* Heap::AllocateExternalStringFromTwoByte( | 2944 MaybeObject* Heap::AllocateExternalStringFromTwoByte( | 
| 2945     ExternalTwoByteString::Resource* resource) { | 2945     const ExternalTwoByteString::Resource* resource) { | 
| 2946   size_t length = resource->length(); | 2946   size_t length = resource->length(); | 
| 2947   if (length > static_cast<size_t>(String::kMaxLength)) { | 2947   if (length > static_cast<size_t>(String::kMaxLength)) { | 
| 2948     isolate()->context()->mark_out_of_memory(); | 2948     isolate()->context()->mark_out_of_memory(); | 
| 2949     return Failure::OutOfMemoryException(); | 2949     return Failure::OutOfMemoryException(); | 
| 2950   } | 2950   } | 
| 2951 | 2951 | 
| 2952   // For small strings we check whether the resource contains only | 2952   // For small strings we check whether the resource contains only | 
| 2953   // ASCII characters.  If yes, we use a different string map. | 2953   // ASCII characters.  If yes, we use a different string map. | 
| 2954   static const size_t kAsciiCheckLengthLimit = 32; | 2954   static const size_t kAsciiCheckLengthLimit = 32; | 
| 2955   bool is_ascii = length <= kAsciiCheckLengthLimit && | 2955   bool is_ascii = length <= kAsciiCheckLengthLimit && | 
| (...skipping 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6347   } | 6347   } | 
| 6348   isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 6348   isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); | 
| 6349   for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 6349   for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { | 
| 6350     next = chunk->next_chunk(); | 6350     next = chunk->next_chunk(); | 
| 6351     isolate_->memory_allocator()->Free(chunk); | 6351     isolate_->memory_allocator()->Free(chunk); | 
| 6352   } | 6352   } | 
| 6353   chunks_queued_for_free_ = NULL; | 6353   chunks_queued_for_free_ = NULL; | 
| 6354 } | 6354 } | 
| 6355 | 6355 | 
| 6356 } }  // namespace v8::internal | 6356 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|