Bug 209581

Summary: MESSAGE_CHECK base macros should use UNLIKELY()
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebKit2Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, useafterfree, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch v1
none
Patch for landing
none
Patch for landing none

Description David Kilzer (:ddkilzer) 2020-03-25 19:52:38 PDT
MESSAGE_CHECK base macros should use UNLIKELY().
Comment 1 Radar WebKit Bug Importer 2020-03-25 19:52:56 PDT
<rdar://problem/60901307>
Comment 2 David Kilzer (:ddkilzer) 2020-03-25 20:01:12 PDT
Created attachment 394572 [details]
Patch v1
Comment 3 youenn fablet 2020-03-26 05:26:08 PDT
Comment on attachment 394572 [details]
Patch v1

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

> Source/WebKit/Platform/IPC/Connection.h:83
>          ASSERT(assertion); \

Seems a bit odd to test assertion twice.
Comment 4 youenn fablet 2020-03-26 05:26:36 PDT
Maybe we should put the ASSERT() before the if check.
Or add ASSERT_NOT_REACHED() instead.
Comment 5 David Kilzer (:ddkilzer) 2020-03-26 08:16:12 PDT
(In reply to youenn fablet from comment #4)
> Maybe we should put the ASSERT() before the if check.
> Or add ASSERT_NOT_REACHED() instead.

I had the same concern when I first saw the macros (especially if the expression didn't evaluate the same way twice), but I ended up realizing the benefit was that the UI Process would crash on debug builds with the exact assertion text.

Maybe we could use ASSERT_NOT_REACHED_WITH_MESSAGE() and use the C-preprocessor trick of changing `assertion` into a literal text string?
Comment 6 David Kilzer (:ddkilzer) 2020-03-26 08:46:15 PDT
Created attachment 394615 [details]
Patch for landing
Comment 7 David Kilzer (:ddkilzer) 2020-03-26 08:54:43 PDT
(In reply to David Kilzer (:ddkilzer) from comment #5)
> (In reply to youenn fablet from comment #4)
> > Maybe we should put the ASSERT() before the if check.
> > Or add ASSERT_NOT_REACHED() instead.
> 
> I had the same concern when I first saw the macros (especially if the
> expression didn't evaluate the same way twice), but I ended up realizing the
> benefit was that the UI Process would crash on debug builds with the exact
> assertion text.
> 
> Maybe we could use ASSERT_NOT_REACHED_WITH_MESSAGE() and use the
> C-preprocessor trick of changing `assertion` into a literal text string?

Actually, putting the ASSERT() before the `if` check is more idiomatic.  I'll do that.
Comment 8 David Kilzer (:ddkilzer) 2020-03-26 09:02:26 PDT
Created attachment 394617 [details]
Patch for landing
Comment 9 EWS 2020-03-26 09:26:11 PDT
Committed r259047: <https://trac.webkit.org/changeset/259047>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394617 [details].