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

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed)

Created:
5 years, 11 months ago by sof
Modified:
5 years, 11 months ago
CC:
aandrey+blink_chromium.org, Mads Ager (chromium), arv+blink, blink-reviews, blink-reviews-bindings_chromium.org, blink-reviews-dom_chromium.org, blink-reviews-wtf_chromium.org, Rik, cmumford, danakj, dglazkov+blink, dgrogan, Dominik Röttsches, krit, eae+blinkwatch, falken, f(malita), gavinp+loader_chromium.org, haraken, horo+watch_chromium.org, Nate Chapin, jbroman, jsbell+idb_chromium.org, kinuko+worker_chromium.org, kouhei+heap_chromium.org, Mikhail, oilpan-reviews, pdr+graphicswatchlist_chromium.org, rwlbuis, Stephen Chennney, tyoshino+watch_chromium.org, Yuki
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Cheaper thread-safe atomic initialization of static references. Introduce AtomicallyInitializedStaticReference(Type, name, initializer) for creating static singletons in a thread-safe manner. Reduce overhead compared to the previous AtomicallyInitializedStatic() by adding a double-checked locking scheme around the initialization. Adopt its use across Blink. R=jochen,kinuko,haraken,jyasskin BUG=447370 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=188774

Patch Set 1 #

Total comments: 7

Patch Set 2 : Follow naming convention #

Patch Set 3 : Avoid using reinterpret_cast<void*> #

Total comments: 2

Patch Set 4 : Add type check for initial value #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+172 lines, -146 lines) Patch
M Source/bindings/core/v8/Dictionary.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/bindings/core/v8/ScriptProfiler.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/bindings/core/v8/V8Initializer.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/dom/DOMArrayBuffer.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/dom/DOMArrayBufferDeallocationObserver.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/dom/DOMArrayBufferDeallocationObserver.cpp View 1 chunk +2 lines, -4 lines 0 comments Download
M Source/core/events/EventTarget.cpp View 1 chunk +3 lines, -3 lines 0 comments Download
M Source/core/fetch/CrossOriginAccessControl.cpp View 2 chunks +4 lines, -4 lines 0 comments Download
M Source/core/fetch/FetchUtils.cpp View 3 chunks +4 lines, -4 lines 0 comments Download
M Source/core/page/NetworkStateNotifier.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/timing/MemoryInfo.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/timing/Performance.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/workers/WorkerThread.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/indexeddb/IDBDatabase.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/webdatabase/Database.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/webdatabase/DatabaseTracker.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/webdatabase/QuotaTracker.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/blob/BlobRegistry.cpp View 1 chunk +3 lines, -3 lines 0 comments Download
M Source/platform/graphics/DeferredImageDecoderTest.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M Source/platform/graphics/ImageDecodingStore.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/graphics/ImageDecodingStore.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/platform/graphics/ImageDecodingStoreTest.cpp View 7 chunks +39 lines, -39 lines 0 comments Download
M Source/platform/graphics/ImageFrameGenerator.cpp View 4 chunks +7 lines, -7 lines 0 comments Download
M Source/platform/graphics/ImageFrameGeneratorTest.cpp View 3 chunks +4 lines, -4 lines 0 comments Download
M Source/platform/heap/Handle.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/heap/Heap.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M Source/platform/heap/HeapTest.cpp View 3 chunks +5 lines, -5 lines 0 comments Download
M Source/platform/heap/ThreadState.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/heap/ThreadState.cpp View 3 chunks +5 lines, -5 lines 0 comments Download
M Source/platform/heap/Visitor.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/image-decoders/ImageDecoder.h View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/web/WebImageCache.cpp View 1 chunk +4 lines, -5 lines 0 comments Download
M Source/web/WebKit.cpp View 1 chunk +0 lines, -9 lines 0 comments Download
M Source/wtf/ArrayBuffer.h View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/wtf/ArrayBufferContents.h View 1 chunk +4 lines, -4 lines 0 comments Download
M Source/wtf/Atomics.h View 4 chunks +27 lines, -0 lines 0 comments Download
M Source/wtf/CryptographicallyRandomNumber.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/wtf/HashTable.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/wtf/Threading.h View 1 2 3 1 chunk +16 lines, -5 lines 7 comments Download
M Source/wtf/text/TextEncoding.cpp View 2 chunks +9 lines, -9 lines 0 comments Download
M Source/wtf/unicode/icu/CollatorICU.cpp View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 27 (4 generated)
sof
Please take a look. A longer list of reviewers, in case people are too busy ...
5 years, 11 months ago (2015-01-21 15:03:19 UTC) #2
jochen (gone - plz use gerrit)
lgtm
5 years, 11 months ago (2015-01-21 15:15:23 UTC) #3
kinuko
lgtm2!
5 years, 11 months ago (2015-01-21 15:21:18 UTC) #4
haraken
LGTM https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h File Source/wtf/ArrayBufferContents.h (right): https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h#newcode64 Source/wtf/ArrayBufferContents.h:64: m_deallocationObserver = &observer; Do we need m_deallocationObserver? I ...
5 years, 11 months ago (2015-01-21 15:23:33 UTC) #5
sof
https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h File Source/wtf/ArrayBufferContents.h (right): https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h#newcode64 Source/wtf/ArrayBufferContents.h:64: m_deallocationObserver = &observer; On 2015/01/21 15:23:33, haraken wrote: > ...
5 years, 11 months ago (2015-01-21 15:51:38 UTC) #6
Jeffrey Yasskin
The reinterpret_casts are undefined behavior. Make the pointer a void* and car the assignment to ...
5 years, 11 months ago (2015-01-21 16:53:20 UTC) #7
haraken
https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h File Source/wtf/ArrayBufferContents.h (right): https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h#newcode64 Source/wtf/ArrayBufferContents.h:64: m_deallocationObserver = &observer; On 2015/01/21 15:51:38, sof wrote: > ...
5 years, 11 months ago (2015-01-21 16:59:17 UTC) #8
sof
On 2015/01/21 16:53:20, Jeffrey Yasskin wrote: > The reinterpret_casts are undefined behavior. Make the pointer ...
5 years, 11 months ago (2015-01-21 19:23:11 UTC) #9
Jeffrey Yasskin
https://codereview.chromium.org/794223003/diff/40001/Source/wtf/Threading.h File Source/wtf/Threading.h (right): https://codereview.chromium.org/794223003/diff/40001/Source/wtf/Threading.h#newcode45 Source/wtf/Threading.h:45: WTF::releaseStore(&name##Pointer, initializer); \ It probably makes sense to use: ...
5 years, 11 months ago (2015-01-21 19:36:07 UTC) #10
sof
Thanks for the quick reviews. https://codereview.chromium.org/794223003/diff/40001/Source/wtf/Threading.h File Source/wtf/Threading.h (right): https://codereview.chromium.org/794223003/diff/40001/Source/wtf/Threading.h#newcode45 Source/wtf/Threading.h:45: WTF::releaseStore(&name##Pointer, initializer); \ On ...
5 years, 11 months ago (2015-01-21 20:42:54 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/794223003/60001
5 years, 11 months ago (2015-01-21 20:43:17 UTC) #13
Jeffrey Yasskin
lgtm
5 years, 11 months ago (2015-01-21 20:59:48 UTC) #14
commit-bot: I haz the power
Committed patchset #4 (id:60001) as https://src.chromium.org/viewvc/blink?view=rev&revision=188774
5 years, 11 months ago (2015-01-21 21:59:54 UTC) #15
Yuki
https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h File Source/wtf/ArrayBufferContents.h (right): https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h#newcode64 Source/wtf/ArrayBufferContents.h:64: m_deallocationObserver = &observer; On 2015/01/21 16:59:17, haraken wrote: > ...
5 years, 11 months ago (2015-01-22 04:27:39 UTC) #17
Yuki
https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h File Source/wtf/ArrayBufferContents.h (right): https://codereview.chromium.org/794223003/diff/1/Source/wtf/ArrayBufferContents.h#newcode64 Source/wtf/ArrayBufferContents.h:64: m_deallocationObserver = &observer; On 2015/01/22 04:27:39, Yuki wrote: > ...
5 years, 11 months ago (2015-01-22 04:35:20 UTC) #18
Noel Gordon
Nice patch: some minor questions. https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h File Source/wtf/Threading.h (right): https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h#newcode40 Source/wtf/Threading.h:40: #define AtomicallyInitializedStaticReference(T, name, initializer) ...
5 years, 11 months ago (2015-01-24 01:20:06 UTC) #20
sof
https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h File Source/wtf/Threading.h (right): https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h#newcode40 Source/wtf/Threading.h:40: #define AtomicallyInitializedStaticReference(T, name, initializer) \ On 2015/01/24 01:20:06, noel ...
5 years, 11 months ago (2015-01-24 06:20:06 UTC) #21
Noel Gordon
https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h File Source/wtf/Threading.h (right): https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h#newcode40 Source/wtf/Threading.h:40: #define AtomicallyInitializedStaticReference(T, name, initializer) \ On 2015/01/24 06:20:06, sof ...
5 years, 11 months ago (2015-01-24 12:08:24 UTC) #22
sof
https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h File Source/wtf/Threading.h (right): https://codereview.chromium.org/794223003/diff/60001/Source/wtf/Threading.h#newcode40 Source/wtf/Threading.h:40: #define AtomicallyInitializedStaticReference(T, name, initializer) \ On 2015/01/24 12:08:24, noel ...
5 years, 11 months ago (2015-01-24 12:40:05 UTC) #23
Noel Gordon
On 2015/01/24 12:40:05, sof wrote: > Sounds sensible; doesn't the description here explain in a ...
5 years, 11 months ago (2015-01-24 13:03:14 UTC) #24
Noel Gordon
/certainly even.
5 years, 11 months ago (2015-01-24 13:04:52 UTC) #25
sof
On 2015/01/24 13:03:14, noel gordon wrote: > On 2015/01/24 12:40:05, sof wrote: > > Sounds ...
5 years, 11 months ago (2015-01-24 13:22:24 UTC) #26
Noel Gordon
5 years, 11 months ago (2015-01-24 14:18:45 UTC) #27
LGTM

Understood. Good to see this change in Blink. Thank you for doing this work.

Powered by Google App Engine
This is Rietveld 408576698