# HG changeset patch # User Christian Wimmer # Date 1369783601 25200 # Node ID 59d799c965c9cb72265edf0ab278d1d9af5ffad9 # Parent eed6a2a939202981500048bdf6cd1347dd5ce215 Allow ResolvedJavaType.resolveMethod to return null diff -r eed6a2a93920 -r 59d799c965c9 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Tue May 28 16:16:57 2013 -0700 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Tue May 28 16:26:41 2013 -0700 @@ -198,7 +198,8 @@ * Resolves the method implementation for virtual dispatches on objects of this dynamic type. * * @param method the method to select the implementation of - * @return the method implementation that would be selected at runtime + * @return the method implementation that would be selected at runtime, or {@code null} if the + * runtime cannot resolve the method at this point in time. */ ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method); diff -r eed6a2a93920 -r 59d799c965c9 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue May 28 16:16:57 2013 -0700 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue May 28 16:26:41 2013 -0700 @@ -1107,8 +1107,11 @@ } if (exact != null) { // either the holder class is exact, or the receiver object has an exact type - invokeDirect(exact.resolveMethod(target), args); - return; + ResolvedJavaMethod exactMethod = exact.resolveMethod(target); + if (exactMethod != null) { + invokeDirect(exactMethod, args); + return; + } } // devirtualization failed, produce an actual invokevirtual appendInvoke(invokeKind, target, args); diff -r eed6a2a93920 -r 59d799c965c9 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue May 28 16:16:57 2013 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Tue May 28 16:26:41 2013 -0700 @@ -1033,20 +1033,29 @@ holder = receiverType; if (receiverStamp.isExactType()) { assert targetMethod.getDeclaringClass().isAssignableFrom(holder) : holder + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod; - return getExactInlineInfo(data, invoke, replacements, optimisticOpts, holder.resolveMethod(targetMethod)); + ResolvedJavaMethod resolvedMethod = holder.resolveMethod(targetMethod); + if (resolvedMethod != null) { + return getExactInlineInfo(data, invoke, replacements, optimisticOpts, resolvedMethod); + } } } } if (holder.isArray()) { // arrays can be treated as Objects - return getExactInlineInfo(data, invoke, replacements, optimisticOpts, holder.resolveMethod(targetMethod)); + ResolvedJavaMethod resolvedMethod = holder.resolveMethod(targetMethod); + if (resolvedMethod != null) { + return getExactInlineInfo(data, invoke, replacements, optimisticOpts, resolvedMethod); + } } if (assumptions.useOptimisticAssumptions()) { ResolvedJavaType uniqueSubtype = holder.findUniqueConcreteSubtype(); if (uniqueSubtype != null) { - return getAssumptionInlineInfo(data, invoke, replacements, optimisticOpts, uniqueSubtype.resolveMethod(targetMethod), new Assumptions.ConcreteSubtype(holder, uniqueSubtype)); + ResolvedJavaMethod resolvedMethod = uniqueSubtype.resolveMethod(targetMethod); + if (resolvedMethod != null) { + return getAssumptionInlineInfo(data, invoke, replacements, optimisticOpts, resolvedMethod, new Assumptions.ConcreteSubtype(holder, uniqueSubtype)); + } } ResolvedJavaMethod concrete = holder.findUniqueConcreteMethod(targetMethod); @@ -1122,6 +1131,9 @@ ArrayList concreteMethodsProbabilities = new ArrayList<>(); for (int i = 0; i < ptypes.length; i++) { ResolvedJavaMethod concrete = ptypes[i].getType().resolveMethod(targetMethod); + if (concrete == null) { + return logNotInlinedMethodAndReturnNull(invoke, data.inliningDepth(), targetMethod, "could not resolve method"); + } int index = concreteMethods.indexOf(concrete); double curProbability = ptypes[i].getProbability(); if (index < 0) {