# HG changeset patch # User Christian Haeubl # Date 1357544320 -3600 # Node ID 599ea4fcdb6d6f18e10bd0f186228403edf5314b # Parent 64f4195d0ecfad62fb34b775950c40888c322d8b added flag AlwaysInlineIntrinsics diff -r 64f4195d0ecf -r 599ea4fcdb6d graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Wed Dec 19 10:01:08 2012 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Mon Jan 07 08:38:40 2013 +0100 @@ -248,6 +248,10 @@ private static class BytecodeSizeBasedWeightComputationPolicy implements WeightComputationPolicy { @Override public double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke) { + if (GraalOptions.AlwaysInlineIntrinsics && InliningUtil.canIntrinsify(method)) { + return 0; + } + double codeSize = method.getCodeSize(); if (preferredInvoke) { codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis; @@ -259,6 +263,10 @@ private static class ComplexityBasedWeightComputationPolicy implements WeightComputationPolicy { @Override public double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke) { + if (GraalOptions.AlwaysInlineIntrinsics && InliningUtil.canIntrinsify(method)) { + return 0; + } + double complexity = method.getCompilationComplexity(); if (preferredInvoke) { complexity = complexity / GraalOptions.BoostInliningForEscapeAnalysis; @@ -270,6 +278,10 @@ private static class CompiledCodeSizeWeightComputationPolicy implements WeightComputationPolicy { @Override public double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke) { + if (GraalOptions.AlwaysInlineIntrinsics && InliningUtil.canIntrinsify(method)) { + return 0; + } + int compiledCodeSize = method.getCompiledCodeSize(); return compiledCodeSize > 0 ? compiledCodeSize : method.getCodeSize() * 10; } diff -r 64f4195d0ecf -r 599ea4fcdb6d 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 Wed Dec 19 10:01:08 2012 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Mon Jan 07 08:38:40 2013 +0100 @@ -200,11 +200,11 @@ return computeInliningLevel(invoke); } - protected static StructuredGraph getGraph(final Invoke invoke, final ResolvedJavaMethod concrete, final InliningCallback callback) { + protected static StructuredGraph getGraph(final ResolvedJavaMethod concrete, final InliningCallback callback) { return Debug.scope("GetInliningGraph", concrete, new Callable() { @Override public StructuredGraph call() throws Exception { - StructuredGraph result = getIntrinsicGraph(invoke, concrete); + StructuredGraph result = getIntrinsicGraph(concrete); if (result == null) { assert !Modifier.isNative(concrete.getModifiers()); result = callback.buildGraph(concrete); @@ -229,14 +229,14 @@ @Override public void inline(StructuredGraph compilerGraph, GraalCodeCacheProvider runtime, InliningCallback callback, Assumptions assumptions) { - StructuredGraph graph = getGraph(invoke, concrete, callback); + StructuredGraph graph = getGraph(concrete, callback); assumptions.recordMethodContents(concrete); InliningUtil.inline(invoke, graph, true); } @Override public int compiledCodeSize() { - return concrete.getCompiledCodeSize(); + return InliningUtil.compiledCodeSize(concrete); } @Override @@ -261,7 +261,7 @@ @Override public int compiledCodeSize() { - return concrete.getCompiledCodeSize(); + return InliningUtil.compiledCodeSize(concrete); } @Override @@ -283,7 +283,7 @@ graph.addBeforeFixed(invoke.node(), guard); graph.addBeforeFixed(invoke.node(), anchor); - StructuredGraph calleeGraph = getGraph(invoke, concrete, callback); + StructuredGraph calleeGraph = getGraph(concrete, callback); assumptions.recordMethodContents(concrete); InliningUtil.inline(invoke, calleeGraph, false); } @@ -320,7 +320,7 @@ public int compiledCodeSize() { int result = 0; for (ResolvedJavaMethod m: concretes) { - result += m.getCompiledCodeSize(); + result += InliningUtil.compiledCodeSize(m); } return result; } @@ -410,7 +410,7 @@ StructuredGraph[] calleeGraphs = new StructuredGraph[numberOfMethods]; for (int i = 0; i < numberOfMethods; i++) { ResolvedJavaMethod concrete = concretes.get(i); - calleeGraphs[i] = getGraph(invoke, concrete, callback); + calleeGraphs[i] = getGraph(concrete, callback); assumptions.recordMethodContents(concrete); } @@ -512,7 +512,7 @@ calleeEntryNode.setNext(invoke.node()); ResolvedJavaMethod concrete = concretes.get(0); - StructuredGraph calleeGraph = getGraph(invoke, concrete, callback); + StructuredGraph calleeGraph = getGraph(concrete, callback); assumptions.recordMethodContents(concrete); InliningUtil.inline(invoke, calleeGraph, false); } @@ -836,7 +836,7 @@ private static boolean checkTargetConditions(Invoke invoke, ResolvedJavaMethod method, OptimisticOptimizations optimisticOpts) { if (method == null) { return logNotInlinedMethodAndReturnFalse(invoke, method, "the method is not resolved"); - } else if (Modifier.isNative(method.getModifiers()) && (!GraalOptions.Intrinsify || !InliningUtil.canIntrinsify(invoke, method))) { + } else if (Modifier.isNative(method.getModifiers()) && (!GraalOptions.Intrinsify || !InliningUtil.canIntrinsify(method))) { return logNotInlinedMethodAndReturnFalse(invoke, method, "it is a non-intrinsic native method"); } else if (Modifier.isAbstract(method.getModifiers())) { return logNotInlinedMethodAndReturnFalse(invoke, method, "it is an abstract method"); @@ -1030,12 +1030,19 @@ } } - public static boolean canIntrinsify(Invoke invoke, ResolvedJavaMethod target) { - return getIntrinsicGraph(invoke, target) != null; + public static boolean canIntrinsify(ResolvedJavaMethod target) { + return getIntrinsicGraph(target) != null; + } + + public static StructuredGraph getIntrinsicGraph(ResolvedJavaMethod target) { + return (StructuredGraph) target.getCompilerStorage().get(Graph.class); } - public static StructuredGraph getIntrinsicGraph(Invoke invoke, ResolvedJavaMethod target) { - assert invoke.node().isAlive(); - return (StructuredGraph) target.getCompilerStorage().get(Graph.class); + private static int compiledCodeSize(ResolvedJavaMethod target) { + if (GraalOptions.AlwaysInlineIntrinsics && canIntrinsify(target)) { + return 0; + } else { + return target.getCompiledCodeSize(); + } } } diff -r 64f4195d0ecf -r 599ea4fcdb6d graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Dec 19 10:01:08 2012 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Jan 07 08:38:40 2013 +0100 @@ -39,6 +39,7 @@ // inlining settings public static boolean Inline = true; + public static boolean AlwaysInlineIntrinsics = ____; public static boolean Intrinsify = true; static boolean InlineMonomorphicCalls = true; static boolean InlinePolymorphicCalls = true;