Bug 213566 - Bytecode UseDef should be aware of checkpoints
Summary: Bytecode UseDef should be aware of checkpoints
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Miller
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-24 10:17 PDT by Keith Miller
Modified: 2020-07-07 17:32 PDT (History)
8 users (show)

See Also:


Attachments
Patch (54.40 KB, patch)
2020-06-24 11:19 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (54.45 KB, patch)
2020-06-24 11:20 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (56.63 KB, patch)
2020-06-24 12:00 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (55.17 KB, patch)
2020-06-24 14:39 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (53.27 KB, patch)
2020-07-06 17:21 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (52.34 KB, patch)
2020-07-07 12:11 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (52.35 KB, patch)
2020-07-07 16:52 PDT, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Miller 2020-06-24 10:17:55 PDT
Bytecode UseDef should be aware of checkpoints
Comment 1 Keith Miller 2020-06-24 11:19:09 PDT
Created attachment 402663 [details]
Patch
Comment 2 Keith Miller 2020-06-24 11:20:44 PDT
Created attachment 402664 [details]
Patch
Comment 3 Keith Miller 2020-06-24 12:00:51 PDT
Created attachment 402669 [details]
Patch
Comment 4 Keith Miller 2020-06-24 14:39:38 PDT
Created attachment 402689 [details]
Patch
Comment 5 Saam Barati 2020-06-25 12:13:18 PDT
Comment on attachment 402689 [details]
Patch

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

> Source/JavaScriptCore/bytecode/BytecodeIndex.h:37
> +using Checkpoint = uint8_t;

nit: Maybe CheckpointIndex?

> Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.cpp:64
> +            for (Checkpoint checkpoint = instructions.at(bytecodeIndex)->numberOfCheckpoints(); checkpoint--;) {

just for sanity reading this too, can you assert numberOfCheckpoints is < length of the bytecode

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:293
> +    case op_iterator_open: {
> +        auto bytecode = instruction->as<OpIteratorOpen>();
> +        functor(OpIteratorOpen::symbolCall, bytecode.m_symbolIterator);
> +        functor(OpIteratorOpen::symbolCall, bytecode.m_iterable);
> +        functor(OpIteratorOpen::getNext, bytecode.m_iterator);
> +        return;
> +    }

this feels like a curious implementation. Why not just branch on the checkpoint being passed in here to see if it's the right checkpoint? Instead of branching on the caller side to see if you're dealing with the right checkpoint. I think it's a much more obviously correct implementation.
Comment 6 Keith Miller 2020-07-06 17:21:28 PDT
Created attachment 403644 [details]
Patch
Comment 7 Saam Barati 2020-07-06 23:55:26 PDT
Comment on attachment 403644 [details]
Patch

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

r=me

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:49
> +    auto functor = [&] (Checkpoint target, VirtualRegister operand) {

Calling this functor and the other functorImpl are weird. I’d keep the parameter functor, and maybe call this “useAtCheckpoint” or something?

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:57
> +            functor(noCheckpoints, VirtualRegister { base - i });

Why not functorImpl?

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:64
> +            functor(noCheckpoints, VirtualRegister { lastArg + i });

Why not functorImpl?

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:66
> +            functor(noCheckpoints, scopeRegister);

Why not functorImpl?

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:266
> +        useAtEachCheckpoint(bytecode.m_callee, bytecode.m_thisValue, bytecode.m_arguments);

Is this just so you can add the static assert to the macro? If so, I’m not sure it’s accomplishing much. I kinda like calling the macro instead and removing the static assert

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:292
> +        auto bytecode = instruction->as<OpIteratorOpen>();

Alternatively to my suggestion on naming of functor and functorImpl to useAtCheckpoint, you could totally just switch on the bytecode index here. Might be a nicer style tbh and is in line with switching on the bytecode itself.

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:318
> +            functor(noCheckpoints, VirtualRegister { base - i });

Why not functorImpl?

> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:343
> +    auto functor = [&] (Checkpoint target, VirtualRegister operand) {

Ditto about naming

> Source/JavaScriptCore/dfg/DFGForAllKills.h:90
> +        } else if (before.bytecodeIndex().checkpoint()) {

Do we have an assert anywhere that no temp can be live-in to checkpoint 0?
Comment 8 Keith Miller 2020-07-07 11:36:13 PDT
Comment on attachment 403644 [details]
Patch

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

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:49
>> +    auto functor = [&] (Checkpoint target, VirtualRegister operand) {
> 
> Calling this functor and the other functorImpl are weird. I’d keep the parameter functor, and maybe call this “useAtCheckpoint” or something?

Sure, seems reasonable.

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:57
>> +            functor(noCheckpoints, VirtualRegister { base - i });
> 
> Why not functorImpl?

Done.

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:64
>> +            functor(noCheckpoints, VirtualRegister { lastArg + i });
> 
> Why not functorImpl?

Done.

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:66
>> +            functor(noCheckpoints, scopeRegister);
> 
> Why not functorImpl?

Done.

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:266
>> +        useAtEachCheckpoint(bytecode.m_callee, bytecode.m_thisValue, bytecode.m_arguments);
> 
> Is this just so you can add the static assert to the macro? If so, I’m not sure it’s accomplishing much. I kinda like calling the macro instead and removing the static assert

The macro doesn't work for all the checkpoint bytecodes since it includes the switch label in it. I figured it was better to be consistent among the checkpoint bytecodes. I don't have strong feelings though.

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:292
>> +        auto bytecode = instruction->as<OpIteratorOpen>();
> 
> Alternatively to my suggestion on naming of functor and functorImpl to useAtCheckpoint, you could totally just switch on the bytecode index here. Might be a nicer style tbh and is in line with switching on the bytecode itself.

Yeah, my only thought was that seemed more verbose. If you think it's better though, I'll change it.

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:318
>> +            functor(noCheckpoints, VirtualRegister { base - i });
> 
> Why not functorImpl?

Done.

>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:343
>> +    auto functor = [&] (Checkpoint target, VirtualRegister operand) {
> 
> Ditto about naming

Done.

>> Source/JavaScriptCore/dfg/DFGForAllKills.h:90
>> +        } else if (before.bytecodeIndex().checkpoint()) {
> 
> Do we have an assert anywhere that no temp can be live-in to checkpoint 0?

No, I think we only assert nothing is live out and isn't live at the prologue.
Comment 9 Keith Miller 2020-07-07 12:05:11 PDT
Comment on attachment 403644 [details]
Patch

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

>>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:49
>>> +    auto functor = [&] (Checkpoint target, VirtualRegister operand) {
>> 
>> Calling this functor and the other functorImpl are weird. I’d keep the parameter functor, and maybe call this “useAtCheckpoint” or something?
> 
> Sure, seems reasonable.

I killed this lambda so there's just the argument now, which still has the name `functor`.

>>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:292
>>> +        auto bytecode = instruction->as<OpIteratorOpen>();
>> 
>> Alternatively to my suggestion on naming of functor and functorImpl to useAtCheckpoint, you could totally just switch on the bytecode index here. Might be a nicer style tbh and is in line with switching on the bytecode itself.
> 
> Yeah, my only thought was that seemed more verbose. If you think it's better though, I'll change it.

I think I'm going to add a useAtEachCheckpointStartingWith rather than have switches that have a bunch of `FALLTHROUGH` everywhere.

>>> Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp:343
>>> +    auto functor = [&] (Checkpoint target, VirtualRegister operand) {
>> 
>> Ditto about naming
> 
> Done.

I renamed this lambda to `defAt` and kept the argument as `functor`
Comment 10 Keith Miller 2020-07-07 12:11:50 PDT
Created attachment 403710 [details]
Patch for landing
Comment 11 Keith Miller 2020-07-07 12:12:58 PDT
rdar://64639220
Comment 12 Aakash Jain 2020-07-07 15:34:58 PDT
(In reply to Keith Miller from comment #10)
> Created attachment 403710 [details]
> Patch for landing
Can you please check if the test failures in following build are caused by this patch:

https://ews-build.webkit.org/#/builders/28/builds/3309
https://ews-build.webkit.org/#/builders/30/builds/13355
https://ews-build.webkit.org/#/builders/31/builds/13509
Comment 13 Keith Miller 2020-07-07 16:08:47 PDT
(In reply to Aakash Jain from comment #12)
> (In reply to Keith Miller from comment #10)
> > Created attachment 403710 [details]
> > Patch for landing
> Can you please check if the test failures in following build are caused by
> this patch:
> 
> https://ews-build.webkit.org/#/builders/28/builds/3309
> https://ews-build.webkit.org/#/builders/30/builds/13355
> https://ews-build.webkit.org/#/builders/31/builds/13509

Seems unlikely given the patch before was green and I only did minor refactors. I'll double check though.
Comment 14 EWS 2020-07-07 16:51:19 PDT
Found 1 new test failure: inspector/dom/domutilities-csspath.html
Comment 15 Keith Miller 2020-07-07 16:51:56 PDT
(In reply to Keith Miller from comment #13)
> (In reply to Aakash Jain from comment #12)
> > (In reply to Keith Miller from comment #10)
> > > Created attachment 403710 [details]
> > > Patch for landing
> > Can you please check if the test failures in following build are caused by
> > this patch:
> > 
> > https://ews-build.webkit.org/#/builders/28/builds/3309
> > https://ews-build.webkit.org/#/builders/30/builds/13355
> > https://ews-build.webkit.org/#/builders/31/builds/13509
> 
> Seems unlikely given the patch before was green and I only did minor
> refactors. I'll double check though.

Whoops, looks like there was a >= that should have been a <=... I guess forgot to test before uploading 😬
Comment 16 Keith Miller 2020-07-07 16:52:24 PDT
Created attachment 403744 [details]
Patch for landing
Comment 17 EWS 2020-07-07 17:32:40 PDT
Committed r264049: <https://trac.webkit.org/changeset/264049>

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