Patch for misleading comment in src/share/vm/opto/node.cpp
Christian Thalinger
Christian.Thalinger at Sun.COM
Tue Feb 24 00:32:45 PST 2009
On Mon, 2009-02-23 at 11:15 -0800, Peter B. Kessler wrote:
> Peter B. Kessler wrote:
> > This comment is so wrong as almost to qualify as malicious. Here's a
> > patch that might help.
> >
> > src/share/vm/opto/node.cpp
> >
> > 971 // If you modify the 'this' pointer's inputs, you must use 'set_req' with
> > 972 // def-use info. If you are making a new Node (either as the new root or
> > 973 // some new internal piece) you must NOT use set_req with def-use info.
> > 974 // You can make a new Node with either 'new' or 'clone'. In either case,
> > 975 // def-use info is (correctly) not generated.
> > 976 // Example: reshape "(X+3)+4" into "X+7":
> > 977 // set_req(1,in(1)->in(1) /* grab X */, du /* must use DU on 'this' */);
> > 978 // set_req(2,phase->intcon(7),du);
> > 979 // return this;
> > - 980 // Example: reshape "X*4" into "X<<1"
> > - 981 // return new (C,3) LShiftINode( in(1), phase->intcon(1) );
> > + 980 // Example: reshape "X*4" into "X<<2"
> > + 981 // return new (C,3) LShiftINode( in(1), phase->intcon(2) );
> > 982 //
> > 983 // You must call 'phase->transform(X)' on any new Nodes X you make, except
> > - 984 // for the returned root node. Example: reshape "X*31" with "(X<<5)-1".
> > - 985 // Node *shift=phase->transform(new(C,3)LShiftINode(in(1),phase->intcon(5)));
> > - 986 // return new (C,3) AddINode(shift, phase->intcon(-1));
> > + 984 // for the returned root node. Example: reshape "X*31" with "(X<<5)-X".
> > + 985 // Node *shift=phase->transform(new(C,3)LShiftINode(in(1),phase->intcon(5)));
> > + 986 // return new (C,3) SubINode(shift, phase->intcon(in(1)));
>
> This last line should probably be
>
> + 986 // return new (C,3) SubINode(shift, in(1));
>
> but I admit I'm a noob in this part of the code. (Which is why I was reading the comments. :-)
I'm not an expert either but it looks good. I'm adding this one to my
typos-repository. Thanks!
-- Christian
More information about the hotspot-compiler-dev
mailing list