Bug 226255

Summary: Stop using UncheckedLock in WTF::AutomaticThread
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web Template FrameworkAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, benjamin, cmarcelo, darin, ddkilzer, ews-watchlist, ggaren, keith_miller, mark.lam, msaboff, saam, sam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2021-05-25 19:35:23 PDT
Stop using UncheckedLock in WTF::AutomaticThread as it is being phased out in favor of Lock, which supports Clang thread safety analysis.
Comment 1 Chris Dumez 2021-05-25 19:41:19 PDT
Created attachment 429725 [details]
Patch
Comment 2 Chris Dumez 2021-05-25 20:09:16 PDT
Created attachment 429726 [details]
Patch
Comment 3 Chris Dumez 2021-05-25 20:13:00 PDT
Created attachment 429727 [details]
Patch
Comment 4 Keith Miller 2021-05-26 08:04:08 PDT
Comment on attachment 429727 [details]
Patch

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

> Source/WTF/wtf/ParallelHelperPool.cpp:189
> +        assertIsHeld(*m_pool.m_lock);

Why not just annotate the poll function? Or does this only work for locks that are a member of the same class as the method?
Comment 5 Chris Dumez 2021-05-26 08:06:40 PDT
Comment on attachment 429727 [details]
Patch

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

>> Source/WTF/wtf/ParallelHelperPool.cpp:189
>> +        assertIsHeld(*m_pool.m_lock);
> 
> Why not just annotate the poll function? Or does this only work for locks that are a member of the same class as the method?

I'll try. I think I already tried that and it didn't work but I don't really remember why.
Comment 6 Chris Dumez 2021-05-26 08:11:37 PDT
Created attachment 429759 [details]
Patch
Comment 7 Chris Dumez 2021-05-26 08:12:10 PDT
(In reply to Keith Miller from comment #4)
> Comment on attachment 429727 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=429727&action=review
> 
> > Source/WTF/wtf/ParallelHelperPool.cpp:189
> > +        assertIsHeld(*m_pool.m_lock);
> 
> Why not just annotate the poll function? Or does this only work for locks
> that are a member of the same class as the method?

Looks like it builds without the assertIsHeld() and the annotation. Made the change.
Comment 8 Keith Miller 2021-05-26 08:19:17 PDT
(In reply to Chris Dumez from comment #7)
> (In reply to Keith Miller from comment #4)
> > Comment on attachment 429727 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=429727&action=review
> > 
> > > Source/WTF/wtf/ParallelHelperPool.cpp:189
> > > +        assertIsHeld(*m_pool.m_lock);
> > 
> > Why not just annotate the poll function? Or does this only work for locks
> > that are a member of the same class as the method?
> 
> Looks like it builds without the assertIsHeld() and the annotation. Made the
> change.

Interesting, I'm surprised it's able to prove that no function changes the m_pool ref. Or maybe it makes the assumption that those values are constant? I guess the same thing would apply to the Box<Lock> that we pass to the AtomaticThread too.
Comment 9 Chris Dumez 2021-05-26 09:42:46 PDT
Created attachment 429767 [details]
Patch
Comment 10 Chris Dumez 2021-05-26 09:46:45 PDT
Comment on attachment 429767 [details]
Patch

Clearing flags on attachment: 429767

Committed r278087 (238164@main): <https://commits.webkit.org/238164@main>
Comment 11 Chris Dumez 2021-05-26 09:46:48 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Radar WebKit Bug Importer 2021-05-26 09:47:18 PDT
<rdar://problem/78517626>