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

Issue 2728453006: WTF: Initialize main-thread stack estimates when WTF starts up. (Closed)

Created:
3 years, 9 months ago by jbroman
Modified:
3 years, 8 months ago
CC:
adithyas, blink-reviews, blink-reviews-wtf_chromium.org, chromium-reviews, haraken, Mikhail
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

WTF: Initialize main-thread stack estimates when WTF starts up. Initializing this statically makes it sensitive to which thread it runs on for the first time. Instead of using a static local, an ordinary global variable is initialized once, when WTF knows it is on the main thread. As a side effect, the check for static initialization in the function itself is no longer required (and happens to even be safe if it is called before initialization), which means the function need not be exported (only the variables must be), and should compile to less code. Finally, the method (which is useful to callers outside of WTF) is moved into the general WTF namespace, and only the implementation details are kept in WTF::internal. BUG=697994 Review-Url: https://codereview.chromium.org/2728453006 Cr-Commit-Position: refs/heads/master@{#455150} Committed: https://chromium.googlesource.com/chromium/src/+/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140

Patch Set 1 #

Patch Set 2 : correct call to initializeMainThreadStackEstimate #

Patch Set 3 : remove internal:: prefix from ThreadSpecific #

Patch Set 4 : ThreadSpecific: account for mayNotBeMainThread false positives. #

Patch Set 5 : Make ThreadSpecific check for sure whether it is on the main thread. #

Patch Set 6 : Don't worry about m_mainThreadStorage on platforms where we don't use it. #

Patch Set 7 : an implementation of currentThread that does not use WTFThreadDAta #

Patch Set 8 : fix cast for windows #

Total comments: 8

Patch Set 9 : clarify initialization of s_currentThreadKey #

Total comments: 7

Patch Set 10 : comment about why currentThread works this way #

Unified diffs Side-by-side diffs Delta from patch set Stats (+103 lines, -22 lines) Patch
M third_party/WebKit/Source/wtf/StackUtil.h View 1 chunk +10 lines, -15 lines 0 comments Download
M third_party/WebKit/Source/wtf/StackUtil.cpp View 1 chunk +11 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/wtf/ThreadSpecific.h View 1 2 3 4 5 2 chunks +11 lines, -1 line 0 comments Download
M third_party/WebKit/Source/wtf/Threading.h View 1 2 3 4 5 6 7 8 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/wtf/ThreadingPthreads.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +31 lines, -1 line 0 comments Download
M third_party/WebKit/Source/wtf/ThreadingWin.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +30 lines, -1 line 0 comments Download
M third_party/WebKit/Source/wtf/WTF.cpp View 1 2 3 4 5 6 2 chunks +6 lines, -1 line 0 comments Download

Messages

Total messages: 56 (43 generated)
jbroman
Adithya and I ran into this as he's looking to use this trick to replace ...
3 years, 9 months ago (2017-03-02 21:18:01 UTC) #10
jbroman
Hmm. Non Linux seems to be having issues, will investigate.
3 years, 9 months ago (2017-03-03 04:50:48 UTC) #13
jbroman
OK. The certain isMainThread check itself depended on WTF::ThreadSpecific::operator*, which caused a loop. I've resolved ...
3 years, 9 months ago (2017-03-05 14:54:39 UTC) #32
haraken
It's unfortunate that we're making the ThreadSpecific logic even more complicated, but I don't have ...
3 years, 9 months ago (2017-03-06 01:44:03 UTC) #34
jbroman
https://codereview.chromium.org/2728453006/diff/140001/third_party/WebKit/Source/wtf/ThreadSpecific.h File third_party/WebKit/Source/wtf/ThreadSpecific.h (right): https://codereview.chromium.org/2728453006/diff/140001/third_party/WebKit/Source/wtf/ThreadSpecific.h#newcode291 third_party/WebKit/Source/wtf/ThreadSpecific.h:291: if (!mainThreadAlwaysChecksTLS && UNLIKELY(ptr != &m_mainThreadStorage) && On 2017/03/06 ...
3 years, 9 months ago (2017-03-06 16:14:03 UTC) #37
haraken
Mostly looks good % small questions. https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadSpecific.h File third_party/WebKit/Source/wtf/ThreadSpecific.h (right): https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadSpecific.h#newcode293 third_party/WebKit/Source/wtf/ThreadSpecific.h:293: m_mainThreadStorage = *ptr; ...
3 years, 9 months ago (2017-03-06 19:21:36 UTC) #40
jbroman
https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadSpecific.h File third_party/WebKit/Source/wtf/ThreadSpecific.h (right): https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadSpecific.h#newcode293 third_party/WebKit/Source/wtf/ThreadSpecific.h:293: m_mainThreadStorage = *ptr; On 2017/03/06 at 19:21:36, haraken wrote: ...
3 years, 9 months ago (2017-03-06 20:28:09 UTC) #41
haraken
LGTM https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadSpecific.h File third_party/WebKit/Source/wtf/ThreadSpecific.h (right): https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadSpecific.h#newcode293 third_party/WebKit/Source/wtf/ThreadSpecific.h:293: m_mainThreadStorage = *ptr; On 2017/03/06 20:28:09, jbroman wrote: ...
3 years, 9 months ago (2017-03-06 20:46:42 UTC) #42
jbroman
https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadingPthreads.cpp File third_party/WebKit/Source/wtf/ThreadingPthreads.cpp (left): https://codereview.chromium.org/2728453006/diff/160001/third_party/WebKit/Source/wtf/ThreadingPthreads.cpp#oldcode89 third_party/WebKit/Source/wtf/ThreadingPthreads.cpp:89: return wtfThreadData().threadId(); On 2017/03/06 at 20:46:42, haraken wrote: > ...
3 years, 9 months ago (2017-03-07 16:03:30 UTC) #49
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2728453006/180001
3 years, 9 months ago (2017-03-07 16:05:08 UTC) #50
commit-bot: I haz the power
Committed patchset #10 (id:180001) as https://chromium.googlesource.com/chromium/src/+/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140
3 years, 9 months ago (2017-03-07 18:38:51 UTC) #53
jbroman
On 2017/03/07 at 18:38:51, commit-bot wrote: > Committed patchset #10 (id:180001) as https://chromium.googlesource.com/chromium/src/+/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140 Also fixes ...
3 years, 9 months ago (2017-03-07 18:57:19 UTC) #54
Charlie Harrison
3 years, 8 months ago (2017-03-31 01:26:12 UTC) #56
Message was sent while issue was closed.
Just noticed this CL. Thanks for fixing the bugs I caused :)

Powered by Google App Engine
This is Rietveld 408576698