Bug 118957

Summary: fourthTier: It should be easy to figure out which blocks nodes belong to
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, ggaren, mark.lam, mhahnenberg, msaboff, oliver, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 118749    
Attachments:
Description Flags
the patch
none
the patch sam: review+

Description Filip Pizlo 2013-07-21 15:38:54 PDT
Patch forthcoming.
Comment 1 Filip Pizlo 2013-07-21 16:10:37 PDT
Created attachment 207217 [details]
the patch
Comment 2 Sam Weinig 2013-07-21 18:17:11 PDT
Comment on attachment 207217 [details]
the patch

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

> Source/JavaScriptCore/dfg/DFGNode.h:1404
>      union {
>          Node* replacement;
> +        BasicBlock* owner;
>      } misc;

Can you add clarification about what ensures that a node only has either a replacement or an owner.
Comment 3 Filip Pizlo 2013-07-21 20:40:54 PDT
(In reply to comment #2)
> (From update of attachment 207217 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207217&action=review
> 
> > Source/JavaScriptCore/dfg/DFGNode.h:1404
> >      union {
> >          Node* replacement;
> > +        BasicBlock* owner;
> >      } misc;
> 
> Can you add clarification about what ensures that a node only has either a replacement or an owner.

It's not like that.  These fields only become valid if you initialize them.  You have to make up your mind, when you initialize them, whether your phase needs to use replacement, or needs to know the node-to-block mapping.  Most phases need neither of these pieces of information.  Only three phases use replacements, and the only phases that will use owners are LICM and possibly GVN.
Comment 4 Filip Pizlo 2013-07-21 20:43:37 PDT
Created attachment 207222 [details]
the patch
Comment 5 Sam Weinig 2013-07-21 20:44:27 PDT
Comment on attachment 207217 [details]
the patch

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

>>> Source/JavaScriptCore/dfg/DFGNode.h:1404
>>>      } misc;
>> 
>> Can you add clarification about what ensures that a node only has either a replacement or an owner.
> 
> It's not like that.  These fields only become valid if you initialize them.  You have to make up your mind, when you initialize them, whether your phase needs to use replacement, or needs to know the node-to-block mapping.  Most phases need neither of these pieces of information.  Only three phases use replacements, and the only phases that will use owners are LICM and possibly GVN.

Ok.  You probably want to add some indication of that (or an assertion if possible), as it wasn't clear.
Comment 6 Sam Weinig 2013-07-21 20:45:12 PDT
(In reply to comment #5)
> (From update of attachment 207217 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207217&action=review
> 
> >>> Source/JavaScriptCore/dfg/DFGNode.h:1404
> >>>      } misc;
> >> 
> >> Can you add clarification about what ensures that a node only has either a replacement or an owner.
> > 
> > It's not like that.  These fields only become valid if you initialize them.  You have to make up your mind, when you initialize them, whether your phase needs to use replacement, or needs to know the node-to-block mapping.  Most phases need neither of these pieces of information.  Only three phases use replacements, and the only phases that will use owners are LICM and possibly GVN.
> 
> Ok.  You probably want to add some indication of that (or an assertion if possible), as it wasn't clear.

Moments later, you updated it!  r=me.
Comment 7 Filip Pizlo 2013-07-21 20:48:40 PDT
(In reply to comment #5)
> (From update of attachment 207217 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=207217&action=review
> 
> >>> Source/JavaScriptCore/dfg/DFGNode.h:1404
> >>>      } misc;
> >> 
> >> Can you add clarification about what ensures that a node only has either a replacement or an owner.
> > 
> > It's not like that.  These fields only become valid if you initialize them.  You have to make up your mind, when you initialize them, whether your phase needs to use replacement, or needs to know the node-to-block mapping.  Most phases need neither of these pieces of information.  Only three phases use replacements, and the only phases that will use owners are LICM and possibly GVN.
> 
> Ok.  You probably want to add some indication of that (or an assertion if possible), as it wasn't clear.

I don't think an assertion is either possible or profitable - we don't have any kind of natural way of checking if a pointer points to a Node or a BasicBlock.  Also, each phase first initializes 'misc', and then uses it, often in a very obvious way.  Like, you'll literally see one loop that initializes them and another loop that uses them.
Comment 8 Filip Pizlo 2013-07-21 20:57:03 PDT
Landed in http://trac.webkit.org/changeset/152958