diff graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java @ 4413:c8de52cc672a

Merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Mon, 30 Jan 2012 15:16:33 +0100
parents cd2b68ef8e23 8220fa69f075
children 19fb5eea48b9 539fca6a3b98
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Mon Jan 30 15:08:49 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Mon Jan 30 15:16:33 2012 +0100
@@ -26,13 +26,13 @@
 
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
-import com.oracle.max.criutils.*;
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition;
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.compiler.util.InliningUtil.InlineInfo;
 import com.oracle.max.graal.compiler.util.InliningUtil.InliningCallback;
 import com.oracle.max.graal.cri.*;
+import com.oracle.max.graal.debug.*;
 import com.oracle.max.graal.graph.*;
 import com.oracle.max.graal.nodes.*;
 
@@ -54,6 +54,10 @@
 
     private final PhasePlan plan;
 
+    // Metrics
+    private static final DebugMetric metricInliningPerformed = Debug.metric("InliningPerformed");
+    private static final DebugMetric metricInliningConsidered = Debug.metric("InliningConsidered");
+
     public InliningPhase(CiTarget target, GraalRuntime runtime, Collection<Invoke> hints, CiAssumptions assumptions, PhasePlan plan) {
         this.target = target;
         this.runtime = runtime;
@@ -78,36 +82,24 @@
             InlineInfo info = inlineCandidates.remove();
             double penalty = Math.pow(GraalOptions.InliningSizePenaltyExp, graph.getNodeCount() / (double) GraalOptions.MaximumDesiredSize) / GraalOptions.InliningSizePenaltyExp;
             if (info.weight > GraalOptions.MaximumInlineWeight / (1 + penalty * GraalOptions.InliningSizePenalty)) {
-                if (GraalOptions.TraceInlining) {
-                    TTY.println("not inlining (cut off by weight):");
-                    while (info != null) {
-                        TTY.println("    %f %s", info.weight, info);
-                        info = inlineCandidates.poll();
-                    }
-                }
+                Debug.log("not inlining (cut off by weight): %e", info.weight);
                 return;
             }
             Iterable<Node> newNodes = null;
             if (info.invoke.node().isAlive()) {
                 try {
                     info.inline(graph, runtime, this);
-                    if (GraalOptions.TraceInlining) {
-                        TTY.println("inlining %f: %s", info.weight, info);
-                    }
-                    if (GraalOptions.TraceInlining) {
-                        currentContext.observable.fireCompilationEvent("after inlining " + info, graph);
-                    }
+                    Debug.log("inlining %f: %s", info.weight, info);
+                    Debug.dump(graph, "after inlining %s", info);
                     // get the new nodes here, the canonicalizer phase will reset the mark
                     newNodes = graph.getNewNodes();
                     if (GraalOptions.OptCanonicalizer) {
                         new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
                     }
                     if (GraalOptions.Intrinsify) {
-                        new IntrinsificationPhase(runtime).apply(graph, currentContext);
+                        new IntrinsificationPhase(runtime).apply(graph);
                     }
-                    if (GraalOptions.Meter) {
-                        currentContext.metrics.InlinePerformed++;
-                    }
+                    metricInliningPerformed.increment();
                 } catch (CiBailout bailout) {
                     // TODO determine if we should really bail out of the whole compilation.
                     throw bailout;
@@ -143,9 +135,7 @@
     private void scanInvoke(Invoke invoke, int level) {
         InlineInfo info = InliningUtil.getInlineInfo(invoke, level, runtime, assumptions, this);
         if (info != null) {
-            if (GraalOptions.Meter) {
-                currentContext.metrics.InlineConsidered++;
-            }
+            metricInliningConsidered.increment();
             inlineCandidates.add(info);
         }
     }
@@ -157,14 +147,14 @@
         StructuredGraph newGraph = new StructuredGraph(method);
 
         if (plan != null) {
-            plan.runPhases(PhasePosition.AFTER_PARSING, newGraph, currentContext);
+            plan.runPhases(PhasePosition.AFTER_PARSING, newGraph);
         }
 
         if (GraalOptions.ProbabilityAnalysis) {
-            new DeadCodeEliminationPhase().apply(newGraph, currentContext, false);
-            new ComputeProbabilityPhase().apply(newGraph, currentContext, false);
+            new DeadCodeEliminationPhase().apply(newGraph);
+            new ComputeProbabilityPhase().apply(newGraph);
         }
-        new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph, currentContext, false);
+        new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph);
         return newGraph;
     }
 
@@ -209,9 +199,9 @@
             if (!parsedMethods.containsKey(method)) {
                 StructuredGraph newGraph = new StructuredGraph(method);
                 if (plan != null) {
-                    plan.runPhases(PhasePosition.AFTER_PARSING, newGraph, currentContext);
+                    plan.runPhases(PhasePosition.AFTER_PARSING, newGraph);
                 }
-                new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph, currentContext, false);
+                new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph);
                 count = graphComplexity(newGraph);
                 parsedMethods.put(method, count);
             } else {