Changeset 250867 in webkit


Ignore:
Timestamp:
Oct 8, 2019 3:16:04 PM (5 years ago)
Author:
rmorisset@apple.com
Message:

dataLogIf should be ALWAYS_INLINE
https://bugs.webkit.org/show_bug.cgi?id=202703

Reviewed by Saam Barati.

We often have the following pattern:
`
static constexpr bool verbose = false;
...
dataLogLnIf(verbose, "Something is happening");
`
To make sure that these are always properly eliminated I'd like to make dataLogIf/dataLogLnIf ALWAYS_INLINE.

We may as well mark the branch as UNLIKELY too, for the cases where the condition comes from Options::verboseSomething() and is only known at runtime.

  • wtf/DataLog.h:

(WTF::dataLogIf):
(WTF::dataLogLnIf):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r250809 r250867  
     12019-10-08  Robin Morisset  <rmorisset@apple.com>
     2
     3        dataLogIf should be ALWAYS_INLINE
     4        https://bugs.webkit.org/show_bug.cgi?id=202703
     5
     6        Reviewed by Saam Barati.
     7
     8        We often have the following pattern:
     9        ```
     10        static constexpr bool verbose = false;
     11        ...
     12        dataLogLnIf(verbose, "Something is happening");
     13        ```
     14        To make sure that these are always properly eliminated I'd like to make dataLogIf/dataLogLnIf ALWAYS_INLINE.
     15       
     16        We may as well mark the branch as UNLIKELY too, for the cases where the condition comes from Options::verboseSomething() and is only known at runtime.
     17
     18        * wtf/DataLog.h:
     19        (WTF::dataLogIf):
     20        (WTF::dataLogLnIf):
     21
    1222019-10-07  Alexey Proskuryakov  <ap@apple.com>
    223
  • trunk/Source/WTF/wtf/DataLog.h

    r237099 r250867  
    5353
    5454template<typename... Types>
    55 void dataLogIf(bool shouldLog, const Types&... values)
     55ALWAYS_INLINE void dataLogIf(bool shouldLog, const Types&... values)
    5656{
    57     if (shouldLog)
     57    if (UNLIKELY(shouldLog))
    5858        dataLog(values...);
    5959}
    6060
    6161template<typename... Types>
    62 void dataLogLnIf(bool shouldLog, const Types&... values)
     62ALWAYS_INLINE void dataLogLnIf(bool shouldLog, const Types&... values)
    6363{
    64     if (shouldLog)
     64    if (UNLIKELY(shouldLog))
    6565        dataLogLn(values...);
    6666}
Note: See TracChangeset for help on using the changeset viewer.