Request for reviews (M): 7170463: C2 should recognize "obj.getClass() == A.class" code pattern

Krystal Mok rednaxelafx at gmail.com
Thu May 24 01:28:27 PDT 2012


Hi Vladimir and John,

Thanks for polishing the changes!
Comments inline below:

On Thu, May 24, 2012 at 1:02 PM, John Rose <john.r.rose at oracle.com> wrote:

> On May 23, 2012, at 4:47 PM, Vladimir Kozlov wrote:
>
> I updated webrev:
>
> http://cr.openjdk.java.net/~kvn/7170463/webrev.01
>
> I found additional issue with original changes. They accidentally removed
> optimization which replaces LoadKlass node with ConP (klass type) in map.
> Next code will not be executed:
>
>   cast = con;  // Replace non-constant val by con.
>
> Oops, I didn't notice this assignment handles Longs and Oops too. Thank
for the catch!


> New code should do separate map update of object which klass is compared.
>
>
> That's fine; I like it.
>
> Yes, I like it better this way, too. I couldn't get a clean factoring
of sharpen_type_after_if() with the new and old code mixed together; now it
looks nice.


> New question:  Can the following call return Top?
>   obj_type->join(con_type)
>
> E.g.,
>   Number x = 5;
>   if (x.getClass() == String.class)
>     System.out.println("fail!");
>
> Perhaps the compare will short-circuit before that happens.  If it
> doesn't, we'll get assertion failures or worse.
>
> Maybe we should just do without the join?

Thanks,
Kris


> — John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20120524/40ce788d/attachment.html 


More information about the hotspot-compiler-dev mailing list