comparison agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents a9fed06c01d2
children 5a98bf7d847b
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
311 buf.append("] "); 311 buf.append("] ");
312 } else { 312 } else {
313 buf.append(' '); 313 buf.append(' ');
314 } 314 }
315 buf.append('@'); 315 buf.append('@');
316 buf.append(klass.getHandle().toString()); 316 buf.append(klass.getAddress().toString());
317 return buf.toString(); 317 return buf.toString();
318 } 318 }
319 319
320 protected String genBaseHref() { 320 protected String genBaseHref() {
321 return ""; 321 return "";
322 } 322 }
323 323
324 protected String genKlassHref(InstanceKlass klass) { 324 protected String genKlassHref(InstanceKlass klass) {
325 return genBaseHref() + "klass=" + klass.getHandle(); 325 return genBaseHref() + "klass=" + klass.getAddress();
326 } 326 }
327 327
328 protected String genKlassLink(InstanceKlass klass) { 328 protected String genKlassLink(InstanceKlass klass) {
329 Formatter buf = new Formatter(genHTML); 329 Formatter buf = new Formatter(genHTML);
330 buf.link(genKlassHref(klass), genKlassTitle(klass)); 330 buf.link(genKlassHref(klass), genKlassTitle(klass));
401 protected String genMethodTitle(Method method) { 401 protected String genMethodTitle(Method method) {
402 Formatter buf = new Formatter(genHTML); 402 Formatter buf = new Formatter(genHTML);
403 buf.append(genMethodNameAndSignature(method)); 403 buf.append(genMethodNameAndSignature(method));
404 buf.append(' '); 404 buf.append(' ');
405 buf.append('@'); 405 buf.append('@');
406 buf.append(method.getHandle().toString()); 406 buf.append(method.getAddress().toString());
407 return buf.toString(); 407 return buf.toString();
408 } 408 }
409 409
410 protected String genMethodHref(Method m) { 410 protected String genMethodHref(Method m) {
411 return genBaseHref() + "method=" + m.getHandle(); 411 return genBaseHref() + "method=" + m.getAddress();
412 } 412 }
413 413
414 protected String genMethodLink(Method m) { 414 protected String genMethodLink(Method m) {
415 Formatter buf = new Formatter(genHTML); 415 Formatter buf = new Formatter(genHTML);
416 buf.link(genMethodHref(m), genMethodTitle(m)); 416 buf.link(genMethodHref(m), genMethodTitle(m));
496 // zero'th pool entry is always invalid. ignore it. 496 // zero'th pool entry is always invalid. ignore it.
497 for (int index = 1; index < length; index++) { 497 for (int index = 1; index < length; index++) {
498 buf.beginTag("tr"); 498 buf.beginTag("tr");
499 buf.cell(Integer.toString(index)); 499 buf.cell(Integer.toString(index));
500 500
501 int ctag = (int) cpool.getTags().getByteAt((int) index); 501 int ctag = (int) cpool.getTags().at((int) index);
502 switch (ctag) { 502 switch (ctag) {
503 case JVM_CONSTANT_Integer: 503 case JVM_CONSTANT_Integer:
504 buf.cell("JVM_CONSTANT_Integer"); 504 buf.cell("JVM_CONSTANT_Integer");
505 buf.cell(Integer.toString(cpool.getIntAt(index))); 505 buf.cell(Integer.toString(cpool.getIntAt(index)));
506 break; 506 break;
524 index++; 524 index++;
525 break; 525 break;
526 526
527 case JVM_CONSTANT_UnresolvedClass: 527 case JVM_CONSTANT_UnresolvedClass:
528 buf.cell("JVM_CONSTANT_UnresolvedClass"); 528 buf.cell("JVM_CONSTANT_UnresolvedClass");
529 buf.cell(cpool.getSymbolAt(index).asString()); 529 buf.cell(cpool.getKlassNameAt(index).asString());
530 break; 530 break;
531 531
532 case JVM_CONSTANT_UnresolvedClassInError: 532 case JVM_CONSTANT_UnresolvedClassInError:
533 buf.cell("JVM_CONSTANT_UnresolvedClassInError"); 533 buf.cell("JVM_CONSTANT_UnresolvedClassInError");
534 buf.cell(cpool.getSymbolAt(index).asString()); 534 buf.cell(cpool.getSymbolAt(index).asString());
535 break; 535 break;
536 536
537 case JVM_CONSTANT_Class: 537 case JVM_CONSTANT_Class:
538 buf.cell("JVM_CONSTANT_Class"); 538 buf.cell("JVM_CONSTANT_Class");
539 Klass klass = (Klass) cpool.getObjAtRaw(index); 539 Klass klass = (Klass) cpool.getKlassAt(index);
540 if (klass instanceof InstanceKlass) { 540 if (klass instanceof InstanceKlass) {
541 buf.cell(genKlassLink((InstanceKlass) klass)); 541 buf.cell(genKlassLink((InstanceKlass) klass));
542 } else { 542 } else {
543 buf.cell(klass.getName().asString().replace('/', '.')); 543 buf.cell(klass.getName().asString().replace('/', '.'));
544 } 544 }
545 break; 545 break;
546 546
547 case JVM_CONSTANT_UnresolvedString:
548 buf.cell("JVM_CONSTANT_UnresolvedString");
549 buf.cell("\"" +
550 escapeHTMLSpecialChars(cpool.getSymbolAt(index).asString()) +
551 "\"");
552 break;
553
554 case JVM_CONSTANT_Utf8: 547 case JVM_CONSTANT_Utf8:
555 buf.cell("JVM_CONSTANT_Utf8"); 548 buf.cell("JVM_CONSTANT_Utf8");
556 buf.cell("\"" + 549 buf.cell("\"" +
557 escapeHTMLSpecialChars(cpool.getSymbolAt(index).asString()) + 550 escapeHTMLSpecialChars(cpool.getSymbolAt(index).asString()) +
558 "\""); 551 "\"");
559 break; 552 break;
560 553
561 case JVM_CONSTANT_String: 554 case JVM_CONSTANT_String:
562 buf.cell("JVM_CONSTANT_String"); 555 buf.cell("JVM_CONSTANT_String");
563 buf.cell("\"" + 556 buf.cell("\"" +
564 escapeHTMLSpecialChars(OopUtilities.stringOopToString(cpool.getObjAtRaw(index))) + "\""); 557 escapeHTMLSpecialChars(cpool.getUnresolvedStringAt(index).asString()) + "\"");
565 break; 558 break;
566 559
567 case JVM_CONSTANT_Fieldref: 560 case JVM_CONSTANT_Fieldref:
568 buf.cell("JVM_CONSTANT_Fieldref"); 561 buf.cell("JVM_CONSTANT_Fieldref");
569 buf.cell(genLowHighShort(cpool.getIntAt(index))); 562 buf.cell(genLowHighShort(cpool.getIntAt(index)));
635 return genHTMLErrorMessage(exp); 628 return genHTMLErrorMessage(exp);
636 } 629 }
637 } 630 }
638 631
639 protected String genConstantPoolHref(ConstantPool cpool) { 632 protected String genConstantPoolHref(ConstantPool cpool) {
640 return genBaseHref() + "cpool=" + cpool.getHandle(); 633 return genBaseHref() + "cpool=" + cpool.getAddress();
641 } 634 }
642 635
643 protected String genConstantPoolTitle(ConstantPool cpool) { 636 protected String genConstantPoolTitle(ConstantPool cpool) {
644 Formatter buf = new Formatter(genHTML); 637 Formatter buf = new Formatter(genHTML);
645 buf.append("Constant Pool of ["); 638 buf.append("Constant Pool of [");
646 buf.append(genKlassTitle((InstanceKlass) cpool.getPoolHolder())); 639 buf.append(genKlassTitle((InstanceKlass) cpool.getPoolHolder()));
647 buf.append("] @"); 640 buf.append("] @");
648 buf.append(cpool.getHandle().toString()); 641 buf.append(cpool.getAddress().toString());
649 return buf.toString(); 642 return buf.toString();
650 } 643 }
651 644
652 protected String genConstantPoolLink(ConstantPool cpool) { 645 protected String genConstantPoolLink(ConstantPool cpool) {
653 Formatter buf = new Formatter(genHTML); 646 Formatter buf = new Formatter(genHTML);
676 CheckedExceptionElement[] exceptions = method.getCheckedExceptions(); 669 CheckedExceptionElement[] exceptions = method.getCheckedExceptions();
677 buf.beginTag("ul"); 670 buf.beginTag("ul");
678 for (int exp = 0; exp < exceptions.length; exp++) { 671 for (int exp = 0; exp < exceptions.length; exp++) {
679 short cpIndex = (short) exceptions[exp].getClassCPIndex(); 672 short cpIndex = (short) exceptions[exp].getClassCPIndex();
680 ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex); 673 ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex);
681 if (obj.isMetaData()) { 674 if (obj.isUnresolved()) {
682 buf.li((obj.getSymbol()).asString().replace('/', '.')); 675 buf.li((obj.getSymbol()).asString().replace('/', '.'));
683 } else { 676 } else {
684 buf.li(genKlassLink((InstanceKlass)obj.getOop())); 677 buf.li(genKlassLink((InstanceKlass)obj.getKlass()));
685 } 678 }
686 } 679 }
687 buf.endTag("ul"); 680 buf.endTag("ul");
688 } 681 }
689 682
721 buf.beginTag("td"); 714 buf.beginTag("td");
722 String instrStr = null; 715 String instrStr = null;
723 try { 716 try {
724 instrStr = escapeHTMLSpecialChars(instr.toString()); 717 instrStr = escapeHTMLSpecialChars(instr.toString());
725 } catch (RuntimeException re) { 718 } catch (RuntimeException re) {
726 buf.append("exception during bytecode processing"); 719 buf.append("exception while printing " + instr.getBytecodeName());
727 buf.endTag("td"); 720 buf.endTag("td");
728 buf.endTag("tr"); 721 buf.endTag("tr");
729 re.printStackTrace(); 722 re.printStackTrace();
730 return; 723 return;
731 } 724 }
760 } 753 }
761 } else if (instr instanceof BytecodeLoadConstant) { 754 } else if (instr instanceof BytecodeLoadConstant) {
762 BytecodeLoadConstant ldc = (BytecodeLoadConstant) instr; 755 BytecodeLoadConstant ldc = (BytecodeLoadConstant) instr;
763 if (ldc.isKlassConstant()) { 756 if (ldc.isKlassConstant()) {
764 Object oop = ldc.getKlass(); 757 Object oop = ldc.getKlass();
765 if (oop instanceof Klass) { 758 if (oop instanceof InstanceKlass) {
766 buf.append("<a href='"); 759 buf.append("<a href='");
767 buf.append(genKlassHref((InstanceKlass) oop)); 760 buf.append(genKlassHref((InstanceKlass) oop));
768 buf.append("'>"); 761 buf.append("'>");
769 buf.append(instrStr); 762 buf.append(instrStr);
770 buf.append("</a>"); 763 buf.append("</a>");
810 buf.cell(Integer.toString(exceptionTable[e].getHandlerPC())); 803 buf.cell(Integer.toString(exceptionTable[e].getHandlerPC()));
811 short cpIndex = (short) exceptionTable[e].getCatchTypeIndex(); 804 short cpIndex = (short) exceptionTable[e].getCatchTypeIndex();
812 ConstantPool.CPSlot obj = cpIndex == 0? null : cpool.getSlotAt(cpIndex); 805 ConstantPool.CPSlot obj = cpIndex == 0? null : cpool.getSlotAt(cpIndex);
813 if (obj == null) { 806 if (obj == null) {
814 buf.cell("Any"); 807 buf.cell("Any");
815 } else if (obj.isMetaData()) { 808 } else if (obj.isUnresolved()) {
816 buf.cell(obj.getSymbol().asString().replace('/', '.')); 809 buf.cell(obj.getSymbol().asString().replace('/', '.'));
817 } else { 810 } else {
818 buf.cell(genKlassLink((InstanceKlass)obj.getOop())); 811 buf.cell(genKlassLink((InstanceKlass)obj.getKlass()));
819 } 812 }
820 buf.endTag("tr"); 813 buf.endTag("tr");
821 } 814 }
822 815
823 buf.endTable(); 816 buf.endTable();
841 protected SymbolFinder createSymbolFinder() { 834 protected SymbolFinder createSymbolFinder() {
842 return new DummySymbolFinder(); 835 return new DummySymbolFinder();
843 } 836 }
844 837
845 // genHTML for a given address. Address may be a PC or 838 // genHTML for a given address. Address may be a PC or
846 // methodOop or klassOop. 839 // Method* or Klass*.
847 840
848 public String genHTMLForAddress(String addrStr) { 841 public String genHTMLForAddress(String addrStr) {
849 return genHTML(parseAddress(addrStr)); 842 return genHTML(parseAddress(addrStr));
850 } 843 }
851 844
876 } else if (VM.getVM().getCodeCache().contains(pc)) { 869 } else if (VM.getVM().getCodeCache().contains(pc)) {
877 return "Unknown location in the CodeCache: " + pc; 870 return "Unknown location in the CodeCache: " + pc;
878 } 871 }
879 872
880 // did not find nmethod. 873 // did not find nmethod.
881 // try methodOop, klassOop and constantPoolOop. 874 // try Method*, Klass* and ConstantPool*.
882 try { 875 try {
883 Oop obj = getOopAtAddress(pc); 876 Metadata obj = Metadata.instantiateWrapperFor(pc);
884 if (obj != null) { 877 if (obj != null) {
885 if (obj instanceof Method) { 878 if (obj instanceof Method) {
886 return genHTML((Method) obj); 879 return genHTML((Method) obj);
887 } else if (obj instanceof InstanceKlass) { 880 } else if (obj instanceof InstanceKlass) {
888 return genHTML((InstanceKlass) obj); 881 return genHTML((InstanceKlass) obj);
889 } else if (obj instanceof ConstantPool) { 882 } else if (obj instanceof ConstantPool) {
890 return genHTML((ConstantPool) obj); 883 return genHTML((ConstantPool) obj);
891 } 884 }
892 } 885 }
893 } catch (Exception exp) { 886 } catch (Exception exp) {
887 exp.printStackTrace();
894 // ignore 888 // ignore
895 } 889 }
896 890
897 // didn't find any. do raw disassembly. 891 // didn't find any. do raw disassembly.
898 return genHTMLForRawDisassembly(pc, null); 892 return genHTMLForRawDisassembly(pc, null);
1118 OopHandle klHandle = klv.getValue(); 1112 OopHandle klHandle = klv.getValue();
1119 if (Assert.ASSERTS_ENABLED) { 1113 if (Assert.ASSERTS_ENABLED) {
1120 Assert.that(klHandle != null, "scalar replaced object klass must be not NULL"); 1114 Assert.that(klHandle != null, "scalar replaced object klass must be not NULL");
1121 } 1115 }
1122 Oop obj = VM.getVM().getObjectHeap().newOop(klHandle); 1116 Oop obj = VM.getVM().getObjectHeap().newOop(klHandle);
1123 if (obj instanceof InstanceKlass) { 1117 // Obj is a Java mirror
1124 InstanceKlass kls = (InstanceKlass) obj; 1118 Klass klass = java_lang_Class.asKlass(obj);
1119 if (klass instanceof InstanceKlass) {
1120 InstanceKlass kls = (InstanceKlass) klass;
1125 buf.append(" " + kls.getName().asString() + "={"); 1121 buf.append(" " + kls.getName().asString() + "={");
1126 int flen = ov.fieldsSize(); 1122 int flen = ov.fieldsSize();
1127 int klen = kls.getJavaFieldsCount(); 1123
1124 U2Array klfields = kls.getFields();
1125 int klen = (int) klfields.length();
1128 int findex = 0; 1126 int findex = 0;
1129 for (int index = 0; index < klen; index++) { 1127 for (int index = 0; index < klen; index++) {
1130 int accsFlags = kls.getFieldAccessFlags(index); 1128 int accsFlags = kls.getFieldAccessFlags(index);
1131 Symbol f_name = kls.getFieldName(index); 1129 Symbol f_name = kls.getFieldName(index);
1132 AccessFlags access = new AccessFlags(accsFlags); 1130 AccessFlags access = new AccessFlags(accsFlags);
1138 } 1136 }
1139 buf.append(" }"); 1137 buf.append(" }");
1140 } else { 1138 } else {
1141 buf.append(" "); 1139 buf.append(" ");
1142 int flen = ov.fieldsSize(); 1140 int flen = ov.fieldsSize();
1143 if (obj instanceof TypeArrayKlass) { 1141 if (klass instanceof TypeArrayKlass) {
1144 TypeArrayKlass kls = (TypeArrayKlass) obj; 1142 TypeArrayKlass kls = (TypeArrayKlass) klass;
1145 buf.append(kls.getElementTypeName() + "[" + flen + "]"); 1143 buf.append(kls.getElementTypeName() + "[" + flen + "]");
1146 } else if (obj instanceof ObjArrayKlass) { 1144 } else if (klass instanceof ObjArrayKlass) {
1147 ObjArrayKlass kls = (ObjArrayKlass) obj; 1145 ObjArrayKlass kls = (ObjArrayKlass) klass;
1148 Klass elobj = kls.getBottomKlass(); 1146 Klass elobj = kls.getBottomKlass();
1149 if (elobj instanceof InstanceKlass) { 1147 if (elobj instanceof InstanceKlass) {
1150 buf.append(elobj.getName().asString()); 1148 buf.append(elobj.getName().asString());
1151 } else if (elobj instanceof TypeArrayKlass) { 1149 } else if (elobj instanceof TypeArrayKlass) {
1152 TypeArrayKlass elkls = (TypeArrayKlass) elobj; 1150 TypeArrayKlass elkls = (TypeArrayKlass) elobj;
1685 1683
1686 protected String genDumpKlassesHref(InstanceKlass[] klasses) { 1684 protected String genDumpKlassesHref(InstanceKlass[] klasses) {
1687 StringBuffer buf = new StringBuffer(genBaseHref()); 1685 StringBuffer buf = new StringBuffer(genBaseHref());
1688 buf.append("jcore_multiple="); 1686 buf.append("jcore_multiple=");
1689 for (int k = 0; k < klasses.length; k++) { 1687 for (int k = 0; k < klasses.length; k++) {
1690 buf.append(klasses[k].getHandle().toString()); 1688 buf.append(klasses[k].getAddress().toString());
1691 buf.append(','); 1689 buf.append(',');
1692 } 1690 }
1693 return buf.toString(); 1691 return buf.toString();
1694 } 1692 }
1695 1693
1741 } 1739 }
1742 } 1740 }
1743 1741
1744 protected String genHTMLListForMethods(InstanceKlass klass) { 1742 protected String genHTMLListForMethods(InstanceKlass klass) {
1745 Formatter buf = new Formatter(genHTML); 1743 Formatter buf = new Formatter(genHTML);
1746 ObjArray methods = klass.getMethods(); 1744 MethodArray methods = klass.getMethods();
1747 int numMethods = (int) methods.getLength(); 1745 int numMethods = methods.length();
1748 if (numMethods != 0) { 1746 if (numMethods != 0) {
1749 buf.h3("Methods"); 1747 buf.h3("Methods");
1750 buf.beginTag("ul"); 1748 buf.beginTag("ul");
1751 for (int m = 0; m < numMethods; m++) { 1749 for (int m = 0; m < numMethods; m++) {
1752 Method mtd = (Method) methods.getObjAt(m); 1750 Method mtd = methods.at(m);
1753 buf.li(genMethodLink(mtd) + ";"); 1751 buf.li(genMethodLink(mtd) + ";");
1754 } 1752 }
1755 buf.endTag("ul"); 1753 buf.endTag("ul");
1756 } 1754 }
1757 return buf.toString(); 1755 return buf.toString();
1758 } 1756 }
1759 1757
1760 protected String genHTMLListForInterfaces(InstanceKlass klass) { 1758 protected String genHTMLListForInterfaces(InstanceKlass klass) {
1761 try { 1759 try {
1762 Formatter buf = new Formatter(genHTML); 1760 Formatter buf = new Formatter(genHTML);
1763 ObjArray interfaces = klass.getLocalInterfaces(); 1761 KlassArray interfaces = klass.getLocalInterfaces();
1764 int numInterfaces = (int) interfaces.getLength(); 1762 int numInterfaces = interfaces.length();
1765 if (numInterfaces != 0) { 1763 if (numInterfaces != 0) {
1766 buf.h3("Interfaces"); 1764 buf.h3("Interfaces");
1767 buf.beginTag("ul"); 1765 buf.beginTag("ul");
1768 for (int i = 0; i < numInterfaces; i++) { 1766 for (int i = 0; i < numInterfaces; i++) {
1769 InstanceKlass inf = (InstanceKlass) interfaces.getObjAt(i); 1767 InstanceKlass inf = (InstanceKlass) interfaces.getAt(i);
1770 buf.li(genKlassLink(inf)); 1768 buf.li(genKlassLink(inf));
1771 } 1769 }
1772 buf.endTag("ul"); 1770 buf.endTag("ul");
1773 } 1771 }
1774 return buf.toString(); 1772 return buf.toString();
1820 } 1818 }
1821 } 1819 }
1822 1820
1823 protected String genHTMLListForFields(InstanceKlass klass) { 1821 protected String genHTMLListForFields(InstanceKlass klass) {
1824 Formatter buf = new Formatter(genHTML); 1822 Formatter buf = new Formatter(genHTML);
1825 int numFields = klass.getJavaFieldsCount(); 1823 U2Array fields = klass.getFields();
1824 int numFields = klass.getAllFieldsCount();
1826 if (numFields != 0) { 1825 if (numFields != 0) {
1827 buf.h3("Fields"); 1826 buf.h3("Fields");
1828 buf.beginList(); 1827 buf.beginList();
1829 for (int f = 0; f < numFields; f++) { 1828 for (int f = 0; f < numFields; f++) {
1830 sun.jvm.hotspot.oops.Field field = klass.getFieldByIndex(f); 1829 sun.jvm.hotspot.oops.Field field = klass.getFieldByIndex(f);
1855 } 1854 }
1856 return buf.toString(); 1855 return buf.toString();
1857 } 1856 }
1858 1857
1859 protected String genKlassHierarchyHref(InstanceKlass klass) { 1858 protected String genKlassHierarchyHref(InstanceKlass klass) {
1860 return genBaseHref() + "hierarchy=" + klass.getHandle(); 1859 return genBaseHref() + "hierarchy=" + klass.getAddress();
1861 } 1860 }
1862 1861
1863 protected String genKlassHierarchyTitle(InstanceKlass klass) { 1862 protected String genKlassHierarchyTitle(InstanceKlass klass) {
1864 Formatter buf = new Formatter(genHTML); 1863 Formatter buf = new Formatter(genHTML);
1865 buf.append("Class Hierarchy of "); 1864 buf.append("Class Hierarchy of ");
1917 buf.genHTMLEpilogue(); 1916 buf.genHTMLEpilogue();
1918 return buf.toString(); 1917 return buf.toString();
1919 } 1918 }
1920 1919
1921 protected String genDumpKlassHref(InstanceKlass klass) { 1920 protected String genDumpKlassHref(InstanceKlass klass) {
1922 return genBaseHref() + "jcore=" + klass.getHandle(); 1921 return genBaseHref() + "jcore=" + klass.getAddress();
1923 } 1922 }
1924 1923
1925 protected String genDumpKlassLink(InstanceKlass klass) { 1924 protected String genDumpKlassLink(InstanceKlass klass) {
1926 if (!genHTML) return ""; 1925 if (!genHTML) return "";
1927 1926
1988 } 1987 }
1989 1988
1990 protected Oop getOopAtAddress(String address) { 1989 protected Oop getOopAtAddress(String address) {
1991 sun.jvm.hotspot.debugger.Address addr = parseAddress(address); 1990 sun.jvm.hotspot.debugger.Address addr = parseAddress(address);
1992 return getOopAtAddress(addr); 1991 return getOopAtAddress(addr);
1992 }
1993
1994 protected Klass getKlassAtAddress(String address) {
1995 sun.jvm.hotspot.debugger.Address addr = parseAddress(address);
1996 return (Klass)Metadata.instantiateWrapperFor(addr);
1997 }
1998
1999 protected Method getMethodAtAddress(String address) {
2000 sun.jvm.hotspot.debugger.Address addr = parseAddress(address);
2001 return (Method)Metadata.instantiateWrapperFor(addr);
2002 }
2003
2004 protected ConstantPool getConstantPoolAtAddress(String address) {
2005 sun.jvm.hotspot.debugger.Address addr = parseAddress(address);
2006 return (ConstantPool) Metadata.instantiateWrapperFor(addr);
1993 } 2007 }
1994 2008
1995 private void dumpKlass(InstanceKlass kls) throws IOException { 2009 private void dumpKlass(InstanceKlass kls) throws IOException {
1996 String klassName = kls.getName().asString(); 2010 String klassName = kls.getName().asString();
1997 klassName = klassName.replace('/', File.separatorChar); 2011 klassName = klassName.replace('/', File.separatorChar);
2080 } 2094 }
2081 2095
2082 public String genHTMLForHyperlink(String href) { 2096 public String genHTMLForHyperlink(String href) {
2083 if (href.startsWith("klass=")) { 2097 if (href.startsWith("klass=")) {
2084 href = href.substring(href.indexOf('=') + 1); 2098 href = href.substring(href.indexOf('=') + 1);
2085 Oop obj = getOopAtAddress(href); 2099 Klass k = getKlassAtAddress(href);
2086 if (Assert.ASSERTS_ENABLED) { 2100 if (Assert.ASSERTS_ENABLED) {
2087 Assert.that(obj instanceof InstanceKlass, "class= href with improper InstanceKlass!"); 2101 Assert.that(k instanceof InstanceKlass, "class= href with improper InstanceKlass!");
2088 } 2102 }
2089 return genHTML((InstanceKlass) obj); 2103 return genHTML((InstanceKlass) k);
2090 } else if (href.startsWith("method=")) { 2104 } else if (href.startsWith("method=")) {
2091 href = href.substring(href.indexOf('=') + 1); 2105 href = href.substring(href.indexOf('=') + 1);
2092 Oop obj = getOopAtAddress(href); 2106 Method obj = getMethodAtAddress(href);
2093 if (Assert.ASSERTS_ENABLED) { 2107 if (Assert.ASSERTS_ENABLED) {
2094 Assert.that(obj instanceof Method, "method= href with improper Method!"); 2108 Assert.that(obj instanceof Method, "method= href with improper Method!");
2095 } 2109 }
2096 return genHTML((Method) obj); 2110 return genHTML(obj);
2097 } else if (href.startsWith("nmethod=")) { 2111 } else if (href.startsWith("nmethod=")) {
2098 String addr = href.substring(href.indexOf('=') + 1); 2112 String addr = href.substring(href.indexOf('=') + 1);
2099 Object obj = VMObjectFactory.newObject(NMethod.class, parseAddress(addr)); 2113 Object obj = VMObjectFactory.newObject(NMethod.class, parseAddress(addr));
2100 if (Assert.ASSERTS_ENABLED) { 2114 if (Assert.ASSERTS_ENABLED) {
2101 Assert.that(obj instanceof NMethod, "nmethod= href with improper NMethod!"); 2115 Assert.that(obj instanceof NMethod, "nmethod= href with improper NMethod!");
2115 } 2129 }
2116 } else if (href.startsWith("interp_codelets")) { 2130 } else if (href.startsWith("interp_codelets")) {
2117 return genInterpreterCodeletLinksPage(); 2131 return genInterpreterCodeletLinksPage();
2118 } else if (href.startsWith("hierarchy=")) { 2132 } else if (href.startsWith("hierarchy=")) {
2119 href = href.substring(href.indexOf('=') + 1); 2133 href = href.substring(href.indexOf('=') + 1);
2120 Oop obj = getOopAtAddress(href); 2134 Klass obj = getKlassAtAddress(href);
2121 if (Assert.ASSERTS_ENABLED) { 2135 if (Assert.ASSERTS_ENABLED) {
2122 Assert.that(obj instanceof InstanceKlass, "class= href with improper InstanceKlass!"); 2136 Assert.that(obj instanceof InstanceKlass, "class= href with improper InstanceKlass!");
2123 } 2137 }
2124 return genHTMLForKlassHierarchy((InstanceKlass) obj); 2138 return genHTMLForKlassHierarchy((InstanceKlass) obj);
2125 } else if (href.startsWith("cpool=")) { 2139 } else if (href.startsWith("cpool=")) {
2126 href = href.substring(href.indexOf('=') + 1); 2140 href = href.substring(href.indexOf('=') + 1);
2127 Oop obj = getOopAtAddress(href); 2141 ConstantPool obj = getConstantPoolAtAddress(href);
2128 if (Assert.ASSERTS_ENABLED) { 2142 if (Assert.ASSERTS_ENABLED) {
2129 Assert.that(obj instanceof ConstantPool, "cpool= href with improper ConstantPool!"); 2143 Assert.that(obj instanceof ConstantPool, "cpool= href with improper ConstantPool!");
2130 } 2144 }
2131 return genHTML((ConstantPool) obj); 2145 return genHTML(obj);
2132 } else if (href.startsWith("jcore=")) { 2146 } else if (href.startsWith("jcore=")) {
2133 href = href.substring(href.indexOf('=') + 1); 2147 href = href.substring(href.indexOf('=') + 1);
2134 Oop obj = getOopAtAddress(href); 2148 Klass obj = getKlassAtAddress(href);
2135 if (Assert.ASSERTS_ENABLED) { 2149 if (Assert.ASSERTS_ENABLED) {
2136 Assert.that(obj instanceof InstanceKlass, "jcore= href with improper InstanceKlass!"); 2150 Assert.that(obj instanceof InstanceKlass, "jcore= href with improper InstanceKlass!");
2137 } 2151 }
2138 return genDumpKlass((InstanceKlass) obj); 2152 return genDumpKlass((InstanceKlass) obj);
2139 } else if (href.startsWith("jcore_multiple=")) { 2153 } else if (href.startsWith("jcore_multiple=")) {
2140 href = href.substring(href.indexOf('=') + 1); 2154 href = href.substring(href.indexOf('=') + 1);
2141 Formatter buf = new Formatter(genHTML); 2155 Formatter buf = new Formatter(genHTML);
2142 buf.genHTMLPrologue(); 2156 buf.genHTMLPrologue();
2143 StringTokenizer st = new StringTokenizer(href, ","); 2157 StringTokenizer st = new StringTokenizer(href, ",");
2144 while (st.hasMoreTokens()) { 2158 while (st.hasMoreTokens()) {
2145 Oop obj = getOopAtAddress(st.nextToken()); 2159 Klass obj = getKlassAtAddress(st.nextToken());
2146 if (Assert.ASSERTS_ENABLED) { 2160 if (Assert.ASSERTS_ENABLED) {
2147 Assert.that(obj instanceof InstanceKlass, "jcore_multiple= href with improper InstanceKlass!"); 2161 Assert.that(obj instanceof InstanceKlass, "jcore_multiple= href with improper InstanceKlass!");
2148 } 2162 }
2149 2163
2150 InstanceKlass kls = (InstanceKlass) obj; 2164 InstanceKlass kls = (InstanceKlass) obj;