# HG changeset patch # User Doug Simon # Date 1341905794 -7200 # Node ID be428fe2d86ce0b1ef3f10521fbad83dfaeb193c # Parent 2585af1e26ac6f360176f8b2954c29c7f9b13b92 handles changes in IGV bytecode format diff -r 2585af1e26ac -r be428fe2d86c visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java --- 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 diff -r 2585af1e26ac -r be428fe2d86c visualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java --- 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) { diff -r 2585af1e26ac -r be428fe2d86c visualizer/Data/src/com/sun/hotspot/igv/data/InputBytecode.java --- 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; + } } diff -r 2585af1e26ac -r be428fe2d86c visualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java --- 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); } } }