diff graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java @ 9927:81b298e0868b

Merge.
author Christian Haeubl <haeubl@ssw.jku.at>
date Fri, 07 Jun 2013 14:15:38 +0200
parents 26785bb7006d d8a8d794f631
children a9311ec68721
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Fri Jun 07 13:43:13 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Fri Jun 07 14:15:38 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.phases.common;
 
+import static com.oracle.graal.phases.GraalOptions.*;
+
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -33,6 +35,7 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.util.*;
+import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer;
@@ -45,6 +48,11 @@
 
 public class InliningPhase extends Phase {
 
+    // @formatter:off
+    @Option(help = "Unconditionally inline intrinsics")
+    public static final OptionValue<Boolean> AlwaysInlineIntrinsics = new OptionValue<>(false);
+    // @formatter:on
+
     private final PhasePlan plan;
     private final MetaAccessProvider runtime;
     private final Assumptions compilationAssumptions;
@@ -184,9 +192,9 @@
             metricInliningRuns.increment();
             Debug.dump(callerGraph, "after %s", callee);
 
-            if (GraalOptions.OptCanonicalizer) {
+            if (OptCanonicalizer.getValue()) {
                 int markBeforeCanonicalization = callerGraph.getMark();
-                new CanonicalizerPhase.Instance(runtime, callerAssumptions, invokeUsages, markBeforeInlining, customCanonicalizer).apply(callerGraph);
+                new CanonicalizerPhase.Instance(runtime, callerAssumptions, OptCanonicalizeReads.getValue(), invokeUsages, markBeforeInlining, customCanonicalizer).apply(callerGraph);
 
                 // process invokes that are possibly created during canonicalization
                 for (Node newNode : callerGraph.getNewNodes(markBeforeCanonicalization)) {
@@ -257,7 +265,7 @@
                         callerHasMoreInformationAboutArguments = true;
                     } else {
                         Stamp joinedStamp = localNode.stamp().join(arg.stamp());
-                        if (!joinedStamp.equals(localNode.stamp())) {
+                        if (joinedStamp != null && !joinedStamp.equals(localNode.stamp())) {
                             localNode.setStamp(joinedStamp);
                             callerHasMoreInformationAboutArguments = true;
                         }
@@ -270,8 +278,8 @@
                     // probability to check the inlining
                 }
 
-                if (GraalOptions.OptCanonicalizer) {
-                    new CanonicalizerPhase.Instance(runtime, assumptions).apply(newGraph);
+                if (OptCanonicalizer.getValue()) {
+                    new CanonicalizerPhase.Instance(runtime, assumptions, OptCanonicalizeReads.getValue()).apply(newGraph);
                 }
 
                 return newGraph;
@@ -280,7 +288,7 @@
     }
 
     private StructuredGraph getCachedGraph(ResolvedJavaMethod method) {
-        if (GraalOptions.CacheGraphs && cache != null) {
+        if (CacheGraphs.getValue() && cache != null) {
             StructuredGraph cachedGraph = cache.get(method);
             if (cachedGraph != null) {
                 return cachedGraph;
@@ -297,14 +305,14 @@
 
         new DeadCodeEliminationPhase().apply(newGraph);
 
-        if (GraalOptions.OptCanonicalizer) {
-            new CanonicalizerPhase.Instance(runtime, assumptions).apply(newGraph);
+        if (OptCanonicalizer.getValue()) {
+            new CanonicalizerPhase.Instance(runtime, assumptions, OptCanonicalizeReads.getValue()).apply(newGraph);
         }
 
-        if (GraalOptions.CullFrameStates) {
+        if (CullFrameStates.getValue()) {
             new CullFrameStatesPhase().apply(newGraph);
         }
-        if (GraalOptions.CacheGraphs && cache != null) {
+        if (CacheGraphs.getValue() && cache != null) {
             cache.put(newGraph.copy());
         }
         return newGraph;
@@ -330,7 +338,7 @@
         }
 
         protected double computeMaximumSize(double relevance, int configuredMaximum) {
-            double inlineRatio = Math.min(GraalOptions.RelevanceCapForInlining, relevance);
+            double inlineRatio = Math.min(RelevanceCapForInlining.getValue(), relevance);
             return configuredMaximum * inlineRatio;
         }
 
@@ -342,7 +350,7 @@
         }
 
         protected boolean isIntrinsic(InlineInfo info) {
-            if (GraalOptions.AlwaysInlineIntrinsics) {
+            if (AlwaysInlineIntrinsics.getValue()) {
                 return onlyIntrinsics(info);
             } else {
                 return onlyForcedIntrinsics(info);
@@ -412,7 +420,7 @@
         }
 
         public boolean continueInlining(StructuredGraph currentGraph) {
-            if (currentGraph.getNodeCount() >= GraalOptions.MaximumDesiredSize) {
+            if (currentGraph.getNodeCount() >= MaximumDesiredSize.getValue()) {
                 InliningUtil.logInliningDecision("inlining is cut off by MaximumDesiredSize");
                 metricInliningStoppedByMaxDesiredSize.increment();
                 return false;
@@ -429,33 +437,34 @@
             double inliningBonus = getInliningBonus(info);
 
             int lowLevelGraphSize = previousLowLevelGraphSize(info);
-            if (GraalOptions.SmallCompiledLowLevelGraphSize > 0 && lowLevelGraphSize > GraalOptions.SmallCompiledLowLevelGraphSize * inliningBonus) {
+            if (SmallCompiledLowLevelGraphSize.getValue() > 0 && lowLevelGraphSize > SmallCompiledLowLevelGraphSize.getValue() * inliningBonus) {
                 return InliningUtil.logNotInlinedMethod(info, inliningDepth, "too large previous low-level graph: %d", lowLevelGraphSize);
             }
 
+            int nodes = determineNodeCount(info);
+            if (nodes < TrivialInliningSize.getValue() * inliningBonus) {
+                return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "trivial (nodes=%d)", nodes);
+            }
+
             /*
              * TODO (chaeubl): invoked methods that are on important paths but not yet compiled ->
              * will be compiled anyways and it is likely that we are the only caller... might be
              * useful to inline those methods but increases bootstrap time (maybe those methods are
              * also getting queued in the compilation queue concurrently)
              */
-
-            int nodes = determineNodeCount(info);
-            if (nodes < GraalOptions.TrivialInliningSize * inliningBonus) {
-                return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "trivial (nodes=%d)", nodes);
+            double invokes = determineInvokeProbability(info);
+            if (LimitInlinedInvokes.getValue() > 0 && fullyProcessed && invokes > LimitInlinedInvokes.getValue() * inliningBonus) {
+                return InliningUtil.logNotInlinedMethod(info, inliningDepth, "callee invoke probability is too high (%f)", invokes);
             }
 
-            double invokes = determineInvokeProbability(info);
-            if (GraalOptions.LimitInlinedInvokes > 0 && fullyProcessed && invokes > GraalOptions.LimitInlinedInvokes * inliningBonus) {
-                return InliningUtil.logNotInlinedMethod(info, inliningDepth, "invoke probability is too high (%f)", invokes);
+            double maximumNodes = computeMaximumSize(relevance, (int) (MaximumInliningSize.getValue() * inliningBonus));
+            if (nodes <= maximumNodes) {
+                return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d <= max=%f)", relevance, probability,
+                                inliningBonus, nodes, maximumNodes);
             }
 
-            double maximumNodes = computeMaximumSize(relevance, (int) (GraalOptions.MaximumInliningSize * inliningBonus));
-            if (nodes < maximumNodes) {
-                return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "relevance-based (relevance=%f, nodes=%d)", relevance, nodes);
-            }
-
-            return InliningUtil.logNotInlinedMethod(info, inliningDepth, "(relevance=%f, probability=%f, bonus=%f)", relevance, probability, inliningBonus);
+            return InliningUtil.logNotInlinedMethod(info, inliningDepth, "relevance-based (relevance=%f, probability=%f, bonus=%f, nodes=%d > max=%f)", relevance, probability, inliningBonus, nodes,
+                            maximumNodes);
         }
     }
 
@@ -786,7 +795,7 @@
         }
 
         public double invokeRelevance(Invoke invoke) {
-            return Math.min(GraalOptions.CapInheritedRelevance, relevance) * nodeRelevance.get(invoke.asNode());
+            return Math.min(CapInheritedRelevance.getValue(), relevance) * nodeRelevance.get(invoke.asNode());
         }
     }