Bug 180600 - bmalloc StaticMutex's constructor should be constexpr
Summary: bmalloc StaticMutex's constructor should be constexpr
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:
Blocks:
 
Reported: 2017-12-08 12:39 PST by Yusuke Suzuki
Modified: 2018-04-05 11:08 PDT (History)
5 users (show)

See Also:


Attachments
Patch (2.75 KB, patch)
2017-12-08 12:42 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (3.04 KB, patch)
2017-12-08 12:49 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (72.90 KB, patch)
2018-04-05 09:22 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (72.87 KB, patch)
2018-04-05 09:24 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (72.87 KB, patch)
2018-04-05 09:34 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2017-12-08 12:39:43 PST
bmalloc StaticMutex's constructor should be constexpr
Comment 1 Yusuke Suzuki 2017-12-08 12:42:55 PST
Created attachment 328854 [details]
Patch
Comment 2 Yusuke Suzuki 2017-12-08 12:49:19 PST
Created attachment 328855 [details]
Patch
Comment 3 Yusuke Suzuki 2018-04-04 07:25:22 PDT
Comment on attachment 328855 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328855&action=review

> Source/bmalloc/bmalloc/StaticMutex.h:50
> +    std::atomic_flag m_isSpinning = ATOMIC_FLAG_INIT;

hmm, it is not constexpr (according to the spec). Maybe, we cannot use std::atomic_flag { ATOMIC_FLAG_INIT } since this form is not described in the spec. And even if we use { ATOMIC_FLAG_INIT }, it is still not constexpr.
Note that std::atomic<bool> has a constexpr constructor.
Comment 4 JF Bastien 2018-04-05 08:41:35 PDT
(In reply to Yusuke Suzuki from comment #3)
> Comment on attachment 328855 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=328855&action=review
> 
> > Source/bmalloc/bmalloc/StaticMutex.h:50
> > +    std::atomic_flag m_isSpinning = ATOMIC_FLAG_INIT;
> 
> hmm, it is not constexpr (according to the spec). Maybe, we cannot use
> std::atomic_flag { ATOMIC_FLAG_INIT } since this form is not described in
> the spec. And even if we use { ATOMIC_FLAG_INIT }, it is still not constexpr.
> Note that std::atomic<bool> has a constexpr constructor.

The one thing atomic<bool> doesn't have in theory is guaranteed lock-free... but in practice it does. Otherwise it's more capable in every way than atomic_flag (until we improve atomic_flag for C++20).

So yeah atomic<bool> is better :-)
Comment 5 Yusuke Suzuki 2018-04-05 08:54:14 PDT
Comment on attachment 328855 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328855&action=review

>>> Source/bmalloc/bmalloc/StaticMutex.h:50
>>> +    std::atomic_flag m_isSpinning = ATOMIC_FLAG_INIT;
>> 
>> hmm, it is not constexpr (according to the spec). Maybe, we cannot use std::atomic_flag { ATOMIC_FLAG_INIT } since this form is not described in the spec. And even if we use { ATOMIC_FLAG_INIT }, it is still not constexpr.
>> Note that std::atomic<bool> has a constexpr constructor.
> 
> The one thing atomic<bool> doesn't have in theory is guaranteed lock-free... but in practice it does. Otherwise it's more capable in every way than atomic_flag (until we improve atomic_flag for C++20).
> 
> So yeah atomic<bool> is better :-)

OK, I'll change it to std::atomic<bool>
Comment 6 Yusuke Suzuki 2018-04-05 09:22:17 PDT
Created attachment 337265 [details]
Patch
Comment 7 EWS Watchlist 2018-04-05 09:24:06 PDT
Attachment 337265 [details] did not pass style-queue:


ERROR: Source/bmalloc/bmalloc/Mutex.cpp:27:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/bmalloc/bmalloc/Mutex.cpp:42:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Source/bmalloc/bmalloc/Mutex.h:43:  try_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/bmalloc/bmalloc/Mutex.h:74:  Mutex::try_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 4 in 38 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Yusuke Suzuki 2018-04-05 09:24:51 PDT
Created attachment 337266 [details]
Patch
Comment 9 Yusuke Suzuki 2018-04-05 09:34:10 PDT
Created attachment 337270 [details]
Patch
Comment 10 EWS Watchlist 2018-04-05 09:37:17 PDT
Attachment 337270 [details] did not pass style-queue:


ERROR: Source/bmalloc/bmalloc/Mutex.cpp:27:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Source/bmalloc/bmalloc/Mutex.cpp:42:  More than one command on the same line  [whitespace/newline] [4]
ERROR: Source/bmalloc/bmalloc/Mutex.h:43:  try_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
ERROR: Source/bmalloc/bmalloc/Mutex.h:74:  Mutex::try_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming/underscores] [4]
Total errors found: 4 in 38 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Mark Lam 2018-04-05 10:45:29 PDT
Comment on attachment 337270 [details]
Patch

r=me
Comment 12 Yusuke Suzuki 2018-04-05 10:46:59 PDT
Comment on attachment 337270 [details]
Patch

Thank you!
Comment 13 WebKit Commit Bot 2018-04-05 11:07:34 PDT
Comment on attachment 337270 [details]
Patch

Clearing flags on attachment: 337270

Committed r230308: <https://trac.webkit.org/changeset/230308>
Comment 14 WebKit Commit Bot 2018-04-05 11:07:35 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 Radar WebKit Bug Importer 2018-04-05 11:08:21 PDT
<rdar://problem/39212969>