RFR (S) 8141044: C1 should fold (this == null) to false

John Rose john.r.rose at oracle.com
Sun Nov 1 02:10:28 UTC 2015


On Oct 31, 2015, at 5:52 PM, Aleksey Shipilev <aleksey.shipilev at oracle.com> wrote:
> 
> Hi,
> 
> I would like to suggest a simple improvement in C1: folding "(this ==
> null)" to "false". This is a minor nit in A*FU performance with C1.
> 
> JIRA:
>  https://bugs.openjdk.java.net/browse/JDK-8141044
> 
> Webrev:
>  http://cr.openjdk.java.net/~shade/8141044/webrev.01/
> 
> The patch passes JPRT, and improves the generated code in targeted
> benchmarks.

What happens if javac uses Local[0] for another value, and that value is null?

Something has to clear out the _is_receiver bit if Local[0] can ever be set to non-null.

Here's a bad case of how it can go wrong:

foo(x, y) {
entry:
  Local[0] = x; Local[0].is_recv = true;
  Local[1] = y;
loopHead:
  for (;;) {
    if (Local[0] == null)  doSomethingValid();  // SHOULD reach here, if y==null
  trickyBit:
    Local[0] = Local[1];
  }
}

A simple top-down scan over the method body cannot notice the tricky bit until after the optimization has (perhaps) erroneously triggered.

— John


More information about the hotspot-compiler-dev mailing list