Bug 223278

Summary: DFG arity fixup nodes should exit to the caller's call opcode
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: New BugsAssignee: Keith Miller <keith_miller>
Status: RESOLVED FIXED    
Severity: Normal CC: aperez, ews-watchlist, magomez, 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 for landing none

Description Keith Miller 2021-03-16 14:06:04 PDT
DFG arity fixup nodes should exit to the caller's call opcode
Comment 1 Radar WebKit Bug Importer 2021-03-23 14:07:13 PDT
<rdar://problem/75754212>
Comment 2 Keith Miller 2021-03-31 09:19:39 PDT
Created attachment 424777 [details]
Patch
Comment 3 Saam Barati 2021-03-31 12:11:24 PDT
Comment on attachment 424777 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:29
> +        --> foo: loc10 is a local in foo.
> +            ...
> +            1: MovHint(loc10)
> +            2: SetLocal(loc10)
> +        <-- foo // loc10 ten is now out of scope for the InlineCallFrame of the caller.
> +        ...
> +        // Phantom will be inserted here refering to loc10, which doesn't make sense.
> +        --> bar // loc10 is an argument to bar and needs arity fixup.
> +            ... // All of these nodes are ExitInvalid
> +            3: MovHint(loc10, ExitInvalid)
> +            4: SetLocal(loc10, ExitInvalid)
> +            ...

How does changing the exit origin fix this?

> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:1730
> +    // In this example phantom insertion phase will think @3 is always alive because it's in the header of bar. So,
> +    // it will think we are about to kill the old value and thus need a Phantom. That Phantom, however, may be inserted
> +    // into the caller's NodeOrigin (all the nodes in bar before @3 are ExitInvalid), which doesn't know about loc10.

how does setting the exit origin fix this?
Comment 4 Keith Miller 2021-04-05 11:16:36 PDT
Comment on attachment 424777 [details]
Patch

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

>> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:1730
>> +    // into the caller's NodeOrigin (all the nodes in bar before @3 are ExitInvalid), which doesn't know about loc10.
> 
> how does setting the exit origin fix this?

Since PhantomInsertionPhase asks forAllKilledOperands what locals have been killed at any given Node and loc10 is in the header of bar loc10 will go from being considered dead in the caller to alive again in the callee (and killed at @3). By setting the exit origin to the caller's frame for arity fixup loc10 will not be seen as alive into @3 anymore. I'll add this to the comment.
Comment 5 Keith Miller 2021-04-05 11:30:05 PDT
Created attachment 425177 [details]
Patch for landing
Comment 6 EWS 2021-04-05 18:52:11 PDT
Committed r275472: <https://commits.webkit.org/r275472>

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