changeset 5800:be428fe2d86c

handles changes in IGV bytecode format
author Doug Simon <doug.simon@oracle.com>
date Tue, 10 Jul 2012 09:36:34 +0200
parents 2585af1e26ac
children a24d30822e4f
files visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java visualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java visualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java
diffstat 4 files changed, 51 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java	Mon Jul 09 22:18:49 2012 +0200
+++ b/visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java	Tue Jul 10 09:36:34 2012 +0200
@@ -49,7 +49,7 @@
     public BytecodeNode(InputBytecode bytecode, InputGraph graph, String bciValue) {
 
         super(Children.LEAF);
-        this.setDisplayName(bytecode.getBci() + " " + bytecode.getName());
+        String displayName = bytecode.getBci() + " " + bytecode.getName() + " " + bytecode.getOperands();
 
         bciValue = bytecode.getBci() + " " + bciValue;
         bciValue = bciValue.trim();
@@ -62,8 +62,14 @@
             for (InputNode n : nodeList) {
                 nodes.add(n);
             }
-            this.setDisplayName(this.getDisplayName() + " (" + nodes.size() + " nodes)");
+            displayName += " (" + nodes.size() + " nodes)";
         }
+        
+        if (bytecode.getComment() != null) {
+            displayName += " // " + bytecode.getComment();
+        }
+        
+        this.setDisplayName(displayName);
     }
 
     @Override
--- a/visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java	Mon Jul 09 22:18:49 2012 +0200
+++ b/visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java	Tue Jul 10 09:36:34 2012 +0200
@@ -91,7 +91,7 @@
     /**
      * Gets default instance. Do not use directly: reserved for *.settings files only,
      * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
-     * To obtain the singleton instance, use {@link findInstance}.
+     * To obtain the singleton instance, use {@link #findInstance}.
      */
     public static synchronized BytecodeViewTopComponent getDefault() {
         if (instance == null) {
--- a/visualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java	Mon Jul 09 22:18:49 2012 +0200
+++ b/visualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java	Tue Jul 10 09:36:34 2012 +0200
@@ -31,11 +31,15 @@
 
     private int bci;
     private String name;
+    private String operands;
+    private String comment;
     private InputMethod inlined;
 
-    public InputBytecode(int bci, String name) {
+    public InputBytecode(int bci, String name, String operands, String comment) {
         this.bci = bci;
         this.name = name;
+        this.operands = operands;
+        this.comment = comment;
     }
 
     public InputMethod getInlined() {
@@ -53,4 +57,12 @@
     public String getName() {
         return name;
     }
+
+    public String getOperands() {
+        return operands;
+    }
+
+    public String getComment() {
+        return comment;
+    }
 }
--- a/visualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java	Mon Jul 09 22:18:49 2012 +0200
+++ b/visualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java	Tue Jul 10 09:36:34 2012 +0200
@@ -26,6 +26,8 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  *
@@ -109,35 +111,38 @@
     }
 
     public void setBytecodes(String text) {
-
+        Pattern instruction = Pattern.compile("\\s*(\\d+)\\s*:?\\s*(\\w+)\\s*(.*)(?://(.*))?");
         String[] strings = text.split("\n");
-        int oldNumber = -1;
+        int oldBci = -1;
         for (String s : strings) {
-
-            if (s.length() > 0 && Character.isDigit(s.charAt(0))) {
-                s = s.trim();
-                int spaceIndex = s.indexOf(' ');
-                String numberString = s.substring(0, spaceIndex);
-                String tmpName = s.substring(spaceIndex + 1, s.length());
+            s = s.trim();
+            if (s.length() != 0) {
+                final Matcher matcher = instruction.matcher(s);
+                if (matcher.matches()) {
+                    String bciString = matcher.group(1);
+                    String opcode = matcher.group(2);
+                    String operands = matcher.group(3).trim();
+                    String comment = matcher.group(4);
+                    if (comment != null) {
+                        comment = comment.trim();
+                    }
 
-                int number = -1;
-                try {
-                    number = Integer.parseInt(numberString);
-                } catch (NumberFormatException e) {
-                    // nothing to do...
-                }
+                    int bci = Integer.parseInt(bciString);
+
+                    // assert correct order of bytecodes
+                    assert bci > oldBci;
+
+                    InputBytecode bc = new InputBytecode(bci, opcode, operands, comment);
+                    bytecodes.add(bc);
 
-                // assert correct order of bytecodes
-                assert number > oldNumber;
-
-                InputBytecode bc = new InputBytecode(number, tmpName);
-                bytecodes.add(bc);
-
-                for (InputMethod m : inlined) {
-                    if (m.getBci() == number) {
-                        bc.setInlined(m);
-                        break;
+                    for (InputMethod m : inlined) {
+                        if (m.getBci() == bci) {
+                            bc.setInlined(m);
+                            break;
+                        }
                     }
+                } else {
+                    System.out.println("no match: " + s);
                 }
             }
         }