[inlining] what's best when these two assumptions can be recorded

Garcia Gutierrez Miguel Alfredo miguelalfredo.garcia at epfl.ch
Mon Jan 13 03:28:19 PST 2014


Hi,

I'm trying to understand inlining, so far covering things like Assumptions, InlineInfo.

Getting to InlineUtil::getInlineInfo() I have a question, regarding optimisic assumptions. The snippet below reproduces how getInlineInfo() returns an AssumptionInlineInfo, encapsulating a ConcreteSubtype assumption in one case and a ConcreteMethod assumption in the other.

The emitted code is safe of course because deoptimization + recompilation will trigger "as soon as" a recorded assumption doesn't hold. The code shows a ConcreteSubtype assumption is preferred over a ConcreteMethod assumption. Isn't that too strict at times? Ie doesn't that cause unnecessary recompilations at times? The situation I have in mind involves a class "D" being loaded (thus breaking the ConcreteSubtype assumption) however D doesn't override the targetMethod (which continues to resolve for a D receiver to the same method as "before", ie wouldn't invalidate a ConcreteMethod assumption).

Well, I don't know the specifics of how HotSpot (conservatively?) invalidates a ConcreteMethod assumption. Looks like it shouldn't invalidate as often as a ConcreteSubtype assumption. Thus my question! (In that case, if "findUniqueConcreteMethod" returns non-null, that assumption should be recorded in preference to its ConcreteSubtype formulation, which will be implied by the former, but in general not the other way around).

        if (assumptions.useOptimisticAssumptions()) {
            ResolvedJavaType uniqueSubtype = holder.findUniqueConcreteSubtype();
            if (uniqueSubtype != null) {
                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);
            if (concrete != null) {
                return getAssumptionInlineInfo(data, invoke, replacements, optimisticOpts, concrete, new Assumptions.ConcreteMethod(targetMethod, holder, concrete));
            }
        }




--
Miguel Garcia
Swiss Federal Institute of Technology
EPFL - IC - LAMP1 - INR 328 - Station 14
CH-1015 Lausanne - Switzerland
http://lamp.epfl.ch/~magarcia/


More information about the graal-dev mailing list