Mercurial > hg > graal-jvmci-8
changeset 22152:627188a01c4a
Inlining implicitly casts the receiver to the declared type of the method
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Mon, 06 Jul 2015 12:46:41 -0700 |
parents | 5ac2e4dab379 |
children | 00844f943607 |
files | graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java |
diffstat | 1 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Mon Jul 06 16:27:56 2015 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Mon Jul 06 12:46:41 2015 -0700 @@ -23,7 +23,6 @@ package com.oracle.graal.phases.common.inlining; import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.compiler.common.type.StampFactory.*; import static jdk.internal.jvmci.meta.DeoptimizationAction.*; import static jdk.internal.jvmci.meta.DeoptimizationReason.*; @@ -33,7 +32,7 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.debug.*; -import jdk.internal.jvmci.debug.Debug.*; +import jdk.internal.jvmci.debug.Debug.Scope; import jdk.internal.jvmci.meta.*; import com.oracle.graal.api.replacements.*; @@ -646,21 +645,30 @@ } /** - * Gets the receiver for an invoke, adding a guard if necessary to ensure it is non-null. + * Gets the receiver for an invoke, adding a guard if necessary to ensure it is non-null, and + * ensuring that the resulting type is compatible with the method being invoked. */ public static ValueNode nonNullReceiver(Invoke invoke) { MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget(); assert !callTarget.isStatic() : callTarget.targetMethod(); StructuredGraph graph = callTarget.graph(); ValueNode firstParam = callTarget.arguments().get(0); - if (firstParam.getKind() == Kind.Object && !StampTool.isPointerNonNull(firstParam)) { - IsNullNode condition = graph.unique(new IsNullNode(firstParam)); - Stamp stamp = firstParam.stamp().join(objectNonNull()); - FixedGuardNode fixedGuard = graph.add(new FixedGuardNode(condition, NullCheckException, InvalidateReprofile, true)); - PiNode nonNullReceiver = graph.unique(new PiNode(firstParam, stamp, fixedGuard)); - graph.addBeforeFixed(invoke.asNode(), fixedGuard); - callTarget.replaceFirstInput(firstParam, nonNullReceiver); - return nonNullReceiver; + if (firstParam.getKind() == Kind.Object) { + Stamp paramStamp = firstParam.stamp(); + Stamp stamp = paramStamp.join(StampFactory.declaredNonNull(callTarget.targetMethod().getDeclaringClass())); + if (!StampTool.isPointerNonNull(firstParam)) { + IsNullNode condition = graph.unique(new IsNullNode(firstParam)); + FixedGuardNode fixedGuard = graph.add(new FixedGuardNode(condition, NullCheckException, InvalidateReprofile, true)); + PiNode nonNullReceiver = graph.unique(new PiNode(firstParam, stamp, fixedGuard)); + graph.addBeforeFixed(invoke.asNode(), fixedGuard); + callTarget.replaceFirstInput(firstParam, nonNullReceiver); + return nonNullReceiver; + } + if (!stamp.equals(paramStamp)) { + PiNode cast = graph.unique(new PiNode(firstParam, stamp)); + callTarget.replaceFirstInput(firstParam, cast); + return cast; + } } return firstParam; }