Use std::call_once + LazyNeverDestroyed to initialize complex data structures
Created attachment 406657 [details] Patch
Created attachment 406658 [details] Patch
<rdar://problem/66774266>
Created attachment 406659 [details] Patch
Comment on attachment 406659 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=406659&action=review r=me if EWS bots are happy. > Source/WTF/wtf/Logger.cpp:35 > +Lock loggerObserverLock { }; Don't need the { }.
Created attachment 406660 [details] Patch
Committed r265735: <https://trac.webkit.org/changeset/265735>
Comment on attachment 406660 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=406660&action=review > Source/WTF/wtf/Language.cpp:87 > - static NeverDestroyed<Vector<String>> override; > + static LazyNeverDestroyed<Vector<String>> override; > + static std::once_flag onceKey; > + std::call_once(onceKey, [&] { > + override.construct(); > + }); > return override; This doesn't seem like a useful change. The reference counts on the strings aren’t thread safe either. Same might apply for some of the other examples in this patch, but this one is clear cut case. Unless I am missing something?
Comment on attachment 406660 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=406660&action=review >> Source/WTF/wtf/Language.cpp:87 >> return override; > > This doesn't seem like a useful change. The reference counts on the strings aren’t thread safe either. Same might apply for some of the other examples in this patch, but this one is clear cut case. Unless I am missing something? The goal of this patch is fixing <rdar://problem/66774266> (RunLoop). So the other part is mechanical change. I changed all `NeverDestroyed<ComplexData>` code in WTF mechanically to prevent the above type of issues. If some of them are proven that this is not thread-related, I think we can change it to MainThreadNeverDestroyed<> etc.
Comment on attachment 406660 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=406660&action=review >>> Source/WTF/wtf/Language.cpp:87 >>> return override; >> >> This doesn't seem like a useful change. The reference counts on the strings aren’t thread safe either. Same might apply for some of the other examples in this patch, but this one is clear cut case. Unless I am missing something? > > The goal of this patch is fixing <rdar://problem/66774266> (RunLoop). So the other part is mechanical change. > I changed all `NeverDestroyed<ComplexData>` code in WTF mechanically to prevent the above type of issues. > If some of them are proven that this is not thread-related, I think we can change it to MainThreadNeverDestroyed<> etc. Filed in https://bugs.webkit.org/show_bug.cgi?id=215546