RESOLVED FIXED 215535
Use std::call_once + LazyNeverDestroyed to initialize complex data structures
https://bugs.webkit.org/show_bug.cgi?id=215535
Summary Use std::call_once + LazyNeverDestroyed to initialize complex data structures
Yusuke Suzuki
Reported 2020-08-15 00:56:42 PDT
Use std::call_once + LazyNeverDestroyed to initialize complex data structures
Attachments
Patch (22.94 KB, patch)
2020-08-15 01:08 PDT, Yusuke Suzuki
no flags
Patch (22.97 KB, patch)
2020-08-15 01:11 PDT, Yusuke Suzuki
no flags
Patch (22.99 KB, patch)
2020-08-15 01:18 PDT, Yusuke Suzuki
mark.lam: review+
Patch (23.01 KB, patch)
2020-08-15 01:42 PDT, Yusuke Suzuki
no flags
Yusuke Suzuki
Comment 1 2020-08-15 01:08:00 PDT
Yusuke Suzuki
Comment 2 2020-08-15 01:11:45 PDT
Yusuke Suzuki
Comment 3 2020-08-15 01:12:36 PDT
Yusuke Suzuki
Comment 4 2020-08-15 01:18:14 PDT
Mark Lam
Comment 5 2020-08-15 01:34:16 PDT
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 { }.
Yusuke Suzuki
Comment 6 2020-08-15 01:42:36 PDT
Yusuke Suzuki
Comment 7 2020-08-15 11:41:02 PDT
Darin Adler
Comment 8 2020-08-15 12:00:53 PDT
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?
Yusuke Suzuki
Comment 9 2020-08-15 13:11:02 PDT
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.
Yusuke Suzuki
Comment 10 2020-08-15 21:40:51 PDT
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
Note You need to log in before you can comment on or make changes to this bug.