29 import sun.jvm.hotspot.asm.*; |
29 import sun.jvm.hotspot.asm.*; |
30 import sun.jvm.hotspot.code.*; |
30 import sun.jvm.hotspot.code.*; |
31 import sun.jvm.hotspot.compiler.*; |
31 import sun.jvm.hotspot.compiler.*; |
32 import sun.jvm.hotspot.debugger.*; |
32 import sun.jvm.hotspot.debugger.*; |
33 import sun.jvm.hotspot.interpreter.*; |
33 import sun.jvm.hotspot.interpreter.*; |
34 import sun.jvm.hotspot.memory.*; |
|
35 import sun.jvm.hotspot.oops.*; |
34 import sun.jvm.hotspot.oops.*; |
36 import sun.jvm.hotspot.runtime.*; |
35 import sun.jvm.hotspot.runtime.*; |
37 import sun.jvm.hotspot.tools.jcore.*; |
36 import sun.jvm.hotspot.tools.jcore.*; |
38 import sun.jvm.hotspot.types.*; |
|
39 import sun.jvm.hotspot.utilities.*; |
37 import sun.jvm.hotspot.utilities.*; |
40 |
38 |
41 public class HTMLGenerator implements /* imports */ ClassConstants { |
39 public class HTMLGenerator implements /* imports */ ClassConstants { |
42 static class Formatter { |
40 static class Formatter { |
43 boolean html; |
41 boolean html; |
885 class HTMLDisassembler implements InstructionVisitor { |
883 class HTMLDisassembler implements InstructionVisitor { |
886 private int instrSize = 0; |
884 private int instrSize = 0; |
887 private Formatter buf; |
885 private Formatter buf; |
888 private SymbolFinder symFinder = createSymbolFinder(); |
886 private SymbolFinder symFinder = createSymbolFinder(); |
889 private long pc; |
887 private long pc; |
890 private OopMapSet oms; |
888 private ImmutableOopMapSet oms; |
891 private CodeBlob blob; |
889 private CodeBlob blob; |
892 private NMethod nmethod; |
890 private NMethod nmethod; |
893 |
891 |
894 HTMLDisassembler(Formatter buf, CodeBlob blob) { |
892 HTMLDisassembler(Formatter buf, CodeBlob blob) { |
895 this.buf = buf; |
893 this.buf = buf; |
952 } |
950 } |
953 } |
951 } |
954 |
952 |
955 if (oms != null) { |
953 if (oms != null) { |
956 long base = addressToLong(blob.codeBegin()); |
954 long base = addressToLong(blob.codeBegin()); |
957 for (int i = 0, imax = (int)oms.getSize(); i < imax; i++) { |
955 for (int i = 0, imax = oms.getCount(); i < imax; i++) { |
958 OopMap om = oms.getMapAt(i); |
956 ImmutableOopMapPair pair = oms.getPairAt(i); |
959 long omspc = base + om.getOffset(); |
957 long omspc = base + pair.getPC(); |
960 if (omspc > pc) { |
958 if (omspc > pc) { |
961 if (omspc <= endPc) { |
959 if (omspc <= endPc) { |
962 buf.br(); |
960 buf.br(); |
963 buf.append(genOopMapInfo(om)); |
961 buf.append(genOopMapInfo(oms.getMap(pair))); |
964 // st.move_to(column); |
962 // st.move_to(column); |
965 // visitor.print("; "); |
963 // visitor.print("; "); |
966 // om.print_on(st); |
964 // om.print_on(st); |
967 } |
965 } |
968 break; |
966 break; |
1165 } |
1163 } |
1166 buf.br(); |
1164 buf.br(); |
1167 } |
1165 } |
1168 } |
1166 } |
1169 |
1167 |
1170 protected String genHTMLForOopMap(OopMap map) { |
1168 protected String genHTMLForOopMap(ImmutableOopMap map) { |
1171 final int stack0 = VMRegImpl.getStack0().getValue(); |
1169 final int stack0 = VMRegImpl.getStack0().getValue(); |
1172 Formatter buf = new Formatter(genHTML); |
1170 Formatter buf = new Formatter(genHTML); |
1173 |
1171 |
1174 final class OopMapValueIterator { |
1172 final class OopMapValueIterator { |
1175 final Formatter iterate(OopMapStream oms, String type, boolean printContentReg) { |
1173 final Formatter iterate(OopMapStream oms, String type, boolean printContentReg) { |
1235 return buf.toString(); |
1233 return buf.toString(); |
1236 } |
1234 } |
1237 |
1235 |
1238 |
1236 |
1239 protected String genOopMapInfo(NMethod nmethod, PCDesc pcDesc) { |
1237 protected String genOopMapInfo(NMethod nmethod, PCDesc pcDesc) { |
1240 OopMapSet mapSet = nmethod.getOopMaps(); |
1238 ImmutableOopMapSet mapSet = nmethod.getOopMaps(); |
1241 if (mapSet == null || (mapSet.getSize() <= 0)) |
1239 if (mapSet == null || (mapSet.getSize() <= 0)) |
1242 return ""; |
1240 return ""; |
1243 int pcOffset = pcDesc.getPCOffset(); |
1241 int pcOffset = pcDesc.getPCOffset(); |
1244 OopMap map = mapSet.findMapAtOffset(pcOffset, VM.getVM().isDebugging()); |
1242 ImmutableOopMap map = mapSet.findMapAtOffset(pcOffset, VM.getVM().isDebugging()); |
1245 if (map == null) { |
1243 if (map == null) { |
1246 throw new IllegalArgumentException("no oopmap at safepoint!"); |
1244 throw new IllegalArgumentException("no oopmap at safepoint!"); |
1247 } |
1245 } |
1248 |
1246 |
1249 return genOopMapInfo(map); |
1247 return genOopMapInfo(map); |
1250 } |
1248 } |
1251 |
1249 |
1252 protected String genOopMapInfo(OopMap map) { |
1250 protected String genOopMapInfo(ImmutableOopMap map) { |
1253 Formatter buf = new Formatter(genHTML); |
1251 Formatter buf = new Formatter(genHTML); |
1254 buf.beginTag("pre"); |
1252 buf.beginTag("pre"); |
1255 buf.append("OopMap: "); |
1253 buf.append("OopMap: "); |
1256 buf.br(); |
1254 buf.br(); |
1257 buf.append(genHTMLForOopMap(map)); |
1255 buf.append(genHTMLForOopMap(map)); |