| 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 | |
| 225 void* fastMalloc(size_t n) | 216 void* fastMalloc(size_t n) |
| 226 { | 217 { |
| 227 ASSERT(!isForbidden()); | 218 ASSERT(!isForbidden()); |
| 228 | 219 |
| 229 void* result = malloc(n); | 220 void* result = malloc(n); |
| 230 ASSERT(result); // We expect tcmalloc underneath, which would crash instead
of getting here. | 221 ASSERT(result); // We expect tcmalloc underneath, which would crash instead
of getting here. |
| 231 | 222 |
| 232 return result; | 223 return result; |
| 233 } | 224 } |
| 234 | 225 |
| (...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2459 } PageHeapUnion; | 2450 } PageHeapUnion; |
| 2460 | 2451 |
| 2461 static inline TCMalloc_PageHeap* getPageHeap() | 2452 static inline TCMalloc_PageHeap* getPageHeap() |
| 2462 { | 2453 { |
| 2463 PageHeapUnion u = { &pageheap_memory[0] }; | 2454 PageHeapUnion u = { &pageheap_memory[0] }; |
| 2464 return u.m_pageHeap; | 2455 return u.m_pageHeap; |
| 2465 } | 2456 } |
| 2466 | 2457 |
| 2467 #define pageheap getPageHeap() | 2458 #define pageheap getPageHeap() |
| 2468 | 2459 |
| 2469 size_t fastMallocGoodSize(size_t bytes) | |
| 2470 { | |
| 2471 if (!phinited) | |
| 2472 TCMalloc_ThreadCache::InitModule(); | |
| 2473 return AllocationSize(bytes); | |
| 2474 } | |
| 2475 | |
| 2476 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY | 2460 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY |
| 2477 | 2461 |
| 2478 #if HAVE(DISPATCH_H) || OS(WIN) | 2462 #if HAVE(DISPATCH_H) || OS(WIN) |
| 2479 | 2463 |
| 2480 void TCMalloc_PageHeap::periodicScavenge() | 2464 void TCMalloc_PageHeap::periodicScavenge() |
| 2481 { | 2465 { |
| 2482 SpinLockHolder h(&pageheap_lock); | 2466 SpinLockHolder h(&pageheap_lock); |
| 2483 pageheap->scavenge(); | 2467 pageheap->scavenge(); |
| 2484 | 2468 |
| 2485 if (shouldScavenge()) { | 2469 if (shouldScavenge()) { |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3891 void FastMallocZone::init() | 3875 void FastMallocZone::init() |
| 3892 { | 3876 { |
| 3893 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); | 3877 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); |
| 3894 } | 3878 } |
| 3895 | 3879 |
| 3896 #endif // OS(MACOSX) | 3880 #endif // OS(MACOSX) |
| 3897 | 3881 |
| 3898 } // namespace WTF | 3882 } // namespace WTF |
| 3899 | 3883 |
| 3900 #endif // FORCE_SYSTEM_MALLOC | 3884 #endif // FORCE_SYSTEM_MALLOC |
| OLD | NEW |