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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 447 |
448 #if HAVE(DISPATCH_H) | 448 #if HAVE(DISPATCH_H) |
449 #include <dispatch/dispatch.h> | 449 #include <dispatch/dispatch.h> |
450 #endif | 450 #endif |
451 | 451 |
452 #ifdef __has_include | 452 #ifdef __has_include |
453 #if __has_include(<System/pthread_machdep.h>) | 453 #if __has_include(<System/pthread_machdep.h>) |
454 | 454 |
455 #include <System/pthread_machdep.h> | 455 #include <System/pthread_machdep.h> |
456 | 456 |
457 #if defined(__PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0) | |
458 #define WTF_USE_PTHREAD_GETSPECIFIC_DIRECT 1 | |
459 #endif | |
460 | |
461 #endif | 457 #endif |
462 #endif | 458 #endif |
463 | 459 |
464 #ifndef PRIuS | 460 #ifndef PRIuS |
465 #define PRIuS "zu" | 461 #define PRIuS "zu" |
466 #endif | 462 #endif |
467 | 463 |
468 // Calling pthread_getspecific through a global function pointer is faster than
a normal | 464 // Calling pthread_getspecific through a global function pointer is faster than
a normal |
469 // call to the function on Mac OS X, and it's used in performance-critical code.
So we | 465 // call to the function on Mac OS X, and it's used in performance-critical code.
So we |
470 // use a function pointer. But that's not necessarily faster on other platforms,
and we had | 466 // use a function pointer. But that's not necessarily faster on other platforms,
and we had |
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 // code when a thread is destroyed. | 2689 // code when a thread is destroyed. |
2694 #ifdef HAVE_TLS | 2690 #ifdef HAVE_TLS |
2695 static __thread TCMalloc_ThreadCache *threadlocal_heap; | 2691 static __thread TCMalloc_ThreadCache *threadlocal_heap; |
2696 #endif | 2692 #endif |
2697 // Thread-specific key. Initialization here is somewhat tricky | 2693 // Thread-specific key. Initialization here is somewhat tricky |
2698 // because some Linux startup code invokes malloc() before it | 2694 // because some Linux startup code invokes malloc() before it |
2699 // is in a good enough state to handle pthread_keycreate(). | 2695 // is in a good enough state to handle pthread_keycreate(). |
2700 // Therefore, we use TSD keys only after tsd_inited is set to true. | 2696 // Therefore, we use TSD keys only after tsd_inited is set to true. |
2701 // Until then, we use a slow path to get the heap object. | 2697 // Until then, we use a slow path to get the heap object. |
2702 static bool tsd_inited = false; | 2698 static bool tsd_inited = false; |
2703 #if USE(PTHREAD_GETSPECIFIC_DIRECT) | |
2704 static const pthread_key_t heap_key = __PTK_FRAMEWORK_JAVASCRIPTCORE_KEY0; | |
2705 #else | |
2706 static pthread_key_t heap_key; | 2699 static pthread_key_t heap_key; |
2707 #endif | |
2708 #if OS(WINDOWS) | 2700 #if OS(WINDOWS) |
2709 DWORD tlsIndex = TLS_OUT_OF_INDEXES; | 2701 DWORD tlsIndex = TLS_OUT_OF_INDEXES; |
2710 #endif | 2702 #endif |
2711 | 2703 |
2712 static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap) | 2704 static ALWAYS_INLINE void setThreadHeap(TCMalloc_ThreadCache* heap) |
2713 { | 2705 { |
2714 #if USE(PTHREAD_GETSPECIFIC_DIRECT) | 2706 #if USE(PTHREAD_GETSPECIFIC_DIRECT) |
2715 // Can't have two libraries both doing this in the same process, | 2707 // Can't have two libraries both doing this in the same process, |
2716 // so check and make this crash right away. | 2708 // so check and make this crash right away. |
2717 if (pthread_getspecific(heap_key)) | 2709 if (pthread_getspecific(heap_key)) |
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4202 void FastMallocZone::init() | 4194 void FastMallocZone::init() |
4203 { | 4195 { |
4204 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); | 4196 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); |
4205 } | 4197 } |
4206 | 4198 |
4207 #endif // OS(DARWIN) | 4199 #endif // OS(DARWIN) |
4208 | 4200 |
4209 } // namespace WTF | 4201 } // namespace WTF |
4210 | 4202 |
4211 #endif // FORCE_SYSTEM_MALLOC | 4203 #endif // FORCE_SYSTEM_MALLOC |
OLD | NEW |