Mercurial > hg > truffle
comparison visualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java @ 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 | eca97d497f5d |
children |
comparison
equal
deleted
inserted
replaced
5798:2585af1e26ac | 5800:be428fe2d86c |
---|---|
24 package com.sun.hotspot.igv.data; | 24 package com.sun.hotspot.igv.data; |
25 | 25 |
26 import java.util.ArrayList; | 26 import java.util.ArrayList; |
27 import java.util.Collections; | 27 import java.util.Collections; |
28 import java.util.List; | 28 import java.util.List; |
29 import java.util.regex.Matcher; | |
30 import java.util.regex.Pattern; | |
29 | 31 |
30 /** | 32 /** |
31 * | 33 * |
32 * @author Thomas Wuerthinger | 34 * @author Thomas Wuerthinger |
33 */ | 35 */ |
107 public String getShortName() { | 109 public String getShortName() { |
108 return shortName; | 110 return shortName; |
109 } | 111 } |
110 | 112 |
111 public void setBytecodes(String text) { | 113 public void setBytecodes(String text) { |
114 Pattern instruction = Pattern.compile("\\s*(\\d+)\\s*:?\\s*(\\w+)\\s*(.*)(?://(.*))?"); | |
115 String[] strings = text.split("\n"); | |
116 int oldBci = -1; | |
117 for (String s : strings) { | |
118 s = s.trim(); | |
119 if (s.length() != 0) { | |
120 final Matcher matcher = instruction.matcher(s); | |
121 if (matcher.matches()) { | |
122 String bciString = matcher.group(1); | |
123 String opcode = matcher.group(2); | |
124 String operands = matcher.group(3).trim(); | |
125 String comment = matcher.group(4); | |
126 if (comment != null) { | |
127 comment = comment.trim(); | |
128 } | |
112 | 129 |
113 String[] strings = text.split("\n"); | 130 int bci = Integer.parseInt(bciString); |
114 int oldNumber = -1; | |
115 for (String s : strings) { | |
116 | 131 |
117 if (s.length() > 0 && Character.isDigit(s.charAt(0))) { | 132 // assert correct order of bytecodes |
118 s = s.trim(); | 133 assert bci > oldBci; |
119 int spaceIndex = s.indexOf(' '); | |
120 String numberString = s.substring(0, spaceIndex); | |
121 String tmpName = s.substring(spaceIndex + 1, s.length()); | |
122 | 134 |
123 int number = -1; | 135 InputBytecode bc = new InputBytecode(bci, opcode, operands, comment); |
124 try { | 136 bytecodes.add(bc); |
125 number = Integer.parseInt(numberString); | |
126 } catch (NumberFormatException e) { | |
127 // nothing to do... | |
128 } | |
129 | 137 |
130 // assert correct order of bytecodes | 138 for (InputMethod m : inlined) { |
131 assert number > oldNumber; | 139 if (m.getBci() == bci) { |
132 | 140 bc.setInlined(m); |
133 InputBytecode bc = new InputBytecode(number, tmpName); | 141 break; |
134 bytecodes.add(bc); | 142 } |
135 | |
136 for (InputMethod m : inlined) { | |
137 if (m.getBci() == number) { | |
138 bc.setInlined(m); | |
139 break; | |
140 } | 143 } |
144 } else { | |
145 System.out.println("no match: " + s); | |
141 } | 146 } |
142 } | 147 } |
143 } | 148 } |
144 } | 149 } |
145 | 150 |