changeset 2903:eb3a82946429

Measure nodes created and nodes deleted for nodes. New option -G:+Meter.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 08 Jun 2011 17:26:22 +0200
parents 434d71eec7a9
children 1916da1d3e11
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java runfop.sh
diffstat 8 files changed, 63 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Wed Jun 08 17:07:06 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Wed Jun 08 17:26:22 2011 +0200
@@ -205,7 +205,7 @@
             emitLIR();
             targetMethod = emitCode();
 
-            if (GraalOptions.PrintMetrics) {
+            if (GraalOptions.Meter) {
                 GraalMetrics.BytecodesCompiled += method.code().length;
             }
         } catch (CiBailout b) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java	Wed Jun 08 17:07:06 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalMetrics.java	Wed Jun 08 17:26:22 2011 +0200
@@ -24,6 +24,7 @@
 
 import java.lang.reflect.*;
 import java.util.*;
+import java.util.Map.*;
 
 import com.oracle.max.graal.compiler.debug.*;
 
@@ -32,7 +33,7 @@
  * This class contains a number of fields that collect metrics about compilation, particularly
  * the number of times certain optimizations are performed.
  */
-public class GraalMetrics {
+public final class GraalMetrics {
     public static int CompiledMethods;
     public static int TargetMethods;
     public static int LocalValueNumberHits;
@@ -67,6 +68,33 @@
     public static void print() {
         printClassFields(GraalMetrics.class);
 
+        for (Entry<String, GraalMetrics> m : map.entrySet()) {
+            printField(m.getKey(), m.getValue().value);
+        }
+    }
+
+    private static LinkedHashMap<String, GraalMetrics> map = new LinkedHashMap<String, GraalMetrics>();
+
+    public static GraalMetrics get(String name) {
+        if (!map.containsKey(name)) {
+            map.put(name, new GraalMetrics(name));
+        }
+        return map.get(name);
+    }
+
+    private GraalMetrics(String name) {
+        this.name = name;
+    }
+
+    private int value;
+    private String name;
+
+    public void increment() {
+        increment(1);
+    }
+
+    public void increment(int val) {
+        value += val;
     }
 
     public static void printClassFields(Class<?> javaClass) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Jun 08 17:07:06 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Jun 08 17:26:22 2011 +0200
@@ -77,7 +77,7 @@
     public static int     PrintIdealGraphPort                = 4444;
 
     // Other printing settings
-    public static boolean PrintMetrics                       = ____;
+    public static boolean Meter                              = ____;
     public static boolean Time                               = ____;
     public static boolean PrintCompilation                   = ____;
     public static boolean PrintXirTemplates                  = ____;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java	Wed Jun 08 17:07:06 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java	Wed Jun 08 17:26:22 2011 +0200
@@ -68,7 +68,7 @@
             }
         }
 
-        if (GraalOptions.PrintMetrics) {
+        if (GraalOptions.Meter) {
             GraalMetrics.TargetMethods++;
             GraalMetrics.CodeBytesEmitted += targetMethod.targetCodeSize();
             GraalMetrics.SafepointsEmitted += targetMethod.safepoints.size();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Wed Jun 08 17:07:06 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Wed Jun 08 17:26:22 2011 +0200
@@ -109,7 +109,7 @@
      * @param graph
      */
     public GraphBuilderPhase(GraalCompilation compilation, RiMethod method, boolean createUnwind, boolean inline) {
-        super(inline ? "Build Inline Graph" : "Build Graph");
+        super(inline ? "BuildInlineGraph" : "BuildGraph");
         this.compilation = compilation;
 
         this.runtime = compilation.runtime;
@@ -201,11 +201,7 @@
         // remove FrameStates
         for (Node n : graph.getNodes()) {
             if (n instanceof FrameState) {
-                boolean delete = false;
                 if (n.usages().size() == 0 && n.predecessors().size() == 0) {
-                    delete = true;
-                }
-                if (delete) {
                     n.delete();
                 }
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Wed Jun 08 17:07:06 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Wed Jun 08 17:26:22 2011 +0200
@@ -43,9 +43,10 @@
 
         int startDeletedNodeCount = graph.getDeletedNodeCount();
         int startNodeCount = graph.getNodeCount();
-        Phase oldCurrentPhase = currentPhase.get();
-        currentPhase.set(this);
+        Phase oldCurrentPhase = null;
         if (GraalOptions.Time) {
+            oldCurrentPhase = currentPhase.get();
+            currentPhase.set(this);
             if (oldCurrentPhase != null) {
                 GraalTimers.get(oldCurrentPhase.getName()).stop();
             }
@@ -57,10 +58,15 @@
             if (oldCurrentPhase != null) {
                 GraalTimers.get(oldCurrentPhase.getName()).start();
             }
+            currentPhase.set(oldCurrentPhase);
         }
-        currentPhase.set(oldCurrentPhase);
-        int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount;
-        int nodeCount = graph.getNodeCount() - startNodeCount;
+        if (GraalOptions.Meter) {
+            int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount;
+            int createdNodeCount = graph.getNodeCount() - startNodeCount;
+            GraalMetrics.get(getName().concat(".executed")).increment();
+            GraalMetrics.get(getName().concat(".deletedNodes")).increment(deletedNodeCount);
+            GraalMetrics.get(getName().concat(".createdNodes")).increment(createdNodeCount);
+        }
 
         // (Item|Graph|Phase|Value)
     }
--- a/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java	Wed Jun 08 17:07:06 2011 +0200
+++ b/graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/VMExitsNative.java	Wed Jun 08 17:26:22 2011 +0200
@@ -74,7 +74,7 @@
     public void shutdownCompiler() {
         compileMethods = false;
 
-        if (GraalOptions.PrintMetrics) {
+        if (GraalOptions.Meter) {
             GraalMetrics.print();
         }
         if (GraalOptions.Time) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/runfop.sh	Wed Jun 08 17:26:22 2011 +0200
@@ -0,0 +1,18 @@
+#!/bin/bash
+if [ -z "${JDK7}" ]; then
+  echo "JDK7 is not defined."
+  exit 1;
+fi
+if [ -z "${MAXINE}" ]; then
+  echo "MAXINE is not defined. It must point to a maxine repository directory."
+  exit 1;
+fi
+if [ -z "${GRAAL}" ]; then
+  echo "GRAAL is not defined. It must point to a maxine repository directory."
+  exit 1;
+fi
+if [ -z "${DACAPO}" ]; then
+  echo "DACAPO is not defined. It must point to a Dacapo benchmark directory."
+  exit 1;
+fi
+${JDK7}/bin/java -client -d64 -graal -XX:-GraalBailoutIsFatal -XX:+PrintCompilation -Xms1g -Xmx2g -esa -classpath ${DACAPO}/dacapo-9.12-bach.jar $* Harness --preserve fop