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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 // a thread is destroyed. | 252 // a thread is destroyed. |
253 // We also give a hint to the compiler to use the "initial exec" TLS | 253 // We also give a hint to the compiler to use the "initial exec" TLS |
254 // model. This is faster than the default TLS model, at the cost that | 254 // model. This is faster than the default TLS model, at the cost that |
255 // you cannot dlopen this library. (To see the difference, look at | 255 // you cannot dlopen this library. (To see the difference, look at |
256 // the CPU use of __tls_get_addr with and without this attribute.) | 256 // the CPU use of __tls_get_addr with and without this attribute.) |
257 // Since we don't really use dlopen in google code -- and using dlopen | 257 // Since we don't really use dlopen in google code -- and using dlopen |
258 // on a malloc replacement is asking for trouble in any case -- that's | 258 // on a malloc replacement is asking for trouble in any case -- that's |
259 // a good tradeoff for us. | 259 // a good tradeoff for us. |
260 #ifdef HAVE_TLS | 260 #ifdef HAVE_TLS |
261 static __thread ThreadCache* threadlocal_heap_ | 261 static __thread ThreadCache* threadlocal_heap_ |
262 # ifdef HAVE___ATTRIBUTE__ | 262 // http://code.google.com/p/chromium/issues/detail?id=124489 |
263 // This code is being linked into pyautolib.so file for Chrome. A bug has | |
264 // been filed here: | |
265 // http://code.google.com/p/chromium/issues/detail?id=124489 | |
266 // Ideally pyautolib.so should not link against this code. The current | |
267 // workaround is to pass in -DPGO_GENERATE. | |
gpike
2012/04/24 18:38:21
Please improve the comment. Under what circumstanc
| |
268 #if defined(HAVE___ATTRIBUTE__) && ! defined(PGO_GENERATE) | |
Alexander Potapenko
2012/04/24 10:38:15
I think "!defined" is more common in Chromium.
asharif1
2012/04/24 17:50:12
Done.
| |
263 __attribute__ ((tls_model ("initial-exec"))) | 269 __attribute__ ((tls_model ("initial-exec"))) |
264 # endif | 270 # endif |
265 ; | 271 ; |
266 #endif | 272 #endif |
267 | 273 |
268 // Thread-specific key. Initialization here is somewhat tricky | 274 // Thread-specific key. Initialization here is somewhat tricky |
269 // because some Linux startup code invokes malloc() before it | 275 // because some Linux startup code invokes malloc() before it |
270 // is in a good enough state to handle pthread_keycreate(). | 276 // is in a good enough state to handle pthread_keycreate(). |
271 // Therefore, we use TSD keys only after tsd_inited is set to true. | 277 // Therefore, we use TSD keys only after tsd_inited is set to true. |
272 // Until then, we use a slow path to get the heap object. | 278 // Until then, we use a slow path to get the heap object. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 // because we may be in the thread destruction code and may have | 418 // because we may be in the thread destruction code and may have |
413 // already cleaned up the cache for this thread. | 419 // already cleaned up the cache for this thread. |
414 inline ThreadCache* ThreadCache::GetCacheIfPresent() { | 420 inline ThreadCache* ThreadCache::GetCacheIfPresent() { |
415 if (!tsd_inited_) return NULL; | 421 if (!tsd_inited_) return NULL; |
416 return GetThreadHeap(); | 422 return GetThreadHeap(); |
417 } | 423 } |
418 | 424 |
419 } // namespace tcmalloc | 425 } // namespace tcmalloc |
420 | 426 |
421 #endif // TCMALLOC_THREAD_CACHE_H_ | 427 #endif // TCMALLOC_THREAD_CACHE_H_ |
OLD | NEW |