Bug 226000 - AbstractSlotVisitor::containsOpaqueRoot() should only declare didFindOpaqueRoot if the root is actually found.
Summary: AbstractSlotVisitor::containsOpaqueRoot() should only declare didFindOpaqueRo...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-19 19:24 PDT by Mark Lam
Modified: 2021-05-19 20:34 PDT (History)
7 users (show)

See Also:


Attachments
proposed patch. (1.64 KB, patch)
2021-05-19 19:29 PDT, Mark Lam
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2021-05-19 19:24:31 PDT
It was erroneously calling didFindOpaqueRoot() all the time even when the root is not found.

rdar://78208014
Comment 1 Mark Lam 2021-05-19 19:29:55 PDT
Created attachment 429126 [details]
proposed patch.
Comment 2 Robin Morisset 2021-05-19 19:35:25 PDT
Comment on attachment 429126 [details]
proposed patch.

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

> Source/JavaScriptCore/heap/AbstractSlotVisitorInlines.h:136
> +    if (UNLIKELY(found && m_needsExtraOpaqueRootHandling)) {

Is there a reason to check found first and m_needsExtraOpaqueRootHandling second?

If anything, I would expect the entire check of m_opaqueRoots.contains(ptr) to be only done after checking m_needsExtraOpaqueRootHandling, especially if it is UNLIKELY.
Comment 3 Mark Lam 2021-05-19 19:37:52 PDT
(In reply to Robin Morisset from comment #2)
> Comment on attachment 429126 [details]
> proposed patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=429126&action=review
> 
> > Source/JavaScriptCore/heap/AbstractSlotVisitorInlines.h:136
> > +    if (UNLIKELY(found && m_needsExtraOpaqueRootHandling)) {
> 
> Is there a reason to check found first and m_needsExtraOpaqueRootHandling
> second?
> 
> If anything, I would expect the entire check of m_opaqueRoots.contains(ptr)
> to be only done after checking m_needsExtraOpaqueRootHandling, especially if
> it is UNLIKELY.

I check found first because found is already in memory.  If not found, we save on triggering a load of m_needsExtraOpaqueRootHandling.
Comment 4 Robin Morisset 2021-05-19 19:43:14 PDT
Comment on attachment 429126 [details]
proposed patch.

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

r=me

>>> Source/JavaScriptCore/heap/AbstractSlotVisitorInlines.h:136
>>> +    if (UNLIKELY(found && m_needsExtraOpaqueRootHandling)) {
>> 
>> Is there a reason to check found first and m_needsExtraOpaqueRootHandling second?
>> 
>> If anything, I would expect the entire check of m_opaqueRoots.contains(ptr) to be only done after checking m_needsExtraOpaqueRootHandling, especially if it is UNLIKELY.
> 
> I check found first because found is already in memory.  If not found, we save on triggering a load of m_needsExtraOpaqueRootHandling.

I had missed that we eventually return found and so we need to compute it even if !m_needsExtraOpaqueRootHandling.
Comment 5 Mark Lam 2021-05-19 19:45:22 PDT
Comment on attachment 429126 [details]
proposed patch.

Thanks for the review.  Landing now.
Comment 6 EWS 2021-05-19 20:34:36 PDT
Committed r277773 (237934@main): <https://commits.webkit.org/237934@main>

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