Bug 194911

Summary: Add more doesGC() assertions.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: fpizlo, keith_miller, msaboff, rmorisset, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed patch.
saam: review+
proposed patch after applying Saam's and Yusuke's feedback. ysuzuki: review+

Description Mark Lam 2019-02-21 12:15:01 PST
Patch coming.
Comment 1 Radar WebKit Bug Importer 2019-02-21 12:16:44 PST
<rdar://problem/48285723>
Comment 2 Mark Lam 2019-02-21 14:17:57 PST
Created attachment 362645 [details]
proposed patch.
Comment 3 Saam Barati 2019-02-21 14:24:31 PST
Comment on attachment 362645 [details]
proposed patch.

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

> Source/JavaScriptCore/ChangeLog:47
> +        (JSC::Heap::collectAsync):

I wonder if it's correct for this one.

> Source/JavaScriptCore/heap/DeferGC.h:49
> +            if (m_heap.deferralDepth() == 1)

Why would we not always assert this? We generally don't know if we're the outmost or not.

> Source/JavaScriptCore/heap/Heap.cpp:1033
> +        RELEASE_ASSERT(expectDoesGC());

I wonder if this should be based on synchronousness
Comment 4 Mark Lam 2019-02-21 16:12:15 PST
Comment on attachment 362645 [details]
proposed patch.

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

>> Source/JavaScriptCore/ChangeLog:47
>> +        (JSC::Heap::collectAsync):
> 
> I wonder if it's correct for this one.

collectAsync can GC synchronously as well because:
- collectAsync() calls requestCollection()
- requestCollection() calls stopIfNecessary()
- stopIfNecessary() can calls collectInMutatorThread().

>> Source/JavaScriptCore/heap/DeferGC.h:49
>> +            if (m_heap.deferralDepth() == 1)
> 
> Why would we not always assert this? We generally don't know if we're the outmost or not.

You're right.  This check is not needed.  I'll make the assertion unconditional.

>> Source/JavaScriptCore/heap/Heap.cpp:1033
>> +        RELEASE_ASSERT(expectDoesGC());
> 
> I wonder if this should be based on synchronousness

Async can GC in mutator thread as well (as explained above).
Comment 5 Mark Lam 2019-02-21 17:54:00 PST
Created attachment 362679 [details]
proposed patch after applying Saam's and Yusuke's feedback.
Comment 6 Yusuke Suzuki 2019-02-21 17:58:16 PST
Comment on attachment 362679 [details]
proposed patch after applying Saam's and Yusuke's feedback.

r=me
Comment 7 Mark Lam 2019-02-21 18:03:25 PST
Thanks for the reviews.  Landed in r241927: <http://trac.webkit.org/r241927>.