Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java @ 1385:bc32f286fae0
6945219: minor SA fixes
Reviewed-by: twisti
author | never |
---|---|
date | Tue, 20 Apr 2010 13:26:33 -0700 |
parents | 873ec3787992 |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1384:c544d979f886 | 1385:bc32f286fae0 |
---|---|
1 /* | 1 /* |
2 * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2002-2010 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
93 void h3(String s) { nl(); wrap("h3", s); nl(); } | 93 void h3(String s) { nl(); wrap("h3", s); nl(); } |
94 void h4(String s) { nl(); wrap("h4", s); nl(); } | 94 void h4(String s) { nl(); wrap("h4", s); nl(); } |
95 | 95 |
96 // list tags | 96 // list tags |
97 void beginList() { beginTag("ul"); nl(); } | 97 void beginList() { beginTag("ul"); nl(); } |
98 void endList() { endTag("ul"); nl(); } | |
99 void beginListItem() { beginTag("li"); } | |
100 void endListItem() { endTag("li"); nl(); } | |
98 void li(String s) { wrap("li", s); nl(); } | 101 void li(String s) { wrap("li", s); nl(); } |
99 void endList() { endTag("ul"); nl(); } | |
100 | 102 |
101 // table tags | 103 // table tags |
102 void beginTable(int border) { | 104 void beginTable(int border) { |
103 beginTag("table border='" + border + "'"); | 105 beginTag("table border='" + border + "'"); |
104 } | 106 } |
503 case JVM_CONSTANT_UnresolvedClass: | 505 case JVM_CONSTANT_UnresolvedClass: |
504 buf.cell("JVM_CONSTANT_UnresolvedClass"); | 506 buf.cell("JVM_CONSTANT_UnresolvedClass"); |
505 buf.cell(cpool.getSymbolAt(index).asString()); | 507 buf.cell(cpool.getSymbolAt(index).asString()); |
506 break; | 508 break; |
507 | 509 |
510 case JVM_CONSTANT_UnresolvedClassInError: | |
511 buf.cell("JVM_CONSTANT_UnresolvedClassInError"); | |
512 buf.cell(cpool.getSymbolAt(index).asString()); | |
513 break; | |
514 | |
508 case JVM_CONSTANT_Class: | 515 case JVM_CONSTANT_Class: |
509 buf.cell("JVM_CONSTANT_Class"); | 516 buf.cell("JVM_CONSTANT_Class"); |
510 Klass klass = (Klass) cpool.getObjAt(index); | 517 Klass klass = (Klass) cpool.getObjAt(index); |
511 if (klass instanceof InstanceKlass) { | 518 if (klass instanceof InstanceKlass) { |
512 buf.cell(genKlassLink((InstanceKlass) klass)); | 519 buf.cell(genKlassLink((InstanceKlass) klass)); |
562 | 569 |
563 case JVM_CONSTANT_StringIndex: | 570 case JVM_CONSTANT_StringIndex: |
564 buf.cell("JVM_CONSTANT_StringIndex"); | 571 buf.cell("JVM_CONSTANT_StringIndex"); |
565 buf.cell(Integer.toString(cpool.getIntAt(index))); | 572 buf.cell(Integer.toString(cpool.getIntAt(index))); |
566 break; | 573 break; |
574 | |
575 default: | |
576 throw new InternalError("unknown tag: " + ctag); | |
567 } | 577 } |
568 | 578 |
569 buf.endTag("tr"); | 579 buf.endTag("tr"); |
570 } | 580 } |
571 | 581 |
669 buf.cell(Integer.toString(lineNumber) + spaces); | 679 buf.cell(Integer.toString(lineNumber) + spaces); |
670 } | 680 } |
671 buf.cell(Integer.toString(curBci) + spaces); | 681 buf.cell(Integer.toString(curBci) + spaces); |
672 | 682 |
673 buf.beginTag("td"); | 683 buf.beginTag("td"); |
674 String instrStr = escapeHTMLSpecialChars(instr.toString()); | 684 String instrStr = null; |
685 try { | |
686 instrStr = escapeHTMLSpecialChars(instr.toString()); | |
687 } catch (RuntimeException re) { | |
688 buf.append("exception during bytecode processing"); | |
689 buf.endTag("td"); | |
690 buf.endTag("tr"); | |
691 re.printStackTrace(); | |
692 return; | |
693 } | |
675 | 694 |
676 if (instr instanceof BytecodeNew) { | 695 if (instr instanceof BytecodeNew) { |
677 BytecodeNew newBytecode = (BytecodeNew) instr; | 696 BytecodeNew newBytecode = (BytecodeNew) instr; |
678 InstanceKlass klass = newBytecode.getNewKlass(); | 697 InstanceKlass klass = newBytecode.getNewKlass(); |
679 if (klass != null) { | 698 if (klass != null) { |
1394 final Map safepoints = nmethod.getSafepoints(); | 1413 final Map safepoints = nmethod.getSafepoints(); |
1395 | 1414 |
1396 final SymbolFinder symFinder = createSymbolFinder(); | 1415 final SymbolFinder symFinder = createSymbolFinder(); |
1397 final Disassembler disasm = createDisassembler(startPc, code); | 1416 final Disassembler disasm = createDisassembler(startPc, code); |
1398 class NMethodVisitor implements InstructionVisitor { | 1417 class NMethodVisitor implements InstructionVisitor { |
1399 boolean prevWasCall; | |
1400 public void prologue() { | 1418 public void prologue() { |
1401 prevWasCall = false; | |
1402 } | 1419 } |
1403 | 1420 |
1404 public void visit(long currentPc, Instruction instr) { | 1421 public void visit(long currentPc, Instruction instr) { |
1405 String href = null; | 1422 String href = null; |
1406 if (instr.isCall()) { | 1423 if (instr.isCall()) { |
1416 buf.bold(">Entry Point"); buf.br(); | 1433 buf.bold(">Entry Point"); buf.br(); |
1417 } | 1434 } |
1418 | 1435 |
1419 PCDesc pcDesc = (PCDesc) safepoints.get(longToAddress(currentPc)); | 1436 PCDesc pcDesc = (PCDesc) safepoints.get(longToAddress(currentPc)); |
1420 | 1437 |
1421 boolean isSafepoint = (pcDesc != null); | 1438 if (pcDesc != null) { |
1422 if (isSafepoint && prevWasCall) { | |
1423 buf.append(genSafepointInfo(nmethod, pcDesc)); | 1439 buf.append(genSafepointInfo(nmethod, pcDesc)); |
1424 } | 1440 } |
1425 | 1441 |
1426 buf.append("0x"); | 1442 buf.append("0x"); |
1427 buf.append(Long.toHexString(currentPc)); | 1443 buf.append(Long.toHexString(currentPc)); |
1433 } else { | 1449 } else { |
1434 buf.append(instr.asString(currentPc, symFinder)); | 1450 buf.append(instr.asString(currentPc, symFinder)); |
1435 } | 1451 } |
1436 | 1452 |
1437 buf.br(); | 1453 buf.br(); |
1438 if (isSafepoint && !prevWasCall) { | |
1439 buf.append(genSafepointInfo(nmethod, pcDesc)); | |
1440 } | |
1441 | |
1442 prevWasCall = instr.isCall(); | |
1443 } | 1454 } |
1444 | 1455 |
1445 public void epilogue() { | 1456 public void epilogue() { |
1446 } | 1457 } |
1447 }; | 1458 }; |
1781 ConstantPool cp = klass.getConstants(); | 1792 ConstantPool cp = klass.getConstants(); |
1782 if (numFields != 0) { | 1793 if (numFields != 0) { |
1783 buf.h3("Fields"); | 1794 buf.h3("Fields"); |
1784 buf.beginList(); | 1795 buf.beginList(); |
1785 for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) { | 1796 for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) { |
1786 int nameIndex = fields.getShortAt(f + InstanceKlass.NAME_INDEX_OFFSET); | 1797 sun.jvm.hotspot.oops.Field field = klass.getFieldByIndex(f); |
1787 int sigIndex = fields.getShortAt(f + InstanceKlass.SIGNATURE_INDEX_OFFSET); | 1798 String f_name = ((NamedFieldIdentifier)field.getID()).getName(); |
1788 int genSigIndex = fields.getShortAt(f + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET); | 1799 Symbol f_sig = field.getSignature(); |
1789 Symbol f_name = cp.getSymbolAt(nameIndex); | 1800 Symbol f_genSig = field.getGenericSignature(); |
1790 Symbol f_sig = cp.getSymbolAt(sigIndex); | 1801 AccessFlags acc = field.getAccessFlagsObj(); |
1791 Symbol f_genSig = (genSigIndex != 0)? cp.getSymbolAt(genSigIndex) : null; | 1802 |
1792 AccessFlags acc = new AccessFlags(fields.getShortAt(f + InstanceKlass.ACCESS_FLAGS_OFFSET)); | 1803 buf.beginListItem(); |
1793 | |
1794 buf.beginTag("li"); | |
1795 buf.append(genFieldModifierString(acc)); | 1804 buf.append(genFieldModifierString(acc)); |
1796 buf.append(' '); | 1805 buf.append(' '); |
1797 Formatter sigBuf = new Formatter(genHTML); | 1806 Formatter sigBuf = new Formatter(genHTML); |
1798 new SignatureConverter(f_sig, sigBuf.getBuffer()).dispatchField(); | 1807 new SignatureConverter(f_sig, sigBuf.getBuffer()).dispatchField(); |
1799 buf.append(sigBuf.toString().replace('/', '.')); | 1808 buf.append(sigBuf.toString().replace('/', '.')); |
1800 buf.append(' '); | 1809 buf.append(' '); |
1801 buf.append(f_name.asString()); | 1810 buf.append(f_name); |
1802 buf.append(';'); | 1811 buf.append(';'); |
1803 // is it generic? | 1812 // is it generic? |
1804 if (f_genSig != null) { | 1813 if (f_genSig != null) { |
1805 buf.append(" [signature "); | 1814 buf.append(" [signature "); |
1806 buf.append(escapeHTMLSpecialChars(f_genSig.asString())); | 1815 buf.append(escapeHTMLSpecialChars(f_genSig.asString())); |
1807 buf.append("] "); | 1816 buf.append("] "); |
1808 } | 1817 } |
1809 buf.endTag("li"); | 1818 buf.append(" (offset = " + field.getOffset() + ")"); |
1819 buf.endListItem(); | |
1810 } | 1820 } |
1811 buf.endList(); | 1821 buf.endList(); |
1812 } | 1822 } |
1813 return buf.toString(); | 1823 return buf.toString(); |
1814 } | 1824 } |