Bug 186017 - [WTF] RandomDevice should be initialized inside std::call_once
Summary: [WTF] RandomDevice should be initialized inside std::call_once
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on: 186014
Blocks:
  Show dependency treegraph
 
Reported: 2018-05-27 06:57 PDT by Yusuke Suzuki
Modified: 2018-07-01 21:25 PDT (History)
9 users (show)

See Also:


Attachments
Patch (1.57 KB, patch)
2018-05-27 06:58 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (1.68 KB, patch)
2018-06-26 19:04 PDT, Yusuke Suzuki
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2018-05-27 06:57:24 PDT
[WTF] RandomDevice should be initialized inside std::call_once
Comment 1 Yusuke Suzuki 2018-05-27 06:58:19 PDT
Created attachment 341420 [details]
Patch
Comment 2 Alexey Proskuryakov 2018-05-31 11:46:39 PDT
Comment on attachment 341420 [details]
Patch

Marking r- to get out of review queue, as EWS is all red.
Comment 3 Yusuke Suzuki 2018-06-26 19:04:46 PDT
Created attachment 343674 [details]
Patch
Comment 4 Don Olmstead 2018-06-28 12:33:03 PDT
Comment on attachment 343674 [details]
Patch

Informal review is that LGTM.

Guessing this is something you're going to be doing across the codebase?
Comment 5 Darin Adler 2018-06-28 14:40:28 PDT
(In reply to Don Olmstead from comment #4)
> Guessing this is something you're going to be doing across the codebase?

I think only in code that is supposed to be safe for use from multiple threads, which is a small faction of all WebKit code.
Comment 6 Darin Adler 2018-06-28 14:41:33 PDT
Comment on attachment 343674 [details]
Patch

Since I expect this to come up repeatedly I wonder if there is a cleaner idiom for this. If some way we find we can afford to pay the locking cost on Apple’s platforms it would be nice to be able to quickly remove all of this code.
Comment 7 Darin Adler 2018-06-28 14:53:46 PDT
Maybe the elegant way to do it is to define a different NeverDestroyed variant that automatically includes the once_flag and the laziness and does this all. Then that can be used only on platforms where we turn off the compiler’s built-in locking. On other platforms it can possibly even be a typedef for the plain old NeverDestroyed.
Comment 8 Yusuke Suzuki 2018-07-01 21:17:07 PDT
(In reply to Darin Adler from comment #7)
> Maybe the elegant way to do it is to define a different NeverDestroyed
> variant that automatically includes the once_flag and the laziness and does
> this all. Then that can be used only on platforms where we turn off the
> compiler’s built-in locking. On other platforms it can possibly even be a
> typedef for the plain old NeverDestroyed.

Yeah, that sounds fancy.
Comment 9 Yusuke Suzuki 2018-07-01 21:24:38 PDT
Committed r233415: <https://trac.webkit.org/changeset/233415>
Comment 10 Radar WebKit Bug Importer 2018-07-01 21:25:18 PDT
<rdar://problem/41709074>