changeset 4374:244626f45577

Automatically identify inline scoping in igv dump handler.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 27 Jan 2012 20:53:54 +0100
parents e5cc2440f034
children 0e7133d1991d
files graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterDumpHandler.java
diffstat 1 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterDumpHandler.java	Fri Jan 27 20:36:54 2012 +0100
+++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinterDumpHandler.java	Fri Jan 27 20:53:54 2012 +0100
@@ -45,6 +45,7 @@
     public IdealGraphPrinter printer;
     private OutputStream stream;
     private Socket socket;
+    private List<RiResolvedMethod> previousInlineContext = new ArrayList<RiResolvedMethod>();
 
     /**
      * Creates a new {@link IdealGraphPrinterDumpHandler} that writes output to a file named after the compiled method.
@@ -181,15 +182,47 @@
         openPrinter(groupTitle, null);
     }
 
+
     @Override
     public void dump(Object object, String message) {
         if (object instanceof Graph) {
             Graph graph = (Graph) object;
+
+            // Get all current RiResolvedMethod instances in the context.
             List<RiResolvedMethod> inlineContext = Debug.contextSnapshot(RiResolvedMethod.class);
-            System.out.println("dumping graph");
-            for (RiResolvedMethod m : inlineContext) {
-                System.out.println("m="+m);
+
+            // Reverse list such that inner method comes after outer method.
+            Collections.reverse(inlineContext);
+
+            // 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) != previousInlineContext.get(i)) {
+                    for (int j = previousInlineContext.size() - 1; j >= i; --j) {
+                        closeMethodScope(previousInlineContext.get(j));
+                    }
+                }
             }
+
+            // 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) != previousInlineContext.get(i)) {
+                    for (int j = i; j < inlineContext.size(); ++j) {
+                        openMethodScope(inlineContext.get(j));
+                    }
+                }
+            }
+
+            previousInlineContext = inlineContext;
         }
     }
+
+    private void openMethodScope(RiResolvedMethod method) {
+        System.out.println("OPEN " + method);
+
+    }
+
+    private void closeMethodScope(RiResolvedMethod method) {
+        System.out.println("CLOSE " + method);
+
+    }
 }