changeset 10728:70cb17338a70

Merge.
author Doug Simon <doug.simon@oracle.com>
date Fri, 12 Jul 2013 18:09:39 +0200
parents 9d079661cbcd (diff) e35a72e32aae (current diff)
children 2a4ad6ab345e dfc4b73e79e8
files
diffstat 6 files changed, 36 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Thu Jul 11 15:13:50 2013 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Fri Jul 12 18:09:39 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();
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java	Thu Jul 11 15:13:50 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java	Fri Jul 12 18:09:39 2013 +0200
@@ -118,8 +118,8 @@
             }
         };
         
-        server = new Server(callback, false);
-        binaryServer = new Server(callback, true);
+        server = new Server(getDocument(), callback, false);
+        binaryServer = new Server(getDocument(), callback, true);
     }
 
     public void clear() {
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java	Thu Jul 11 15:13:50 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java	Fri Jul 12 18:09:39 2013 +0200
@@ -110,14 +110,14 @@
                     }
                 };
                 final GraphParser parser;
+                final OutlineTopComponent component = OutlineTopComponent.findInstance();
                 if (file.getName().endsWith(".xml")) {
                     parser = new Parser(channel, monitor, null);
                 } else if (file.getName().endsWith(".bgv")) {
-                    parser = new BinaryParser(channel, monitor, null);
+                    parser = new BinaryParser(channel, monitor, component.getDocument(), null);
                 } else {
                     parser = null;
                 }
-                final OutlineTopComponent component = OutlineTopComponent.findInstance();
                 RequestProcessor.getDefault().post(new Runnable() {
                     @Override
                     public void run() {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Thu Jul 11 15:13:50 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Fri Jul 12 18:09:39 2013 +0200
@@ -69,6 +69,7 @@
     private final List<Object> constantPool;
     private final ByteBuffer buffer;
     private final ReadableByteChannel channel;
+    private final GraphDocument rootDocument;
     private final Deque<Folder> folderStack;
     private final ParseMonitor monitor;
     
@@ -240,12 +241,13 @@
         }
     }
 
-    public BinaryParser(ReadableByteChannel channel, ParseMonitor monitor, GroupCallback callback) {
+    public BinaryParser(ReadableByteChannel channel, ParseMonitor monitor, GraphDocument rootDocument, GroupCallback callback) {
         this.callback = callback;
         constantPool = new ArrayList<>();
         buffer = ByteBuffer.allocateDirect(256 * 1024);
         buffer.flip();
         this.channel = channel;
+        this.rootDocument = rootDocument;
         folderStack = new LinkedList<>();
         this.monitor = monitor;
     }
@@ -527,8 +529,7 @@
 
     @Override
     public GraphDocument parse() throws IOException {
-        GraphDocument doc = new GraphDocument();
-        folderStack.push(doc);
+        folderStack.push(rootDocument);
         if (monitor != null) {
             monitor.setState("Starting parsing");
         }
@@ -542,7 +543,7 @@
         if (monitor != null) {
             monitor.setState("Finished parsing");
         }
-        return doc;
+        return rootDocument;
     }
 
     private void parseRoot() throws IOException {
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java	Thu Jul 11 15:13:50 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java	Fri Jul 12 18:09:39 2013 +0200
@@ -24,6 +24,7 @@
  */
 package com.sun.hotspot.igv.connection;
 
+import com.sun.hotspot.igv.data.GraphDocument;
 import com.sun.hotspot.igv.data.serialization.BinaryParser;
 import com.sun.hotspot.igv.data.serialization.Parser;
 import com.sun.hotspot.igv.data.services.GroupCallback;
@@ -34,12 +35,14 @@
 public class Client implements Runnable {
     private final boolean binary;
     private final SocketChannel socket;
+    private final GraphDocument rootDocument;
     private final GroupCallback callback;
 
-    public Client(SocketChannel socket, GroupCallback callback, boolean  binary) {
+    public Client(SocketChannel socket, GraphDocument rootDocument, GroupCallback callback, boolean  binary) {
         this.callback = callback;
         this.socket = socket;
         this.binary = binary;
+        this.rootDocument = rootDocument;
     }
 
     @Override
@@ -49,7 +52,7 @@
             final SocketChannel channel = socket;
             channel.configureBlocking(true);
             if (binary) {
-                new BinaryParser(channel, null, callback).parse();
+                new BinaryParser(channel, null, rootDocument, callback).parse();
             } else {
                 new Parser(channel, null, callback).parse();
             }
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java	Thu Jul 11 15:13:50 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java	Fri Jul 12 18:09:39 2013 +0200
@@ -24,6 +24,7 @@
  */
 package com.sun.hotspot.igv.connection;
 
+import com.sun.hotspot.igv.data.GraphDocument;
 import com.sun.hotspot.igv.data.services.GroupCallback;
 import com.sun.hotspot.igv.settings.Settings;
 import java.io.IOException;
@@ -43,12 +44,14 @@
 public class Server implements PreferenceChangeListener {
     private final boolean binary;
     private ServerSocketChannel serverSocket;
+    private final GraphDocument rootDocument;
     private final GroupCallback callback;
     private int port;
     private Runnable serverRunnable;
 
-    public Server(GroupCallback callback, boolean binary) {
+    public Server(GraphDocument rootDocument, GroupCallback callback, boolean binary) {
         this.binary = binary;
+        this.rootDocument = rootDocument;
         this.callback = callback;
         initializeNetwork();
         Settings.get().addPreferenceChangeListener(this);
@@ -87,7 +90,7 @@
                             clientSocket.close();
                             return;
                         }
-                        RequestProcessor.getDefault().post(new Client(clientSocket, callback, binary), 0, Thread.MAX_PRIORITY);
+                        RequestProcessor.getDefault().post(new Client(clientSocket, rootDocument, callback, binary), 0, Thread.MAX_PRIORITY);
                     } catch (IOException ex) {
                         serverSocket = null;
                         NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming binary data is disabled.", NotifyDescriptor.ERROR_MESSAGE);