changeset 10727:9d079661cbcd

fixed generation of sequential id prefixes for IGV graphs
author Doug Simon <doug.simon@oracle.com>
date Fri, 12 Jul 2013 18:08:58 +0200
parents c78097171701
children 70cb17338a70
files graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java
diffstat 1 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Fri Jul 12 14:48:30 2013 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Fri Jul 12 18:08:58 2013 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.printer;
 
+import static com.oracle.graal.compiler.GraalDebugConfig.*;
 import static com.oracle.graal.phases.GraalOptions.*;
 
 import java.io.*;
@@ -32,7 +33,6 @@
 import java.util.*;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.phases.schedule.*;
@@ -151,8 +151,8 @@
                 // Check for method scopes that must be closed since the previous dump.
                 for (int i = 0; i < previousInlineContext.size(); ++i) {
                     if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
-                        for (int j = previousInlineContext.size() - 1; j >= i; --j) {
-                            closeScope();
+                        for (int inlineDepth = previousInlineContext.size() - 1; inlineDepth >= i; --inlineDepth) {
+                            closeScope(inlineDepth);
                         }
                         break;
                     }
@@ -161,8 +161,8 @@
                 // Check for method scopes that must be opened since the previous dump.
                 for (int i = 0; i < inlineContext.size(); ++i) {
                     if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
-                        for (int j = i; j < inlineContext.size(); ++j) {
-                            openScope(inlineContext.get(j), j == 0);
+                        for (int inlineDepth = i; inlineDepth < inlineContext.size(); ++inlineDepth) {
+                            openScope(inlineContext.get(inlineDepth), inlineDepth);
                         }
                         break;
                     }
@@ -191,11 +191,11 @@
 
     private static List<String> getInlineContext() {
         List<String> result = new ArrayList<>();
-        Object last = null;
+        Object lastMethodOrGraph = null;
         for (Object o : Debug.context()) {
-            JavaMethod method = GraalDebugConfig.asJavaMethod(o);
+            JavaMethod method = asJavaMethod(o);
             if (method != null) {
-                if (last != method) {
+                if (lastMethodOrGraph == null || asJavaMethod(lastMethodOrGraph) != method) {
                     result.add(MetaUtil.format("%H::%n(%p)", method));
                 } else {
                     // This prevents multiple adjacent method context objects for the same method
@@ -211,7 +211,9 @@
                     result.add(debugDumpScope.name);
                 }
             }
-            last = o;
+            if (o instanceof JavaMethod || o instanceof Graph) {
+                lastMethodOrGraph = o;
+            }
         }
         if (result.isEmpty()) {
             result.add("Top Scope");
@@ -229,8 +231,8 @@
         return result;
     }
 
-    private void openScope(String name, boolean showThread) {
-        String prefix = showThread ? Thread.currentThread().getName() + ":" : "";
+    private void openScope(String name, int inlineDepth) {
+        String prefix = inlineDepth == 0 ? Thread.currentThread().getName() + ":" : "";
         try {
             printer.beginGroup(prefix + name, name, Debug.contextLookup(ResolvedJavaMethod.class), -1);
         } catch (IOException e) {
@@ -239,7 +241,8 @@
         }
     }
 
-    private void closeScope() {
+    private void closeScope(int inlineDepth) {
+        dumpIds[inlineDepth] = 0;
         try {
             printer.endGroup();
         } catch (IOException e) {
@@ -250,8 +253,8 @@
 
     @Override
     public void close() {
-        for (int i = 0; i < previousInlineContext.size(); i++) {
-            closeScope();
+        for (int inlineDepth = 0; inlineDepth < previousInlineContext.size(); inlineDepth++) {
+            closeScope(inlineDepth);
         }
         if (printer != null) {
             printer.close();