| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 volatile size_t ThreadCache::per_thread_cache_size_ = kMaxThreadCacheSize; | 58 volatile size_t ThreadCache::per_thread_cache_size_ = kMaxThreadCacheSize; |
| 59 size_t ThreadCache::overall_thread_cache_size_ = kDefaultOverallThreadCacheSize; | 59 size_t ThreadCache::overall_thread_cache_size_ = kDefaultOverallThreadCacheSize; |
| 60 ssize_t ThreadCache::unclaimed_cache_space_ = kDefaultOverallThreadCacheSize; | 60 ssize_t ThreadCache::unclaimed_cache_space_ = kDefaultOverallThreadCacheSize; |
| 61 PageHeapAllocator<ThreadCache> threadcache_allocator; | 61 PageHeapAllocator<ThreadCache> threadcache_allocator; |
| 62 ThreadCache* ThreadCache::thread_heaps_ = NULL; | 62 ThreadCache* ThreadCache::thread_heaps_ = NULL; |
| 63 int ThreadCache::thread_heap_count_ = 0; | 63 int ThreadCache::thread_heap_count_ = 0; |
| 64 ThreadCache* ThreadCache::next_memory_steal_ = NULL; | 64 ThreadCache* ThreadCache::next_memory_steal_ = NULL; |
| 65 #ifdef HAVE_TLS | 65 #ifdef HAVE_TLS |
| 66 __thread ThreadCache* ThreadCache::threadlocal_heap_ | 66 __thread ThreadCache* ThreadCache::threadlocal_heap_ |
| 67 # ifdef HAVE___ATTRIBUTE__ | 67 // This code links against pyautolib.so, which causes dlopen() on that shared |
| 68 // object to fail when -fprofile-generate is used with it. Ideally pyautolib.so |
| 69 // should not link against this code. There is a bug filed for that: |
| 70 // http://code.google.com/p/chromium/issues/detail?id=124489 |
| 71 // For now the workaround is to pass in -DPGO_GENERATE when building Chrome for |
| 72 // instrumentation (-fprofile-generate). |
| 73 // For all non-instrumentation builds, this define will not be set and the |
| 74 // performance benefit of "intial-exec" will be achieved. |
| 75 #if defined(HAVE___ATTRIBUTE__) && !defined(PGO_GENERATE) |
| 68 __attribute__ ((tls_model ("initial-exec"))) | 76 __attribute__ ((tls_model ("initial-exec"))) |
| 69 # endif | 77 # endif |
| 70 ; | 78 ; |
| 71 #endif | 79 #endif |
| 72 bool ThreadCache::tsd_inited_ = false; | 80 bool ThreadCache::tsd_inited_ = false; |
| 73 pthread_key_t ThreadCache::heap_key_; | 81 pthread_key_t ThreadCache::heap_key_; |
| 74 | 82 |
| 75 #if defined(HAVE_TLS) | 83 #if defined(HAVE_TLS) |
| 76 bool kernel_supports_tls = false; // be conservative | 84 bool kernel_supports_tls = false; // be conservative |
| 77 # if defined(_WIN32) // windows has supported TLS since winnt, I think. | 85 # if defined(_WIN32) // windows has supported TLS since winnt, I think. |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 void ThreadCache::set_overall_thread_cache_size(size_t new_size) { | 511 void ThreadCache::set_overall_thread_cache_size(size_t new_size) { |
| 504 // Clip the value to a reasonable range | 512 // Clip the value to a reasonable range |
| 505 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize; | 513 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize; |
| 506 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB | 514 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB |
| 507 overall_thread_cache_size_ = new_size; | 515 overall_thread_cache_size_ = new_size; |
| 508 | 516 |
| 509 RecomputePerThreadCacheSize(); | 517 RecomputePerThreadCacheSize(); |
| 510 } | 518 } |
| 511 | 519 |
| 512 } // namespace tcmalloc | 520 } // namespace tcmalloc |
| OLD | NEW |