Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1330)

Issue 8702014: Make ThreadLocalStorage more posix pthread compliant (Closed)

Created:
9 years ago by jar (doing other things)
Modified:
9 years ago
CC:
chromium-reviews, brettw-cc_chromium.org
Visibility:
Public.

Description

Make ThreadLocalStorage more posix pthread compliant This is my first shot at cleaning up the implementation. 1) I support multiple calls to destructors, as suggested in pthread standards 2) I added volatile so that the destructors can't cause any compiler confusion if they are nulled out while a second thread is calling the list of destructors. 3) Windows already avoids producing a key which has value zero <good!>, but I added some DHECKs to make this fact more obvious. I plan to try to enforce that in the posix is similarly constrained... but that will be in a future CL. 4) I did some extra cleaning of destructor handling, so that it is plausible that TCMalloc can use this service (and not have to hack its own). The problem *was* that initialization called new, which would trigger allocation activities before a thread local heap could be setup <sigh>. This is now fixed (in this CL). I also handled the destructor calls with greater care, avoiding calling delete after all the destructors have been called (as that would re-incarnate a TCMalloc heap). This is also fixed. r=willchan BUG=105410 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=112030

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Patch Set 4 : '' #

Total comments: 8

Patch Set 5 : '' #

Patch Set 6 : '' #

Total comments: 26

Patch Set 7 : '' #

Patch Set 8 : '' #

Patch Set 9 : '' #

Patch Set 10 : '' #

Patch Set 11 : '' #

Total comments: 5

Patch Set 12 : '' #

Total comments: 2

Patch Set 13 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+105 lines, -30 lines) Patch
M base/threading/thread_local_storage.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +0 lines, -7 lines 0 comments Download
M base/threading/thread_local_storage_unittest.cc View 1 2 3 4 5 6 7 8 9 10 4 chunks +16 lines, -3 lines 0 comments Download
M base/threading/thread_local_storage_win.cc View 1 2 3 4 5 6 7 8 9 10 11 8 chunks +89 lines, -20 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
jar (doing other things)
This is my first shot at cleaning up the implementation. 1) I support multiple calls ...
9 years ago (2011-11-27 06:34:44 UTC) #1
willchan no longer on Chromium
It seems to me that it should be possible to write a test for this ...
9 years ago (2011-11-28 20:58:28 UTC) #2
willchan no longer on Chromium
http://codereview.chromium.org/8702014/diff/7002/base/threading/thread_local_storage_win.cc File base/threading/thread_local_storage_win.cc (right): http://codereview.chromium.org/8702014/diff/7002/base/threading/thread_local_storage_win.cc#newcode85 base/threading/thread_local_storage_win.cc:85: // Setup our destructor. Make sure that any thread ...
9 years ago (2011-11-28 21:04:32 UTC) #3
willchan no longer on Chromium
This message is great. I think it should move into the changelist description. On 2011/11/27 ...
9 years ago (2011-11-28 21:05:01 UTC) #4
jar (doing other things)
Response to comments by willchan Added unit test coverage of repeated calls to the destructor, ...
9 years ago (2011-11-28 23:41:54 UTC) #5
rvargas (doing something else)
http://codereview.chromium.org/8702014/diff/15001/base/threading/thread_local_storage.h File base/threading/thread_local_storage.h (right): http://codereview.chromium.org/8702014/diff/15001/base/threading/thread_local_storage.h#newcode87 base/threading/thread_local_storage.h:87: static const int PTHREAD_DESTRUCTOR_ITERATIONS = kThreadLocalStorageSize; I don't see ...
9 years ago (2011-11-29 01:26:31 UTC) #6
willchan no longer on Chromium
http://codereview.chromium.org/8702014/diff/15001/base/threading/thread_local_storage.h File base/threading/thread_local_storage.h (right): http://codereview.chromium.org/8702014/diff/15001/base/threading/thread_local_storage.h#newcode85 base/threading/thread_local_storage.h:85: // The maximum number of times to try to ...
9 years ago (2011-11-29 01:46:48 UTC) #7
jar (doing other things)
Changes per comments by rvargas and willchan. I moved several Windows-only-statics out of the header ...
9 years ago (2011-11-29 02:32:45 UTC) #8
rvargas (doing something else)
(if it wasn't clear, I really didn't looked at the code too much, just enough ...
9 years ago (2011-11-29 02:46:46 UTC) #9
willchan no longer on Chromium
lgtm http://codereview.chromium.org/8702014/diff/15001/base/threading/thread_local_storage_win.cc File base/threading/thread_local_storage_win.cc (right): http://codereview.chromium.org/8702014/diff/15001/base/threading/thread_local_storage_win.cc#newcode67 base/threading/thread_local_storage_win.cc:67: memcpy(tls_data, stack_allocated_tls_data, sizeof(stack_allocated_tls_data)); On 2011/11/29 02:32:45, jar wrote: ...
9 years ago (2011-11-29 02:47:04 UTC) #10
jar (doing other things)
After further discussion with rvargas, I've relented and removed the use of atomics to store ...
9 years ago (2011-11-29 06:20:06 UTC) #11
jar (doing other things)
Linux was failing, apparently because it did not willing to re-try the destructor calls more ...
9 years ago (2011-11-29 07:12:39 UTC) #12
jar (doing other things)
After sleeping on it... I decided to at least add a volatile qualifier to the ...
9 years ago (2011-11-29 17:01:53 UTC) #13
willchan no longer on Chromium
http://codereview.chromium.org/8702014/diff/13012/base/threading/thread_local_storage_win.cc File base/threading/thread_local_storage_win.cc (right): http://codereview.chromium.org/8702014/diff/13012/base/threading/thread_local_storage_win.cc#newcode31 base/threading/thread_local_storage_win.cc:31: volatile ThreadLocalStorage::TLSDestructorFunc I'm always super wary of use of ...
9 years ago (2011-11-29 18:52:14 UTC) #14
jar (doing other things)
Response to Willchan's comments. http://codereview.chromium.org/8702014/diff/13012/base/threading/thread_local_storage_win.cc File base/threading/thread_local_storage_win.cc (right): http://codereview.chromium.org/8702014/diff/13012/base/threading/thread_local_storage_win.cc#newcode31 base/threading/thread_local_storage_win.cc:31: volatile ThreadLocalStorage::TLSDestructorFunc I'm beyond super ...
9 years ago (2011-11-29 19:53:22 UTC) #15
rvargas (doing something else)
http://codereview.chromium.org/8702014/diff/13012/base/threading/thread_local_storage_win.cc File base/threading/thread_local_storage_win.cc (right): http://codereview.chromium.org/8702014/diff/13012/base/threading/thread_local_storage_win.cc#newcode31 base/threading/thread_local_storage_win.cc:31: volatile ThreadLocalStorage::TLSDestructorFunc On 2011/11/29 18:52:14, willchan wrote: > I'm ...
9 years ago (2011-11-29 19:55:22 UTC) #16
willchan no longer on Chromium
OK, lgtm http://codereview.chromium.org/8702014/diff/11010/base/threading/thread_local_storage.h File base/threading/thread_local_storage.h (right): http://codereview.chromium.org/8702014/diff/11010/base/threading/thread_local_storage.h#newcode82 base/threading/thread_local_storage.h:82: #endif // OS_WIN This shouldn't be indented
9 years ago (2011-11-29 21:25:31 UTC) #17
jar (doing other things)
9 years ago (2011-11-29 21:39:08 UTC) #18
http://codereview.chromium.org/8702014/diff/11010/base/threading/thread_local...
File base/threading/thread_local_storage.h (right):

http://codereview.chromium.org/8702014/diff/11010/base/threading/thread_local...
base/threading/thread_local_storage.h:82: #endif  // OS_WIN
On 2011/11/29 21:25:31, willchan wrote:
> This shouldn't be indented

Done.

Powered by Google App Engine
This is Rietveld 408576698