NullCheckOp

Deneau, Tom tom.deneau at amd.com
Sat Dec 28 07:00:11 PST 2013


Thomas --

I tried -G:-OptImplicitNullChecks, it did not make any difference.
I think the problem is here:

    private static void processBlock(Block block, SchedulePhase schedule, int implicitNullCheckLimit) {
        if (OptImplicitNullChecks.getValue() && implicitNullCheckLimit > 0) {
            new UseImplicitNullChecks(implicitNullCheckLimit).processNodes(block, schedule);
        }
        new LowerGuards(block).processNodes(block, schedule);
    }

In that we still go thru LowerGuards.processNodes which eventually gets to GuardNode.lowerGuard
and the if block conditions are all met here so the NullCheckNode is created...

    public FixedWithNextNode lowerGuard() {
        if (negated() && condition() instanceof IsNullNode) {
            IsNullNode isNull = (IsNullNode) condition();
            NullCheckNode nullCheck = graph().add(new NullCheckNode(isNull.object()));
            setCondition(null);
            if (isNull.usages().isEmpty()) {
                isNull.safeDelete();
            }
            return nullCheck;
        }

        return null;
    }

I have confirmed that if I force GuardNode.lowerGuard to just return null, the explicit null comparison and deopt node works correctly.

-- Tom



> -----Original Message-----
> From: Thomas Wuerthinger [mailto:thomas.wuerthinger at oracle.com]
> Sent: Saturday, December 28, 2013 6:41 AM
> To: Deneau, Tom
> Cc: graal-dev at openjdk.java.net; Christian Thalinger
> Subject: Re: NullCheckOp
> 
> Tom,
> 
> The flag "OptImplicitNullChecks" controls whether the compiler tries to
> create implicit null check instructions. If you set it to false, the
> code generated is equivalent to a comparison of the value against null
> and a deoptimization if the comparison yields true.
> 
> - thomas
> 
> On 24 Dec 2013, at 03:45, Christian Thalinger
> <christian.thalinger at oracle.com> wrote:
> 
> > I'm not an expert on this but it seems that a NullCheckOp (or a
> NullCheckNode) only does an implicit null check; there is no branch
> information attached to it.
> >
> > In order to do an explicit exception you'd need to add nodes to the
> graph that throw the exception.  Not sure if something like this exists
> already.
> >
> > On Dec 23, 2013, at 1:24 PM, Deneau, Tom <tom.deneau at amd.com> wrote:
> >
> >> I am trying to get null checks working on the hsail backend.
> >> What is required of NullCheckOp in the HSAILLIRGenerator?
> >> On Hsail, we can't support an implicit exception for this like amd64
> does  so I think we would just want to end up with an explicit compare
> and branch if null to something that would be similar to the code
> emitted for a deoptimizing node.  How much of that does NullCheckOp have
> to do?
> >>
> >> -- Tom
> >
> 




More information about the graal-dev mailing list