OLD | NEW |
1 // Copyright (c) 2005, 2007, Google Inc. | 1 // Copyright (c) 2005, 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserv
ed. | 3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserv
ed. |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 #if FORCE_SYSTEM_MALLOC | 206 #if FORCE_SYSTEM_MALLOC |
207 | 207 |
208 #if OS(MACOSX) | 208 #if OS(MACOSX) |
209 #include <malloc/malloc.h> | 209 #include <malloc/malloc.h> |
210 #elif OS(WIN) | 210 #elif OS(WIN) |
211 #include <malloc.h> | 211 #include <malloc.h> |
212 #endif | 212 #endif |
213 | 213 |
214 namespace WTF { | 214 namespace WTF { |
215 | 215 |
| 216 size_t fastMallocGoodSize(size_t bytes) |
| 217 { |
| 218 #if OS(MACOSX) |
| 219 return malloc_good_size(bytes); |
| 220 #else |
| 221 return bytes; |
| 222 #endif |
| 223 } |
| 224 |
216 void* fastMalloc(size_t n) | 225 void* fastMalloc(size_t n) |
217 { | 226 { |
218 ASSERT(!isForbidden()); | 227 ASSERT(!isForbidden()); |
219 | 228 |
220 void* result = malloc(n); | 229 void* result = malloc(n); |
221 ASSERT(result); // We expect tcmalloc underneath, which would crash instead
of getting here. | 230 ASSERT(result); // We expect tcmalloc underneath, which would crash instead
of getting here. |
222 | 231 |
223 return result; | 232 return result; |
224 } | 233 } |
225 | 234 |
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 } PageHeapUnion; | 2459 } PageHeapUnion; |
2451 | 2460 |
2452 static inline TCMalloc_PageHeap* getPageHeap() | 2461 static inline TCMalloc_PageHeap* getPageHeap() |
2453 { | 2462 { |
2454 PageHeapUnion u = { &pageheap_memory[0] }; | 2463 PageHeapUnion u = { &pageheap_memory[0] }; |
2455 return u.m_pageHeap; | 2464 return u.m_pageHeap; |
2456 } | 2465 } |
2457 | 2466 |
2458 #define pageheap getPageHeap() | 2467 #define pageheap getPageHeap() |
2459 | 2468 |
| 2469 size_t fastMallocGoodSize(size_t bytes) |
| 2470 { |
| 2471 if (!phinited) |
| 2472 TCMalloc_ThreadCache::InitModule(); |
| 2473 return AllocationSize(bytes); |
| 2474 } |
| 2475 |
2460 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY | 2476 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY |
2461 | 2477 |
2462 #if HAVE(DISPATCH_H) || OS(WIN) | 2478 #if HAVE(DISPATCH_H) || OS(WIN) |
2463 | 2479 |
2464 void TCMalloc_PageHeap::periodicScavenge() | 2480 void TCMalloc_PageHeap::periodicScavenge() |
2465 { | 2481 { |
2466 SpinLockHolder h(&pageheap_lock); | 2482 SpinLockHolder h(&pageheap_lock); |
2467 pageheap->scavenge(); | 2483 pageheap->scavenge(); |
2468 | 2484 |
2469 if (shouldScavenge()) { | 2485 if (shouldScavenge()) { |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3875 void FastMallocZone::init() | 3891 void FastMallocZone::init() |
3876 { | 3892 { |
3877 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); | 3893 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); |
3878 } | 3894 } |
3879 | 3895 |
3880 #endif // OS(MACOSX) | 3896 #endif // OS(MACOSX) |
3881 | 3897 |
3882 } // namespace WTF | 3898 } // namespace WTF |
3883 | 3899 |
3884 #endif // FORCE_SYSTEM_MALLOC | 3900 #endif // FORCE_SYSTEM_MALLOC |
OLD | NEW |