Bug 228890

Summary: [ARM64] Clean up and fix Pre/Post-Indexed Address Mode to Air for ARM64 (Load Instruction)
Product: WebKit Reporter: Yijia Huang <yijia_huang>
Component: JavaScriptCoreAssignee: Yijia Huang <yijia_huang>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, 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
Patch
none
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch none

Description Yijia Huang 2021-08-06 20:54:36 PDT
...
Comment 1 Yijia Huang 2021-08-06 23:04:15 PDT
Created attachment 435116 [details]
Patch
Comment 2 Mark Lam 2021-08-07 10:21:09 PDT
Comment on attachment 435116 [details]
Patch

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

> Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:142
> +    auto detect = [&] (const HashMap<MemoryValue*, Value*>& candidates, bool isPreIndexCandidiates) {

Typo: /isPreIndexCandidiates/isPreIndexCandidates/

> Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:165
> +                if (!controlEquivalent(memory, address->child(1)))

Can you put a brief description in the ChangeLog as to why this is needed?

> Source/JavaScriptCore/b3/B3LowerToAir.cpp:2585
> +            //     memory = load(base, 0)                MoveWithIncrement (%address, posfix(offset)) %memory

/posfix/postfix/

> Source/JavaScriptCore/b3/B3LowerToAir.cpp:2591
> +                if (m_locked.contains(address) || address->opcode() != Add || address->type() != Int64)

Please put a brief description in the ChangeLog as to why this m_locked check is needed.

> Source/JavaScriptCore/b3/air/AirArg.h:1319
> +            return isValidIncrementIndexForm(offset());

You can remove this line too.
Comment 3 Yijia Huang 2021-08-07 16:42:01 PDT
Created attachment 435137 [details]
Patch
Comment 4 Yijia Huang 2021-08-07 16:43:04 PDT
(In reply to Mark Lam from comment #2)
> Comment on attachment 435116 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=435116&action=review
> 

Thanks for reviewing. Updated.
Comment 5 Yijia Huang 2021-08-07 17:15:17 PDT
Created attachment 435139 [details]
Patch
Comment 6 Yijia Huang 2021-08-07 20:58:45 PDT
Created attachment 435142 [details]
Patch
Comment 7 Yijia Huang 2021-08-07 21:01:47 PDT
Created attachment 435143 [details]
Patch
Comment 8 Yijia Huang 2021-08-08 03:40:40 PDT
Created attachment 435148 [details]
Patch
Comment 9 Yijia Huang 2021-08-08 14:14:32 PDT
Created attachment 435156 [details]
Patch
Comment 10 Yijia Huang 2021-08-08 19:10:36 PDT
Created attachment 435162 [details]
Patch
Comment 11 Yijia Huang 2021-08-08 19:30:23 PDT
Created attachment 435164 [details]
Patch
Comment 12 Yijia Huang 2021-08-08 23:18:04 PDT
Created attachment 435168 [details]
Patch
Comment 13 Keith Miller 2021-08-09 15:33:32 PDT
Comment on attachment 435168 [details]
Patch

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

r=me with nit.

> Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:147
> +    auto detect = [&] (const HashMap<MemoryValue*, Value*>& candidates, bool isPreIndexCandidates) {

Nit: I'd change `isPreIndexCandidate` to a lambda which contains the logic to do the canonicalization. I find it to be an anti pattern to pass a bool to a lambda where there is exactly one call with true and false.
Comment 14 EWS 2021-08-09 16:46:17 PDT
Committed r280808 (240378@main): <https://commits.webkit.org/240378@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 435168 [details].
Comment 15 Radar WebKit Bug Importer 2021-08-09 16:59:24 PDT
<rdar://problem/81719365>
Comment 16 Mark Lam 2021-08-09 18:08:11 PDT
(In reply to Keith Miller from comment #13)
> Comment on attachment 435168 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=435168&action=review
> 
> r=me with nit.
> 
> > Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:147
> > +    auto detect = [&] (const HashMap<MemoryValue*, Value*>& candidates, bool isPreIndexCandidates) {
> 
> Nit: I'd change `isPreIndexCandidate` to a lambda which contains the logic
> to do the canonicalization. I find it to be an anti pattern to pass a bool
> to a lambda where there is exactly one call with true and false.

Why was this not addressed in the landed patch?
Comment 17 Yijia Huang 2021-08-09 18:28:16 PDT
(In reply to Mark Lam from comment #16)
> (In reply to Keith Miller from comment #13)
> > Comment on attachment 435168 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=435168&action=review
> > 
> > r=me with nit.
> > 
> > > Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:147
> > > +    auto detect = [&] (const HashMap<MemoryValue*, Value*>& candidates, bool isPreIndexCandidates) {
> > 
> > Nit: I'd change `isPreIndexCandidate` to a lambda which contains the logic
> > to do the canonicalization. I find it to be an anti pattern to pass a bool
> > to a lambda where there is exactly one call with true and false.
> 
> Why was this not addressed in the landed patch?

Sorry, I will update it in the next patch with the store instruction.
Comment 18 Mark Lam 2021-08-09 18:34:53 PDT
Comment on attachment 435168 [details]
Patch

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

> Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:157
> +                // ***                          -->  newMemory = Load(base, offset)
> +                // ***                               ***

Curious: what is the meaning of the "***" here?
Comment 19 Yijia Huang 2021-08-09 18:46:11 PDT
(In reply to Mark Lam from comment #18)
> Comment on attachment 435168 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=435168&action=review
> 
> > Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:157
> > +                // ***                          -->  newMemory = Load(base, offset)
> > +                // ***                               ***
> 
> Curious: what is the meaning of the "***" here?

I was using the ellipsis (...) to indicate any code between them. But it violates the code style, where the format checker requires only one space after the period.
Comment 20 Mark Lam 2021-08-09 19:39:19 PDT
(In reply to Yijia Huang from comment #19)
> (In reply to Mark Lam from comment #18)
> > Comment on attachment 435168 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=435168&action=review
> > 
> > > Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:157
> > > +                // ***                          -->  newMemory = Load(base, offset)
> > > +                // ***                               ***
> > 
> > Curious: what is the meaning of the "***" here?
> 
> I was using the ellipsis (...) to indicate any code between them. But it
> violates the code style, where the format checker requires only one space
> after the period.

Oh, in that case, I would just ignore the style checker because you have a valid use case there.
Comment 21 Yijia Huang 2021-08-09 19:47:07 PDT
(In reply to Mark Lam from comment #20)
> (In reply to Yijia Huang from comment #19)
> > (In reply to Mark Lam from comment #18)
> > > Comment on attachment 435168 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=435168&action=review
> > > 
> > > > Source/JavaScriptCore/b3/B3CanonicalizePrePostIncrements.cpp:157
> > > > +                // ***                          -->  newMemory = Load(base, offset)
> > > > +                // ***                               ***
> > > 
> > > Curious: what is the meaning of the "***" here?
> > 
> > I was using the ellipsis (...) to indicate any code between them. But it
> > violates the code style, where the format checker requires only one space
> > after the period.
> 
> Oh, in that case, I would just ignore the style checker because you have a
> valid use case there.

If I ignore that, would others encounter the checker warning every time they upload a patch because of it?
Comment 22 Mark Lam 2021-08-09 20:01:30 PDT
(In reply to Yijia Huang from comment #21)
> If I ignore that, would others encounter the checker warning every time they
> upload a patch because of it?

Only if they touch that line.