| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2009, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2009, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 StringImpl** header = static_cast<StringImpl**>(WTF::Partitions::FastMalloc( | 59 StringImpl** header = static_cast<StringImpl**>(WTF::Partitions::FastMalloc( |
| 60 sizeof(StringImpl*) + size, WTF_HEAP_PROFILER_TYPE_NAME(StringImpl*))); | 60 sizeof(StringImpl*) + size, WTF_HEAP_PROFILER_TYPE_NAME(StringImpl*))); |
| 61 *header = underlying_string; | 61 *header = underlying_string; |
| 62 return header + 1; | 62 return header + 1; |
| 63 } | 63 } |
| 64 | 64 |
| 65 static void* Reallocate(void* pointer, CFIndex new_size, CFOptionFlags, void*) { | 65 static void* Reallocate(void* pointer, CFIndex new_size, CFOptionFlags, void*) { |
| 66 size_t new_allocation_size = sizeof(StringImpl*) + new_size; | 66 size_t new_allocation_size = sizeof(StringImpl*) + new_size; |
| 67 StringImpl** header = static_cast<StringImpl**>(pointer) - 1; | 67 StringImpl** header = static_cast<StringImpl**>(pointer) - 1; |
| 68 ASSERT(!*header); | 68 DCHECK(!*header); |
| 69 header = static_cast<StringImpl**>(WTF::Partitions::FastRealloc( | 69 header = static_cast<StringImpl**>(WTF::Partitions::FastRealloc( |
| 70 header, new_allocation_size, WTF_HEAP_PROFILER_TYPE_NAME(StringImpl*))); | 70 header, new_allocation_size, WTF_HEAP_PROFILER_TYPE_NAME(StringImpl*))); |
| 71 return header + 1; | 71 return header + 1; |
| 72 } | 72 } |
| 73 | 73 |
| 74 static void DeallocateOnMainThread(void* header_pointer) { | 74 static void DeallocateOnMainThread(void* header_pointer) { |
| 75 StringImpl** header = static_cast<StringImpl**>(header_pointer); | 75 StringImpl** header = static_cast<StringImpl**>(header_pointer); |
| 76 StringImpl* underlying_string = *header; | 76 StringImpl* underlying_string = *header; |
| 77 DCHECK(underlying_string); | 77 DCHECK(underlying_string); |
| 78 underlying_string->Deref(); // Balanced by call to ref in allocate above. | 78 underlying_string->Deref(); // Balanced by call to ref in allocate above. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // StringWrapperCFAllocator. If it is, then we could find the original | 155 // StringWrapperCFAllocator. If it is, then we could find the original |
| 156 // StringImpl and just return that. But to do that we'd have to compute the | 156 // StringImpl and just return that. But to do that we'd have to compute the |
| 157 // offset from CFStringRef to the allocated block; the CFStringRef is *not* at | 157 // offset from CFStringRef to the allocated block; the CFStringRef is *not* at |
| 158 // the start of an allocated block. Testing shows 1000x more calls to | 158 // the start of an allocated block. Testing shows 1000x more calls to |
| 159 // createCFString than calls to the create functions with the appropriate | 159 // createCFString than calls to the create functions with the appropriate |
| 160 // allocator, so it's probably not urgent optimize that case. | 160 // allocator, so it's probably not urgent optimize that case. |
| 161 | 161 |
| 162 } // namespace WTF | 162 } // namespace WTF |
| 163 | 163 |
| 164 #endif // OS(MACOSX) | 164 #endif // OS(MACOSX) |
| OLD | NEW |