| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 next_memory_steal_ = next_memory_steal_->next_; | 292 next_memory_steal_ = next_memory_steal_->next_; |
| 293 return; | 293 return; |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 | 296 |
| 297 int ThreadCache::GetSamplePeriod() { | 297 int ThreadCache::GetSamplePeriod() { |
| 298 return sampler_.GetSamplePeriod(); | 298 return sampler_.GetSamplePeriod(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void ThreadCache::InitModule() { | 301 void ThreadCache::InitModule() { |
| 302 // There is a slight potential race here because of double-checked |
| 303 // locking idiom. However, as long as the program does a small |
| 304 // allocation before switching to multi-threaded mode, we will be |
| 305 // fine. We increase the chances of doing such a small allocation |
| 306 // by doing one in the constructor of the module_enter_exit_hook |
| 307 // object declared below. |
| 302 SpinLockHolder h(Static::pageheap_lock()); | 308 SpinLockHolder h(Static::pageheap_lock()); |
| 303 if (!phinited) { | 309 if (!phinited) { |
| 304 Static::InitStaticVars(); | 310 Static::InitStaticVars(); |
| 305 threadcache_allocator.Init(); | 311 threadcache_allocator.Init(); |
| 306 phinited = 1; | 312 phinited = 1; |
| 307 } | 313 } |
| 308 } | 314 } |
| 309 | 315 |
| 310 void ThreadCache::InitTSD() { | 316 void ThreadCache::InitTSD() { |
| 311 ASSERT(!tsd_inited_); | 317 ASSERT(!tsd_inited_); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 void ThreadCache::set_overall_thread_cache_size(size_t new_size) { | 504 void ThreadCache::set_overall_thread_cache_size(size_t new_size) { |
| 499 // Clip the value to a reasonable range | 505 // Clip the value to a reasonable range |
| 500 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize; | 506 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize; |
| 501 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB | 507 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB |
| 502 overall_thread_cache_size_ = new_size; | 508 overall_thread_cache_size_ = new_size; |
| 503 | 509 |
| 504 RecomputePerThreadCacheSize(); | 510 RecomputePerThreadCacheSize(); |
| 505 } | 511 } |
| 506 | 512 |
| 507 } // namespace tcmalloc | 513 } // namespace tcmalloc |
| OLD | NEW |