annotate agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java @ 1040:873ec3787992

6892186: SA does not dump debug info for scalar replaced objects Summary: Implement scalar replaced objects debug info dump in SA. Reviewed-by: twisti
author kvn
date Wed, 21 Oct 2009 09:15:33 -0700
parents cecd8eb4e0ca
children bc32f286fae0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 113
diff changeset
2 * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.ui.classbrowser;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.asm.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.asm.sparc.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.asm.x86.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.asm.ia64.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.compiler.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import sun.jvm.hotspot.tools.jcore.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 public class HTMLGenerator implements /* imports */ ClassConstants {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static class Formatter {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 boolean html;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 StringBuffer buf = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 Formatter(boolean h) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 html = h;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 void append(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 buf.append(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 void append(int s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 buf.append(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 void append(char s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 buf.append(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void append(StringBuffer s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 buf.append(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void append(Formatter s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 buf.append(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 StringBuffer getBuffer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 return buf;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 void wrap(String tag, String text) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 wrap(tag, tag, text);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 void wrap(String before, String after, String text) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 beginTag(before);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 append(text);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 endTag(after);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // header tags
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void h1(String s) { nl(); wrap("h1", s); nl(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 void h2(String s) { nl(); wrap("h2", s); nl(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void h3(String s) { nl(); wrap("h3", s); nl(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 void h4(String s) { nl(); wrap("h4", s); nl(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // list tags
a61af66fc99e Initial load
duke
parents:
diff changeset
97 void beginList() { beginTag("ul"); nl(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void li(String s) { wrap("li", s); nl(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void endList() { endTag("ul"); nl(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // table tags
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void beginTable(int border) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 beginTag("table border='" + border + "'");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void cell(String s) { wrap("td", s); }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void headerCell(String s) { wrap("th", s); }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 void endTable() { endTag("table"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 void link(String href, String text) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 wrap("a href='" + href + "'", "a", text);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void beginTag(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (html) { append("<"); append(s); append(">"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void endTag(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (html) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 append("</"); append(s); append(">");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 if (s.equals("table") || s.equals("tr")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 nl();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if (s.equals("td") || s.equals("th")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 append(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void bold(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 wrap("b", s);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 void nl() {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (!html) buf.append("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void br() {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (html) append("<br>");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 else append("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 void genEmptyHTML() {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (html) append("<html></html>");
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 void genHTMLPrologue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (html) append("<html><body>");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 void genHTMLPrologue(String title) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 if (html) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 append("<html><head><title>");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 append(title);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 append("</title></head>");
a61af66fc99e Initial load
duke
parents:
diff changeset
152 append("<body>");
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 h2(title);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void genHTMLEpilogue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (html) append("</body></html>");
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 private static final String DUMP_KLASS_OUTPUT_DIR = ".";
a61af66fc99e Initial load
duke
parents:
diff changeset
163 private static final int NATIVE_CODE_SIZE = 200;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 private final String spaces;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 private final String tab;
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 private boolean genHTML = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 public HTMLGenerator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 this(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 public HTMLGenerator(boolean html) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 genHTML = html;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if (html) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 spaces = "&nbsp;&nbsp;";
a61af66fc99e Initial load
duke
parents:
diff changeset
177 tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
a61af66fc99e Initial load
duke
parents:
diff changeset
178 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 spaces = " ";
a61af66fc99e Initial load
duke
parents:
diff changeset
180 tab = " ";
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 private static CPUHelper cpuHelper;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 });
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 private static synchronized void initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 String cpu = VM.getVM().getCPU();
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (cpu.equals("sparc")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 cpuHelper = new SPARCHelper();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 } else if (cpu.equals("x86")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 cpuHelper = new X86Helper();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 } else if (cpu.equals("ia64")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 cpuHelper = new IA64Helper();
a61af66fc99e Initial load
duke
parents:
diff changeset
201 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 throw new RuntimeException("cpu '" + cpu + "' is not yet supported!");
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 protected static synchronized CPUHelper getCPUHelper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return cpuHelper;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 protected String escapeHTMLSpecialChars(String value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (!genHTML) return value;
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 int len = value.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
215 for (int i=0; i < len; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 char c = value.charAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 switch (c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 case '<':
a61af66fc99e Initial load
duke
parents:
diff changeset
219 buf.append("&lt;");
a61af66fc99e Initial load
duke
parents:
diff changeset
220 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 case '>':
a61af66fc99e Initial load
duke
parents:
diff changeset
222 buf.append("&gt;");
a61af66fc99e Initial load
duke
parents:
diff changeset
223 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 case '&':
a61af66fc99e Initial load
duke
parents:
diff changeset
225 buf.append("&amp;");
a61af66fc99e Initial load
duke
parents:
diff changeset
226 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
228 buf.append(c);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 public String genHTMLForMessage(String message) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 buf.genHTMLPrologue(message);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 public String genHTMLErrorMessage(Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 exp.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return genHTMLForMessage(exp.getClass().getName() + " : " + exp.getMessage());
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 public String genHTMLForWait(String message) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 buf.genHTMLPrologue("Please wait ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
250 buf.h2(message);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 protected String genKlassTitle(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 AccessFlags acc = klass.getAccessFlagsObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 if (acc.isPublic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 buf.append("public ");
a61af66fc99e Initial load
duke
parents:
diff changeset
259 } else if (acc.isProtected()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 buf.append("protected ");
a61af66fc99e Initial load
duke
parents:
diff changeset
261 } else if (acc.isPrivate()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 buf.append("private ");
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 if (acc.isStatic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 buf.append("static ");
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if (acc.isAbstract() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 buf.append("abstract ");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 } else if (acc.isFinal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 buf.append("final ");
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 if (acc.isStrict()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 buf.append("strict ");
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // javac generated flags
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (acc.isEnum()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 buf.append("[enum] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (acc.isSynthetic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 buf.append("[synthetic] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (klass.isInterface()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 buf.append("interface");
a61af66fc99e Initial load
duke
parents:
diff changeset
289 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 buf.append("class");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 buf.append(' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
294 buf.append(klass.getName().asString().replace('/', '.'));
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // is it generic?
a61af66fc99e Initial load
duke
parents:
diff changeset
296 Symbol genSig = klass.getGenericSignature();
a61af66fc99e Initial load
duke
parents:
diff changeset
297 if (genSig != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 buf.append(" [signature ");
a61af66fc99e Initial load
duke
parents:
diff changeset
299 buf.append(escapeHTMLSpecialChars(genSig.asString()));
a61af66fc99e Initial load
duke
parents:
diff changeset
300 buf.append("] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
301 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 buf.append(' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 buf.append('@');
a61af66fc99e Initial load
duke
parents:
diff changeset
305 buf.append(klass.getHandle().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
306 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 protected String genBaseHref() {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 return "";
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 protected String genKlassHref(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 return genBaseHref() + "klass=" + klass.getHandle();
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 protected String genKlassLink(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 buf.link(genKlassHref(klass), genKlassTitle(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
320 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 protected String genMethodModifierString(AccessFlags acc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
325 if (acc.isPrivate()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 buf.append("private ");
a61af66fc99e Initial load
duke
parents:
diff changeset
327 } else if (acc.isProtected()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 buf.append("protected ");
a61af66fc99e Initial load
duke
parents:
diff changeset
329 } else if (acc.isPublic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 buf.append("public ");
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 if (acc.isStatic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 buf.append("static ");
a61af66fc99e Initial load
duke
parents:
diff changeset
335 } else if (acc.isAbstract() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 buf.append("abstract ");
a61af66fc99e Initial load
duke
parents:
diff changeset
337 } else if (acc.isFinal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 buf.append("final ");
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 if (acc.isNative()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 buf.append("native ");
a61af66fc99e Initial load
duke
parents:
diff changeset
343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 if (acc.isStrict()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
346 buf.append("strict ");
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 if (acc.isSynchronized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 buf.append("synchronized ");
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // javac generated flags
a61af66fc99e Initial load
duke
parents:
diff changeset
354 if (acc.isBridge()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 buf.append("[bridge] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (acc.isSynthetic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 buf.append("[synthetic] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 if (acc.isVarArgs()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 buf.append("[varargs] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 protected String genMethodNameAndSignature(Method method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 buf.append(genMethodModifierString(method.getAccessFlagsObj()));
a61af66fc99e Initial load
duke
parents:
diff changeset
372 Symbol sig = method.getSignature();
a61af66fc99e Initial load
duke
parents:
diff changeset
373 new SignatureConverter(sig, buf.getBuffer()).iterateReturntype();
a61af66fc99e Initial load
duke
parents:
diff changeset
374 buf.append(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
375 String methodName = method.getName().asString();
a61af66fc99e Initial load
duke
parents:
diff changeset
376 buf.append(escapeHTMLSpecialChars(methodName));
a61af66fc99e Initial load
duke
parents:
diff changeset
377 buf.append('(');
a61af66fc99e Initial load
duke
parents:
diff changeset
378 new SignatureConverter(sig, buf.getBuffer()).iterateParameters();
a61af66fc99e Initial load
duke
parents:
diff changeset
379 buf.append(')');
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // is it generic?
a61af66fc99e Initial load
duke
parents:
diff changeset
381 Symbol genSig = method.getGenericSignature();
a61af66fc99e Initial load
duke
parents:
diff changeset
382 if (genSig != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 buf.append(" [signature ");
a61af66fc99e Initial load
duke
parents:
diff changeset
384 buf.append(escapeHTMLSpecialChars(genSig.asString()));
a61af66fc99e Initial load
duke
parents:
diff changeset
385 buf.append("] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
386 }
a61af66fc99e Initial load
duke
parents:
diff changeset
387 return buf.toString().replace('/', '.');
a61af66fc99e Initial load
duke
parents:
diff changeset
388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390 protected String genMethodTitle(Method method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
391 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
392 buf.append(genMethodNameAndSignature(method));
a61af66fc99e Initial load
duke
parents:
diff changeset
393 buf.append(' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
394 buf.append('@');
a61af66fc99e Initial load
duke
parents:
diff changeset
395 buf.append(method.getHandle().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
396 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398
a61af66fc99e Initial load
duke
parents:
diff changeset
399 protected String genMethodHref(Method m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
400 return genBaseHref() + "method=" + m.getHandle();
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 protected String genMethodLink(Method m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
405 buf.link(genMethodHref(m), genMethodTitle(m));
a61af66fc99e Initial load
duke
parents:
diff changeset
406 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 protected String genMethodAndKlassLink(Method m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
411 buf.append(genMethodLink(m));
a61af66fc99e Initial load
duke
parents:
diff changeset
412 buf.append(" of ");
a61af66fc99e Initial load
duke
parents:
diff changeset
413 buf.append(genKlassLink((InstanceKlass) m.getMethodHolder()));
a61af66fc99e Initial load
duke
parents:
diff changeset
414 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416
a61af66fc99e Initial load
duke
parents:
diff changeset
417 protected String genNMethodHref(NMethod nm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
418 return genBaseHref() + "nmethod=" + nm.getAddress();
a61af66fc99e Initial load
duke
parents:
diff changeset
419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 public String genNMethodTitle(NMethod nmethod) {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
423 Method m = nmethod.getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 buf.append("Disassembly for compiled method [");
a61af66fc99e Initial load
duke
parents:
diff changeset
426 buf.append(genMethodTitle(m));
a61af66fc99e Initial load
duke
parents:
diff changeset
427 buf.append(" ] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
428 buf.append('@');
a61af66fc99e Initial load
duke
parents:
diff changeset
429 buf.append(nmethod.getAddress().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
430 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 }
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 protected String genNMethodLink(NMethod nm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
434 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 buf.link(genNMethodHref(nm), genNMethodTitle(nm));
a61af66fc99e Initial load
duke
parents:
diff changeset
436 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 public String genCodeBlobTitle(CodeBlob blob) {
a61af66fc99e Initial load
duke
parents:
diff changeset
440 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
441 buf.append("Disassembly for code blob " + blob.getName() + " [");
a61af66fc99e Initial load
duke
parents:
diff changeset
442 buf.append(blob.getClass().getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
443 buf.append(" ] @");
a61af66fc99e Initial load
duke
parents:
diff changeset
444 buf.append(blob.getAddress().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
445 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
447
a61af66fc99e Initial load
duke
parents:
diff changeset
448 protected BytecodeDisassembler createBytecodeDisassembler(Method m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 return new BytecodeDisassembler(m);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 private String genLowHighShort(int val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
454 buf.append('#');
a61af66fc99e Initial load
duke
parents:
diff changeset
455 buf.append(Integer.toString(val & 0xFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
456 buf.append(" #");
a61af66fc99e Initial load
duke
parents:
diff changeset
457 buf.append(Integer.toString((val >> 16) & 0xFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
458 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 protected String genHTMLTableForConstantPool(ConstantPool cpool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
462 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
463 buf.beginTable(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 buf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
466 buf.headerCell("Index");
a61af66fc99e Initial load
duke
parents:
diff changeset
467 buf.headerCell("Constant Type");
a61af66fc99e Initial load
duke
parents:
diff changeset
468 buf.headerCell("Constant Value");
a61af66fc99e Initial load
duke
parents:
diff changeset
469 buf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
470
a61af66fc99e Initial load
duke
parents:
diff changeset
471 final int length = (int) cpool.getLength();
a61af66fc99e Initial load
duke
parents:
diff changeset
472 // zero'th pool entry is always invalid. ignore it.
a61af66fc99e Initial load
duke
parents:
diff changeset
473 for (int index = 1; index < length; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
474 buf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
475 buf.cell(Integer.toString(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
476
a61af66fc99e Initial load
duke
parents:
diff changeset
477 int ctag = (int) cpool.getTags().getByteAt((int) index);
a61af66fc99e Initial load
duke
parents:
diff changeset
478 switch (ctag) {
a61af66fc99e Initial load
duke
parents:
diff changeset
479 case JVM_CONSTANT_Integer:
a61af66fc99e Initial load
duke
parents:
diff changeset
480 buf.cell("JVM_CONSTANT_Integer");
a61af66fc99e Initial load
duke
parents:
diff changeset
481 buf.cell(Integer.toString(cpool.getIntAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
482 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 case JVM_CONSTANT_Float:
a61af66fc99e Initial load
duke
parents:
diff changeset
485 buf.cell("JVM_CONSTANT_Float");
a61af66fc99e Initial load
duke
parents:
diff changeset
486 buf.cell(Float.toString(cpool.getFloatAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
487 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
488
a61af66fc99e Initial load
duke
parents:
diff changeset
489 case JVM_CONSTANT_Long:
a61af66fc99e Initial load
duke
parents:
diff changeset
490 buf.cell("JVM_CONSTANT_Long");
a61af66fc99e Initial load
duke
parents:
diff changeset
491 buf.cell(Long.toString(cpool.getLongAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
492 // long entries occupy two slots
a61af66fc99e Initial load
duke
parents:
diff changeset
493 index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 case JVM_CONSTANT_Double:
a61af66fc99e Initial load
duke
parents:
diff changeset
497 buf.cell("JVM_CONSTANT_Double");
a61af66fc99e Initial load
duke
parents:
diff changeset
498 buf.cell(Double.toString(cpool.getDoubleAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // double entries occupy two slots
a61af66fc99e Initial load
duke
parents:
diff changeset
500 index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
501 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
502
a61af66fc99e Initial load
duke
parents:
diff changeset
503 case JVM_CONSTANT_UnresolvedClass:
a61af66fc99e Initial load
duke
parents:
diff changeset
504 buf.cell("JVM_CONSTANT_UnresolvedClass");
a61af66fc99e Initial load
duke
parents:
diff changeset
505 buf.cell(cpool.getSymbolAt(index).asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
506 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
507
a61af66fc99e Initial load
duke
parents:
diff changeset
508 case JVM_CONSTANT_Class:
a61af66fc99e Initial load
duke
parents:
diff changeset
509 buf.cell("JVM_CONSTANT_Class");
a61af66fc99e Initial load
duke
parents:
diff changeset
510 Klass klass = (Klass) cpool.getObjAt(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
511 if (klass instanceof InstanceKlass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
512 buf.cell(genKlassLink((InstanceKlass) klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
513 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 buf.cell(klass.getName().asString().replace('/', '.'));
a61af66fc99e Initial load
duke
parents:
diff changeset
515 }
a61af66fc99e Initial load
duke
parents:
diff changeset
516 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
517
a61af66fc99e Initial load
duke
parents:
diff changeset
518 case JVM_CONSTANT_UnresolvedString:
a61af66fc99e Initial load
duke
parents:
diff changeset
519 buf.cell("JVM_CONSTANT_UnresolvedString");
a61af66fc99e Initial load
duke
parents:
diff changeset
520 buf.cell("\"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
521 escapeHTMLSpecialChars(cpool.getSymbolAt(index).asString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
522 "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
523 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
524
a61af66fc99e Initial load
duke
parents:
diff changeset
525 case JVM_CONSTANT_Utf8:
a61af66fc99e Initial load
duke
parents:
diff changeset
526 buf.cell("JVM_CONSTANT_Utf8");
a61af66fc99e Initial load
duke
parents:
diff changeset
527 buf.cell("\"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
528 escapeHTMLSpecialChars(cpool.getSymbolAt(index).asString()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
529 "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
530 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 case JVM_CONSTANT_String:
a61af66fc99e Initial load
duke
parents:
diff changeset
533 buf.cell("JVM_CONSTANT_String");
a61af66fc99e Initial load
duke
parents:
diff changeset
534 buf.cell("\"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
535 escapeHTMLSpecialChars(OopUtilities.stringOopToString(cpool.getObjAt(index))) + "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
536 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
537
a61af66fc99e Initial load
duke
parents:
diff changeset
538 case JVM_CONSTANT_Fieldref:
a61af66fc99e Initial load
duke
parents:
diff changeset
539 buf.cell("JVM_CONSTANT_Fieldref");
a61af66fc99e Initial load
duke
parents:
diff changeset
540 buf.cell(genLowHighShort(cpool.getIntAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
541 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 case JVM_CONSTANT_Methodref:
a61af66fc99e Initial load
duke
parents:
diff changeset
544 buf.cell("JVM_CONSTANT_Methodref");
a61af66fc99e Initial load
duke
parents:
diff changeset
545 buf.cell(genLowHighShort(cpool.getIntAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
546 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
547
a61af66fc99e Initial load
duke
parents:
diff changeset
548 case JVM_CONSTANT_InterfaceMethodref:
a61af66fc99e Initial load
duke
parents:
diff changeset
549 buf.cell("JVM_CONSTANT_InterfaceMethodref");
a61af66fc99e Initial load
duke
parents:
diff changeset
550 buf.cell(genLowHighShort(cpool.getIntAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
551 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
552
a61af66fc99e Initial load
duke
parents:
diff changeset
553 case JVM_CONSTANT_NameAndType:
a61af66fc99e Initial load
duke
parents:
diff changeset
554 buf.cell("JVM_CONSTANT_NameAndType");
a61af66fc99e Initial load
duke
parents:
diff changeset
555 buf.cell(genLowHighShort(cpool.getIntAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
556 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 case JVM_CONSTANT_ClassIndex:
a61af66fc99e Initial load
duke
parents:
diff changeset
559 buf.cell("JVM_CONSTANT_ClassIndex");
a61af66fc99e Initial load
duke
parents:
diff changeset
560 buf.cell(Integer.toString(cpool.getIntAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
561 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 case JVM_CONSTANT_StringIndex:
a61af66fc99e Initial load
duke
parents:
diff changeset
564 buf.cell("JVM_CONSTANT_StringIndex");
a61af66fc99e Initial load
duke
parents:
diff changeset
565 buf.cell(Integer.toString(cpool.getIntAt(index)));
a61af66fc99e Initial load
duke
parents:
diff changeset
566 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
567 }
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 buf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 buf.endTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
573 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
574 }
a61af66fc99e Initial load
duke
parents:
diff changeset
575
a61af66fc99e Initial load
duke
parents:
diff changeset
576 public String genHTML(ConstantPool cpool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
577 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
578 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
579 buf.genHTMLPrologue(genConstantPoolTitle(cpool));
a61af66fc99e Initial load
duke
parents:
diff changeset
580 buf.h3("Holder Class");
a61af66fc99e Initial load
duke
parents:
diff changeset
581 buf.append(genKlassLink((InstanceKlass) cpool.getPoolHolder()));
a61af66fc99e Initial load
duke
parents:
diff changeset
582 buf.h3("Constants");
a61af66fc99e Initial load
duke
parents:
diff changeset
583 buf.append(genHTMLTableForConstantPool(cpool));
a61af66fc99e Initial load
duke
parents:
diff changeset
584 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
585 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
586 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
587 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590
a61af66fc99e Initial load
duke
parents:
diff changeset
591 protected String genConstantPoolHref(ConstantPool cpool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
592 return genBaseHref() + "cpool=" + cpool.getHandle();
a61af66fc99e Initial load
duke
parents:
diff changeset
593 }
a61af66fc99e Initial load
duke
parents:
diff changeset
594
a61af66fc99e Initial load
duke
parents:
diff changeset
595 protected String genConstantPoolTitle(ConstantPool cpool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
596 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
597 buf.append("Constant Pool of [");
a61af66fc99e Initial load
duke
parents:
diff changeset
598 buf.append(genKlassTitle((InstanceKlass) cpool.getPoolHolder()));
a61af66fc99e Initial load
duke
parents:
diff changeset
599 buf.append("] @");
a61af66fc99e Initial load
duke
parents:
diff changeset
600 buf.append(cpool.getHandle().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
601 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
602 }
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 protected String genConstantPoolLink(ConstantPool cpool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
606 buf.link(genConstantPoolHref(cpool), genConstantPoolTitle(cpool));
a61af66fc99e Initial load
duke
parents:
diff changeset
607 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
609
a61af66fc99e Initial load
duke
parents:
diff changeset
610 public String genHTML(Method method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
612 final Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
613 buf.genHTMLPrologue(genMethodTitle(method));
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615 buf.h3("Holder Class");
a61af66fc99e Initial load
duke
parents:
diff changeset
616 buf.append(genKlassLink((InstanceKlass) method.getMethodHolder()));
a61af66fc99e Initial load
duke
parents:
diff changeset
617
a61af66fc99e Initial load
duke
parents:
diff changeset
618 NMethod nmethod = method.getNativeMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
619 if (nmethod != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
620 buf.h3("Compiled Code");
a61af66fc99e Initial load
duke
parents:
diff changeset
621 buf.append(genNMethodLink(nmethod));
a61af66fc99e Initial load
duke
parents:
diff changeset
622 }
a61af66fc99e Initial load
duke
parents:
diff changeset
623
a61af66fc99e Initial load
duke
parents:
diff changeset
624 boolean hasThrows = method.hasCheckedExceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
625 ConstantPool cpool = ((InstanceKlass) method.getMethodHolder()).getConstants();
a61af66fc99e Initial load
duke
parents:
diff changeset
626 if (hasThrows) {
a61af66fc99e Initial load
duke
parents:
diff changeset
627 buf.h3("Checked Exception(s)");
a61af66fc99e Initial load
duke
parents:
diff changeset
628 CheckedExceptionElement[] exceptions = method.getCheckedExceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
629 buf.beginTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
630 for (int exp = 0; exp < exceptions.length; exp++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
631 short cpIndex = (short) exceptions[exp].getClassCPIndex();
a61af66fc99e Initial load
duke
parents:
diff changeset
632 Oop obj = cpool.getObjAt(cpIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
633 if (obj instanceof Symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
634 buf.li(((Symbol)obj).asString().replace('/', '.'));
a61af66fc99e Initial load
duke
parents:
diff changeset
635 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
636 buf.li(genKlassLink((InstanceKlass)obj));
a61af66fc99e Initial load
duke
parents:
diff changeset
637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
639 buf.endTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
641
a61af66fc99e Initial load
duke
parents:
diff changeset
642 if (method.isNative() || method.isAbstract()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
643 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
644 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647 buf.h3("Bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
648 BytecodeDisassembler disasm = createBytecodeDisassembler(method);
a61af66fc99e Initial load
duke
parents:
diff changeset
649 final boolean hasLineNumbers = method.hasLineNumberTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
650 disasm.decode(new BytecodeVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
651 private Method method;
a61af66fc99e Initial load
duke
parents:
diff changeset
652 public void prologue(Method m) {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 method = m;
a61af66fc99e Initial load
duke
parents:
diff changeset
654 buf.beginTable(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
655 buf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
656 if (hasLineNumbers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
657 buf.headerCell("line");
a61af66fc99e Initial load
duke
parents:
diff changeset
658 }
a61af66fc99e Initial load
duke
parents:
diff changeset
659 buf.headerCell("bci" + spaces);
a61af66fc99e Initial load
duke
parents:
diff changeset
660 buf.headerCell("bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
661 buf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663
a61af66fc99e Initial load
duke
parents:
diff changeset
664 public void visit(Bytecode instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
665 int curBci = instr.bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
666 buf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
667 if (hasLineNumbers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
668 int lineNumber = method.getLineNumberFromBCI(curBci);
a61af66fc99e Initial load
duke
parents:
diff changeset
669 buf.cell(Integer.toString(lineNumber) + spaces);
a61af66fc99e Initial load
duke
parents:
diff changeset
670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
671 buf.cell(Integer.toString(curBci) + spaces);
a61af66fc99e Initial load
duke
parents:
diff changeset
672
a61af66fc99e Initial load
duke
parents:
diff changeset
673 buf.beginTag("td");
a61af66fc99e Initial load
duke
parents:
diff changeset
674 String instrStr = escapeHTMLSpecialChars(instr.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
675
a61af66fc99e Initial load
duke
parents:
diff changeset
676 if (instr instanceof BytecodeNew) {
a61af66fc99e Initial load
duke
parents:
diff changeset
677 BytecodeNew newBytecode = (BytecodeNew) instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
678 InstanceKlass klass = newBytecode.getNewKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
679 if (klass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
680 buf.link(genKlassHref(klass), instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
681 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
682 buf.append(instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
683 }
a61af66fc99e Initial load
duke
parents:
diff changeset
684 } else if(instr instanceof BytecodeInvoke) {
a61af66fc99e Initial load
duke
parents:
diff changeset
685 BytecodeInvoke invokeBytecode = (BytecodeInvoke) instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
686 Method m = invokeBytecode.getInvokedMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
687 if (m != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
688 buf.link(genMethodHref(m), instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
689 buf.append(" of ");
a61af66fc99e Initial load
duke
parents:
diff changeset
690 InstanceKlass klass = (InstanceKlass) m.getMethodHolder();
a61af66fc99e Initial load
duke
parents:
diff changeset
691 buf.link(genKlassHref(klass), genKlassTitle(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
692 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
693 buf.append(instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
695 } else if (instr instanceof BytecodeGetPut) {
a61af66fc99e Initial load
duke
parents:
diff changeset
696 BytecodeGetPut getPut = (BytecodeGetPut) instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
697 sun.jvm.hotspot.oops.Field f = getPut.getField();
a61af66fc99e Initial load
duke
parents:
diff changeset
698 buf.append(instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
699 if (f != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
700 InstanceKlass klass = f.getFieldHolder();
a61af66fc99e Initial load
duke
parents:
diff changeset
701 buf.append(" of ");
a61af66fc99e Initial load
duke
parents:
diff changeset
702 buf.link(genKlassHref(klass), genKlassTitle(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
703 }
a61af66fc99e Initial load
duke
parents:
diff changeset
704 } else if (instr instanceof BytecodeLoadConstant) {
a61af66fc99e Initial load
duke
parents:
diff changeset
705 BytecodeLoadConstant ldc = (BytecodeLoadConstant) instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
706 if (ldc.isKlassConstant()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
707 Oop oop = ldc.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
708 if (oop instanceof Klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
709 buf.append("<a href='");
a61af66fc99e Initial load
duke
parents:
diff changeset
710 buf.append(genKlassHref((InstanceKlass) oop));
a61af66fc99e Initial load
duke
parents:
diff changeset
711 buf.append("'>");
a61af66fc99e Initial load
duke
parents:
diff changeset
712 buf.append(instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
713 buf.append("</a>");
a61af66fc99e Initial load
duke
parents:
diff changeset
714 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
715 // unresolved klass literal
a61af66fc99e Initial load
duke
parents:
diff changeset
716 buf.append(instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
717 }
a61af66fc99e Initial load
duke
parents:
diff changeset
718 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
719 // not a klass literal
a61af66fc99e Initial load
duke
parents:
diff changeset
720 buf.append(instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
721 }
a61af66fc99e Initial load
duke
parents:
diff changeset
722 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
723 buf.append(instrStr);
a61af66fc99e Initial load
duke
parents:
diff changeset
724 }
a61af66fc99e Initial load
duke
parents:
diff changeset
725 buf.endTag("td");
a61af66fc99e Initial load
duke
parents:
diff changeset
726 buf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
727 }
a61af66fc99e Initial load
duke
parents:
diff changeset
728
a61af66fc99e Initial load
duke
parents:
diff changeset
729 public void epilogue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
730 buf.endTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
731 }
a61af66fc99e Initial load
duke
parents:
diff changeset
732 });
a61af66fc99e Initial load
duke
parents:
diff changeset
733
a61af66fc99e Initial load
duke
parents:
diff changeset
734 // display exception table for this method
a61af66fc99e Initial load
duke
parents:
diff changeset
735 TypeArray exceptionTable = method.getExceptionTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
736 // exception table is 4 tuple array of shorts
a61af66fc99e Initial load
duke
parents:
diff changeset
737 int numEntries = (int)exceptionTable.getLength() / 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
738 if (numEntries != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
739 buf.h4("Exception Table");
a61af66fc99e Initial load
duke
parents:
diff changeset
740 buf.beginTable(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
741 buf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
742 buf.headerCell("start bci");
a61af66fc99e Initial load
duke
parents:
diff changeset
743 buf.headerCell("end bci");
a61af66fc99e Initial load
duke
parents:
diff changeset
744 buf.headerCell("handler bci");
a61af66fc99e Initial load
duke
parents:
diff changeset
745 buf.headerCell("catch type");
a61af66fc99e Initial load
duke
parents:
diff changeset
746 buf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
747
a61af66fc99e Initial load
duke
parents:
diff changeset
748 for (int e = 0; e < numEntries; e += 4) {
a61af66fc99e Initial load
duke
parents:
diff changeset
749 buf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
750 buf.cell(Integer.toString(exceptionTable.getIntAt(e)));
a61af66fc99e Initial load
duke
parents:
diff changeset
751 buf.cell(Integer.toString(exceptionTable.getIntAt(e + 1)));
a61af66fc99e Initial load
duke
parents:
diff changeset
752 buf.cell(Integer.toString(exceptionTable.getIntAt(e + 2)));
a61af66fc99e Initial load
duke
parents:
diff changeset
753 short cpIndex = (short) exceptionTable.getIntAt(e + 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
754 Oop obj = cpIndex == 0? null : cpool.getObjAt(cpIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
755 if (obj == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
756 buf.cell("Any");
a61af66fc99e Initial load
duke
parents:
diff changeset
757 } else if (obj instanceof Symbol) {
a61af66fc99e Initial load
duke
parents:
diff changeset
758 buf.cell(((Symbol)obj).asString().replace('/', '.'));
a61af66fc99e Initial load
duke
parents:
diff changeset
759 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
760 buf.cell(genKlassLink((InstanceKlass)obj));
a61af66fc99e Initial load
duke
parents:
diff changeset
761 }
a61af66fc99e Initial load
duke
parents:
diff changeset
762 buf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
763 }
a61af66fc99e Initial load
duke
parents:
diff changeset
764
a61af66fc99e Initial load
duke
parents:
diff changeset
765 buf.endTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
766 }
a61af66fc99e Initial load
duke
parents:
diff changeset
767
a61af66fc99e Initial load
duke
parents:
diff changeset
768 // display constant pool hyperlink
a61af66fc99e Initial load
duke
parents:
diff changeset
769 buf.h3("Constant Pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
770 buf.append(genConstantPoolLink(cpool));
a61af66fc99e Initial load
duke
parents:
diff changeset
771 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
772 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
773 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
774 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
775 }
a61af66fc99e Initial load
duke
parents:
diff changeset
776 }
a61af66fc99e Initial load
duke
parents:
diff changeset
777
a61af66fc99e Initial load
duke
parents:
diff changeset
778 protected Disassembler createDisassembler(long startPc, byte[] code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
779 return getCPUHelper().createDisassembler(startPc, code);
a61af66fc99e Initial load
duke
parents:
diff changeset
780 }
a61af66fc99e Initial load
duke
parents:
diff changeset
781
a61af66fc99e Initial load
duke
parents:
diff changeset
782 protected SymbolFinder createSymbolFinder() {
a61af66fc99e Initial load
duke
parents:
diff changeset
783 return new DummySymbolFinder();
a61af66fc99e Initial load
duke
parents:
diff changeset
784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
785
a61af66fc99e Initial load
duke
parents:
diff changeset
786 // genHTML for a given address. Address may be a PC or
a61af66fc99e Initial load
duke
parents:
diff changeset
787 // methodOop or klassOop.
a61af66fc99e Initial load
duke
parents:
diff changeset
788
a61af66fc99e Initial load
duke
parents:
diff changeset
789 public String genHTMLForAddress(String addrStr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
790 return genHTML(parseAddress(addrStr));
a61af66fc99e Initial load
duke
parents:
diff changeset
791 }
a61af66fc99e Initial load
duke
parents:
diff changeset
792
a61af66fc99e Initial load
duke
parents:
diff changeset
793 public String genHTML(sun.jvm.hotspot.debugger.Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
794 CodeBlob blob = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
795
a61af66fc99e Initial load
duke
parents:
diff changeset
796 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
797 blob = (CodeBlob)VM.getVM().getCodeCache().findBlobUnsafe(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
798 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
799 // ignore
a61af66fc99e Initial load
duke
parents:
diff changeset
800 }
a61af66fc99e Initial load
duke
parents:
diff changeset
801
a61af66fc99e Initial load
duke
parents:
diff changeset
802 if (blob != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
803 if (blob instanceof NMethod) {
a61af66fc99e Initial load
duke
parents:
diff changeset
804 return genHTML((NMethod)blob);
a61af66fc99e Initial load
duke
parents:
diff changeset
805 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
806 // may be interpreter code.
a61af66fc99e Initial load
duke
parents:
diff changeset
807 Interpreter interp = VM.getVM().getInterpreter();
a61af66fc99e Initial load
duke
parents:
diff changeset
808 if (interp.contains(pc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
809 InterpreterCodelet codelet = interp.getCodeletContaining(pc);
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
810 if (codelet == null) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
811 return "Unknown location in the Interpreter: " + pc;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
812 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
813 return genHTML(codelet);
a61af66fc99e Initial load
duke
parents:
diff changeset
814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
815 return genHTML(blob);
a61af66fc99e Initial load
duke
parents:
diff changeset
816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
817 } else if (VM.getVM().getCodeCache().contains(pc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
818 return "Unknown location in the CodeCache: " + pc;
a61af66fc99e Initial load
duke
parents:
diff changeset
819 }
a61af66fc99e Initial load
duke
parents:
diff changeset
820
a61af66fc99e Initial load
duke
parents:
diff changeset
821 // did not find nmethod.
a61af66fc99e Initial load
duke
parents:
diff changeset
822 // try methodOop, klassOop and constantPoolOop.
a61af66fc99e Initial load
duke
parents:
diff changeset
823 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
824 Oop obj = getOopAtAddress(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
825 if (obj != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
826 if (obj instanceof Method) {
a61af66fc99e Initial load
duke
parents:
diff changeset
827 return genHTML((Method) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
828 } else if (obj instanceof InstanceKlass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
829 return genHTML((InstanceKlass) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
830 } else if (obj instanceof ConstantPool) {
a61af66fc99e Initial load
duke
parents:
diff changeset
831 return genHTML((ConstantPool) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
832 }
a61af66fc99e Initial load
duke
parents:
diff changeset
833 }
a61af66fc99e Initial load
duke
parents:
diff changeset
834 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
835 // ignore
a61af66fc99e Initial load
duke
parents:
diff changeset
836 }
a61af66fc99e Initial load
duke
parents:
diff changeset
837
a61af66fc99e Initial load
duke
parents:
diff changeset
838 // didn't find any. do raw disassembly.
a61af66fc99e Initial load
duke
parents:
diff changeset
839 return genHTMLForRawDisassembly(pc, null);
a61af66fc99e Initial load
duke
parents:
diff changeset
840 }
a61af66fc99e Initial load
duke
parents:
diff changeset
841
a61af66fc99e Initial load
duke
parents:
diff changeset
842 protected byte[] readBuffer(sun.jvm.hotspot.debugger.Address addr, int size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
843 byte[] buf = new byte[size];
a61af66fc99e Initial load
duke
parents:
diff changeset
844 for (int b = 0; b < size; b++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
845 buf[b] = (byte) addr.getJByteAt(b);
a61af66fc99e Initial load
duke
parents:
diff changeset
846 }
a61af66fc99e Initial load
duke
parents:
diff changeset
847 return buf;
a61af66fc99e Initial load
duke
parents:
diff changeset
848 }
a61af66fc99e Initial load
duke
parents:
diff changeset
849
a61af66fc99e Initial load
duke
parents:
diff changeset
850 public String genHTMLForRawDisassembly(sun.jvm.hotspot.debugger.Address startPc, int size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
852 return genHTMLForRawDisassembly(startPc, null, readBuffer(startPc, size));
a61af66fc99e Initial load
duke
parents:
diff changeset
853 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
854 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
855 }
a61af66fc99e Initial load
duke
parents:
diff changeset
856 }
a61af66fc99e Initial load
duke
parents:
diff changeset
857
a61af66fc99e Initial load
duke
parents:
diff changeset
858 protected String genHTMLForRawDisassembly(sun.jvm.hotspot.debugger.Address startPc,
a61af66fc99e Initial load
duke
parents:
diff changeset
859 String prevPCs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
860 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
861 return genHTMLForRawDisassembly(startPc, prevPCs, readBuffer(startPc, NATIVE_CODE_SIZE));
a61af66fc99e Initial load
duke
parents:
diff changeset
862 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
863 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
865 }
a61af66fc99e Initial load
duke
parents:
diff changeset
866
a61af66fc99e Initial load
duke
parents:
diff changeset
867 protected String genPCHref(long targetPc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
868 return genBaseHref() + "pc=0x" + Long.toHexString(targetPc);
a61af66fc99e Initial load
duke
parents:
diff changeset
869 }
a61af66fc99e Initial load
duke
parents:
diff changeset
870
a61af66fc99e Initial load
duke
parents:
diff changeset
871 protected String genMultPCHref(String pcs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
872 StringBuffer buf = new StringBuffer(genBaseHref());
a61af66fc99e Initial load
duke
parents:
diff changeset
873 buf.append("pc_multiple=");
a61af66fc99e Initial load
duke
parents:
diff changeset
874 buf.append(pcs);
a61af66fc99e Initial load
duke
parents:
diff changeset
875 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
876 }
a61af66fc99e Initial load
duke
parents:
diff changeset
877
a61af66fc99e Initial load
duke
parents:
diff changeset
878 protected String genPCHref(long currentPc, sun.jvm.hotspot.asm.Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
879 String href = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
880 if (addr instanceof PCRelativeAddress) {
a61af66fc99e Initial load
duke
parents:
diff changeset
881 PCRelativeAddress pcRelAddr = (PCRelativeAddress) addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
882 href = genPCHref(currentPc + pcRelAddr.getDisplacement());
a61af66fc99e Initial load
duke
parents:
diff changeset
883 } else if(addr instanceof DirectAddress) {
a61af66fc99e Initial load
duke
parents:
diff changeset
884 href = genPCHref(((DirectAddress) addr).getValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
885 }
a61af66fc99e Initial load
duke
parents:
diff changeset
886
a61af66fc99e Initial load
duke
parents:
diff changeset
887 return href;
a61af66fc99e Initial load
duke
parents:
diff changeset
888 }
a61af66fc99e Initial load
duke
parents:
diff changeset
889
a61af66fc99e Initial load
duke
parents:
diff changeset
890 class RawCodeVisitor implements InstructionVisitor {
a61af66fc99e Initial load
duke
parents:
diff changeset
891 private int instrSize = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
892 private Formatter buf;
a61af66fc99e Initial load
duke
parents:
diff changeset
893 private SymbolFinder symFinder = createSymbolFinder();
a61af66fc99e Initial load
duke
parents:
diff changeset
894
a61af66fc99e Initial load
duke
parents:
diff changeset
895 RawCodeVisitor(Formatter buf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
896 this.buf = buf;
a61af66fc99e Initial load
duke
parents:
diff changeset
897 }
a61af66fc99e Initial load
duke
parents:
diff changeset
898
a61af66fc99e Initial load
duke
parents:
diff changeset
899 public int getInstructionSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
900 return instrSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
901 }
a61af66fc99e Initial load
duke
parents:
diff changeset
902
a61af66fc99e Initial load
duke
parents:
diff changeset
903 public void prologue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
904 }
a61af66fc99e Initial load
duke
parents:
diff changeset
905
a61af66fc99e Initial load
duke
parents:
diff changeset
906 public void visit(long currentPc, Instruction instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
907 String href = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
908 if (instr.isCall()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
909 CallInstruction call = (CallInstruction) instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
910 sun.jvm.hotspot.asm.Address addr = call.getBranchDestination();
a61af66fc99e Initial load
duke
parents:
diff changeset
911 href = genPCHref(currentPc, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
913
a61af66fc99e Initial load
duke
parents:
diff changeset
914 instrSize += instr.getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
915 buf.append("0x");
a61af66fc99e Initial load
duke
parents:
diff changeset
916 buf.append(Long.toHexString(currentPc));
a61af66fc99e Initial load
duke
parents:
diff changeset
917 buf.append(':');
a61af66fc99e Initial load
duke
parents:
diff changeset
918 buf.append(tab);
a61af66fc99e Initial load
duke
parents:
diff changeset
919
a61af66fc99e Initial load
duke
parents:
diff changeset
920 if (href != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
921 buf.link(href, instr.asString(currentPc, symFinder));
a61af66fc99e Initial load
duke
parents:
diff changeset
922 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
923 buf.append(instr.asString(currentPc, symFinder));
a61af66fc99e Initial load
duke
parents:
diff changeset
924 }
a61af66fc99e Initial load
duke
parents:
diff changeset
925 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
927
a61af66fc99e Initial load
duke
parents:
diff changeset
928 public void epilogue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
929 }
a61af66fc99e Initial load
duke
parents:
diff changeset
930 };
a61af66fc99e Initial load
duke
parents:
diff changeset
931
a61af66fc99e Initial load
duke
parents:
diff changeset
932 protected String genHTMLForRawDisassembly(sun.jvm.hotspot.debugger.Address addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
933 String prevPCs,
a61af66fc99e Initial load
duke
parents:
diff changeset
934 byte[] code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
935 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
936 long startPc = addressToLong(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
937 Disassembler disasm = createDisassembler(startPc, code);
a61af66fc99e Initial load
duke
parents:
diff changeset
938 final Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
939 buf.genHTMLPrologue("Disassembly @0x" + Long.toHexString(startPc));
a61af66fc99e Initial load
duke
parents:
diff changeset
940
a61af66fc99e Initial load
duke
parents:
diff changeset
941 if (prevPCs != null && genHTML) {
a61af66fc99e Initial load
duke
parents:
diff changeset
942 buf.beginTag("p");
a61af66fc99e Initial load
duke
parents:
diff changeset
943 buf.link(genMultPCHref(prevPCs), "show previous code ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
944 buf.endTag("p");
a61af66fc99e Initial load
duke
parents:
diff changeset
945 }
a61af66fc99e Initial load
duke
parents:
diff changeset
946
a61af66fc99e Initial load
duke
parents:
diff changeset
947
a61af66fc99e Initial load
duke
parents:
diff changeset
948 buf.h3("Code");
a61af66fc99e Initial load
duke
parents:
diff changeset
949 RawCodeVisitor visitor = new RawCodeVisitor(buf);
a61af66fc99e Initial load
duke
parents:
diff changeset
950 disasm.decode(visitor);
a61af66fc99e Initial load
duke
parents:
diff changeset
951
a61af66fc99e Initial load
duke
parents:
diff changeset
952 if (genHTML) buf.beginTag("p");
a61af66fc99e Initial load
duke
parents:
diff changeset
953 Formatter tmpBuf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
954 tmpBuf.append("0x");
a61af66fc99e Initial load
duke
parents:
diff changeset
955 tmpBuf.append(Long.toHexString(startPc + visitor.getInstructionSize()).toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
956 tmpBuf.append(",0x");
a61af66fc99e Initial load
duke
parents:
diff changeset
957 tmpBuf.append(Long.toHexString(startPc));
a61af66fc99e Initial load
duke
parents:
diff changeset
958 if (prevPCs != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
959 tmpBuf.append(',');
a61af66fc99e Initial load
duke
parents:
diff changeset
960 tmpBuf.append(prevPCs);
a61af66fc99e Initial load
duke
parents:
diff changeset
961 }
a61af66fc99e Initial load
duke
parents:
diff changeset
962 if (genHTML) {
a61af66fc99e Initial load
duke
parents:
diff changeset
963 buf.link(genMultPCHref(tmpBuf.toString()), "show more code ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
964 buf.endTag("p");
a61af66fc99e Initial load
duke
parents:
diff changeset
965 }
a61af66fc99e Initial load
duke
parents:
diff changeset
966
a61af66fc99e Initial load
duke
parents:
diff changeset
967 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
968 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
969 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
970 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
973
a61af66fc99e Initial load
duke
parents:
diff changeset
974 protected String genSafepointInfo(NMethod nm, PCDesc pcDesc) {
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
975 ScopeDesc sd = nm.getScopeDescAt(pcDesc.getRealPC(nm));
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
976 Formatter buf = new Formatter(genHTML);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
977 Formatter tabs = new Formatter(genHTML);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
978 tabs.append(tab + tab + tab); // Initial indent for debug info
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
979
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
980 buf.beginTag("pre");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
981 genScope(buf, tabs, sd);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
982
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
983 // Reset indent for scalar replaced objects
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
984 tabs = new Formatter(genHTML);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
985 tabs.append(tab + tab + tab); // Initial indent for debug info
0
a61af66fc99e Initial load
duke
parents:
diff changeset
986
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
987 genScObjInfo(buf, tabs, sd);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
988 buf.endTag("pre");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
989
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
990 buf.append(genOopMapInfo(nm, pcDesc));
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
991
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
992 return buf.toString();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
993 }
a61af66fc99e Initial load
duke
parents:
diff changeset
994
a61af66fc99e Initial load
duke
parents:
diff changeset
995 protected void genScope(Formatter buf, Formatter tabs, ScopeDesc sd) {
a61af66fc99e Initial load
duke
parents:
diff changeset
996 if (sd == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
997 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
998 }
a61af66fc99e Initial load
duke
parents:
diff changeset
999
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 genScope(buf, tabs, sd.sender());
a61af66fc99e Initial load
duke
parents:
diff changeset
1001
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 buf.append(tabs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 Method m = sd.getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 buf.append(genMethodAndKlassLink(m));
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 int bci = sd.getBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 buf.append(" @ bci = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 buf.append(Integer.toString(bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
1008
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 int line = m.getLineNumberFromBCI(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 if (line != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 buf.append(", line = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 buf.append(Integer.toString(line));
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1014
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 List locals = sd.getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 if (locals != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 buf.append(tabs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 buf.append(genHTMLForLocals(sd, locals));
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1021
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 List expressions = sd.getExpressions();
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 if (expressions != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 buf.append(tabs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 buf.append(genHTMLForExpressions(sd, expressions));
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1028
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 List monitors = sd.getMonitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 if (monitors != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 buf.append(tabs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 buf.append(genHTMLForMonitors(sd, monitors));
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1035
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1036 buf.br();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 tabs.append(tab);
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1038 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1039
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1040 protected void genScObjInfo(Formatter buf, Formatter tabs, ScopeDesc sd) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1041 if (sd == null) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1042 return;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1043 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1044
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1045 List objects = sd.getObjects();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1046 if (objects == null) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1047 return;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1048 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1049 int length = objects.size();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1050 for (int i = 0; i < length; i++) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1051 buf.append(tabs);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1052 ObjectValue ov = (ObjectValue)objects.get(i);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1053 buf.append("ScObj" + i);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1054 ScopeValue sv = ov.getKlass();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1055 if (Assert.ASSERTS_ENABLED) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1056 Assert.that(sv.isConstantOop(), "scalar replaced object klass must be constant oop");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1057 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1058 ConstantOopReadValue klv = (ConstantOopReadValue)sv;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1059 OopHandle klHandle = klv.getValue();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1060 if (Assert.ASSERTS_ENABLED) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1061 Assert.that(klHandle != null, "scalar replaced object klass must be not NULL");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1062 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1063 Oop obj = VM.getVM().getObjectHeap().newOop(klHandle);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1064 if (obj instanceof InstanceKlass) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1065 InstanceKlass kls = (InstanceKlass) obj;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1066 buf.append(" " + kls.getName().asString() + "={");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1067 int flen = ov.fieldsSize();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1068
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1069 TypeArray klfields = kls.getFields();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1070 int klen = (int) klfields.getLength();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1071
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1072 ConstantPool cp = kls.getConstants();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1073 int findex = 0;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1074 for (int index = 0; index < klen; index += kls.NEXT_OFFSET) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1075 int accsFlags = klfields.getShortAt(index + kls.ACCESS_FLAGS_OFFSET);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1076 int nameIndex = klfields.getShortAt(index + kls.NAME_INDEX_OFFSET);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1077 AccessFlags access = new AccessFlags(accsFlags);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1078 if (!access.isStatic()) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1079 ScopeValue svf = ov.getFieldAt(findex++);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1080 String fstr = scopeValueAsString(sd, svf);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1081 Symbol f_name = cp.getSymbolAt(nameIndex);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1082 buf.append(" [" + f_name.asString() + " :"+ index + "]=(#" + fstr + ")");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1083 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1084 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1085 buf.append(" }");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1086 } else {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1087 buf.append(" ");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1088 int flen = ov.fieldsSize();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1089 if (obj instanceof TypeArrayKlass) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1090 TypeArrayKlass kls = (TypeArrayKlass) obj;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1091 buf.append(kls.getElementTypeName() + "[" + flen + "]");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1092 } else if (obj instanceof ObjArrayKlass) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1093 ObjArrayKlass kls = (ObjArrayKlass) obj;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1094 Klass elobj = kls.getBottomKlass();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1095 if (elobj instanceof InstanceKlass) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1096 buf.append(elobj.getName().asString());
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1097 } else if (elobj instanceof TypeArrayKlass) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1098 TypeArrayKlass elkls = (TypeArrayKlass) elobj;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1099 buf.append(elkls.getElementTypeName());
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1100 } else {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1101 if (Assert.ASSERTS_ENABLED) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1102 Assert.that(false, "unknown scalar replaced object klass!");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1103 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1104 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1105 buf.append("[" + flen + "]");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1106 int ndim = (int) kls.getDimension();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1107 while (--ndim > 0) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1108 buf.append("[]");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1109 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1110 } else {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1111 if (Assert.ASSERTS_ENABLED) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1112 Assert.that(false, "unknown scalar replaced object klass!");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1113 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1114 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1115 buf.append("={");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1116 for (int findex = 0; findex < flen; findex++) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1117 ScopeValue svf = ov.getFieldAt(findex);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1118 String fstr = scopeValueAsString(sd, svf);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1119 buf.append(" [" + findex + "]=(#" + fstr + ")");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1120 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1121 buf.append(" }");
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1122 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1123 buf.br();
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1124 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1126
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 protected String genHTMLForOopMap(OopMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 final int stack0 = VMRegImpl.getStack0().getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1130
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 final class OopMapValueIterator {
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 final Formatter iterate(OopMapStream oms, String type, boolean printContentReg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 Formatter tmpBuf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 boolean found = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 tmpBuf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
1136 tmpBuf.beginTag("td");
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 tmpBuf.append(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 for (; ! oms.isDone(); oms.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 OopMapValue omv = oms.getCurrent();
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 if (omv == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 found = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 VMReg vmReg = omv.getReg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 int reg = vmReg.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1146 if (reg < stack0) {
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1147 tmpBuf.append(VMRegImpl.getRegisterName(reg));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 tmpBuf.append('[');
a61af66fc99e Initial load
duke
parents:
diff changeset
1150 tmpBuf.append(Integer.toString((reg - stack0) * 4));
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 tmpBuf.append(']');
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 if (printContentReg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 tmpBuf.append(" = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1155 VMReg vmContentReg = omv.getContentReg();
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 int contentReg = vmContentReg.getValue();
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1157 if (contentReg < stack0) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1158 tmpBuf.append(VMRegImpl.getRegisterName(contentReg));
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1159 } else {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1160 tmpBuf.append('[');
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1161 tmpBuf.append(Integer.toString((contentReg - stack0) * 4));
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1162 tmpBuf.append(']');
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1163 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1165 tmpBuf.append(spaces);
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 tmpBuf.endTag("td");
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 tmpBuf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 return found ? tmpBuf : new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1172
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 buf.beginTable(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1174
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 OopMapValueIterator omvIterator = new OopMapValueIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 OopMapStream oms = new OopMapStream(map, OopMapValue.OopTypes.OOP_VALUE);
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1177 buf.append(omvIterator.iterate(oms, "Oops:", false));
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1178
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1179 oms = new OopMapStream(map, OopMapValue.OopTypes.NARROWOOP_VALUE);
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1180 buf.append(omvIterator.iterate(oms, "narrowOops:", false));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1181
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 oms = new OopMapStream(map, OopMapValue.OopTypes.VALUE_VALUE);
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1183 buf.append(omvIterator.iterate(oms, "Values:", false));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1184
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 oms = new OopMapStream(map, OopMapValue.OopTypes.CALLEE_SAVED_VALUE);
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 buf.append(omvIterator.iterate(oms, "Callee saved:", true));
a61af66fc99e Initial load
duke
parents:
diff changeset
1187
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 oms = new OopMapStream(map, OopMapValue.OopTypes.DERIVED_OOP_VALUE);
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1189 buf.append(omvIterator.iterate(oms, "Derived oops:", true));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1190
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 buf.endTag("table");
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1194
a61af66fc99e Initial load
duke
parents:
diff changeset
1195
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 protected String genOopMapInfo(NMethod nmethod, PCDesc pcDesc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 OopMapSet mapSet = nmethod.getOopMaps();
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1198 if (mapSet == null || (mapSet.getSize() <= 0))
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1199 return "";
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 int pcOffset = pcDesc.getPCOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 OopMap map = mapSet.findMapAtOffset(pcOffset, VM.getVM().isDebugging());
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 if (map == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 throw new IllegalArgumentException("no oopmap at safepoint!");
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1205
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 return genOopMapInfo(map);
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1208
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 protected String genOopMapInfo(OopMap map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 buf.beginTag("pre");
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 buf.append("OopMap: ");
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1213 buf.br();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 buf.append(genHTMLForOopMap(map));
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 buf.endTag("pre");
a61af66fc99e Initial load
duke
parents:
diff changeset
1216
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1219
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 protected String locationAsString(Location loc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1222 if (loc.isIllegal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 buf.append("illegal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 Location.Where w = loc.getWhere();
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 Location.Type type = loc.getType();
a61af66fc99e Initial load
duke
parents:
diff changeset
1227
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 if (w == Location.Where.ON_STACK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 buf.append("stack[" + loc.getStackOffset() + "]");
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 } else if (w == Location.Where.IN_REGISTER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 boolean isFloat = (type == Location.Type.FLOAT_IN_DBL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 type == Location.Type.DBL);
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 int regNum = loc.getRegisterNumber();
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 VMReg vmReg = new VMReg(regNum);
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 buf.append(VMRegImpl.getRegisterName(vmReg.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1237
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 buf.append(", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 if (type == Location.Type.NORMAL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 buf.append("normal");
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 } else if (type == Location.Type.OOP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 buf.append("oop");
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 196
diff changeset
1243 } else if (type == Location.Type.NARROWOOP) {
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 196
diff changeset
1244 buf.append("narrowoop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 } else if (type == Location.Type.INT_IN_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 buf.append("int");
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 } else if (type == Location.Type.LNG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 buf.append("long");
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 } else if (type == Location.Type.FLOAT_IN_DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 buf.append("float");
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 } else if (type == Location.Type.DBL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 buf.append("double");
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 } else if (type == Location.Type.ADDR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 buf.append("address");
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 } else if (type == Location.Type.INVALID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 buf.append("invalid");
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1261
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1262 private String scopeValueAsString(ScopeDesc sd, ScopeValue sv) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 if (sv.isConstantInt()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 buf.append("int ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 ConstantIntValue intValue = (ConstantIntValue) sv;
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 buf.append(Integer.toString(intValue.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 } else if (sv.isConstantLong()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 buf.append("long ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 ConstantLongValue longValue = (ConstantLongValue) sv;
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 buf.append(Long.toString(longValue.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 buf.append("L");
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 } else if (sv.isConstantDouble()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 buf.append("double ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 ConstantDoubleValue dblValue = (ConstantDoubleValue) sv;
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 buf.append(Double.toString(dblValue.getValue()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 buf.append("D");
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 } else if (sv.isConstantOop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 buf.append("oop ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 ConstantOopReadValue oopValue = (ConstantOopReadValue) sv;
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 OopHandle oopHandle = oopValue.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 if (oopHandle != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 buf.append(oopHandle.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 buf.append("null");
a61af66fc99e Initial load
duke
parents:
diff changeset
1286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 } else if (sv.isLocation()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1288 LocationValue lvalue = (LocationValue) sv;
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 Location loc = lvalue.getLocation();
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 if (loc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 buf.append(locationAsString(loc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 buf.append("null");
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 }
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1295 } else if (sv.isObject()) {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1296 ObjectValue ov = (ObjectValue)sv;
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1297 buf.append("#ScObj" + sd.getObjects().indexOf(ov));
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1298 } else {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1299 buf.append("unknown scope value " + sv);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1303
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 protected String genHTMLForScopeValues(ScopeDesc sd, boolean locals, List values) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 int length = values.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 buf.append(locals? "locals " : "expressions ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 for (int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 ScopeValue sv = (ScopeValue) values.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 if (sv == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 buf.append('(');
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 if (locals) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 Symbol name = sd.getMethod().getLocalVariableName(sd.getBCI(), i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 if (name != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 buf.append("'");
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 buf.append(name.asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 buf.append('\'');
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 buf.append("[");
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 buf.append(Integer.toString(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 buf.append(']');
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1325 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 buf.append("[");
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 buf.append(Integer.toString(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 buf.append(']');
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1330
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 buf.append(", ");
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1332 buf.append(scopeValueAsString(sd, sv));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1333 buf.append(") ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1335
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1338
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 protected String genHTMLForLocals(ScopeDesc sd, List locals) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1340 return genHTMLForScopeValues(sd, true, locals);
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1342
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 protected String genHTMLForExpressions(ScopeDesc sd, List expressions) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 return genHTMLForScopeValues(sd, false, expressions);
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1346
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 protected String genHTMLForMonitors(ScopeDesc sd, List monitors) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 int length = monitors.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 buf.append("monitors ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 for (int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 MonitorValue mv = (MonitorValue) monitors.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 if (mv == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 buf.append("(owner = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 ScopeValue owner = mv.owner();
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 if (owner != null) {
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1359 buf.append(scopeValueAsString(sd, owner));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 buf.append("null");
a61af66fc99e Initial load
duke
parents:
diff changeset
1362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 buf.append(", lock = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1364
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 Location loc = mv.basicLock();
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 if (loc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 buf.append(locationAsString(loc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 buf.append("null");
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 buf.append(") ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1375
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 public String genHTML(final NMethod nmethod) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 final Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 buf.genHTMLPrologue(genNMethodTitle(nmethod));
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 buf.h3("Method");
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 buf.append(genMethodAndKlassLink(nmethod.getMethod()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1382
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 buf.h3("Compiled Code");
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 sun.jvm.hotspot.debugger.Address codeBegin = nmethod.codeBegin();
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 sun.jvm.hotspot.debugger.Address codeEnd = nmethod.codeEnd();
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 final int codeSize = (int)codeEnd.minus(codeBegin);
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 final long startPc = addressToLong(codeBegin);
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 final byte[] code = new byte[codeSize];
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 for (int i=0; i < code.length; i++)
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 code[i] = codeBegin.getJByteAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1391
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 final long verifiedEntryPoint = addressToLong(nmethod.getVerifiedEntryPoint());
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 final long entryPoint = addressToLong(nmethod.getEntryPoint());
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 final Map safepoints = nmethod.getSafepoints();
a61af66fc99e Initial load
duke
parents:
diff changeset
1395
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 final SymbolFinder symFinder = createSymbolFinder();
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 final Disassembler disasm = createDisassembler(startPc, code);
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 class NMethodVisitor implements InstructionVisitor {
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 boolean prevWasCall;
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 public void prologue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 prevWasCall = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1403
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 public void visit(long currentPc, Instruction instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 String href = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 if (instr.isCall()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 CallInstruction call = (CallInstruction) instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 sun.jvm.hotspot.asm.Address addr = call.getBranchDestination();
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 href = genPCHref(currentPc, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1411
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 if (currentPc == verifiedEntryPoint) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 buf.bold("Verified Entry Point"); buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 if (currentPc == entryPoint) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 buf.bold(">Entry Point"); buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1418
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 PCDesc pcDesc = (PCDesc) safepoints.get(longToAddress(currentPc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1420
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 boolean isSafepoint = (pcDesc != null);
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 if (isSafepoint && prevWasCall) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 buf.append(genSafepointInfo(nmethod, pcDesc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1425
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 buf.append("0x");
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 buf.append(Long.toHexString(currentPc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 buf.append(':');
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 buf.append(tab);
a61af66fc99e Initial load
duke
parents:
diff changeset
1430
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 if (href != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 buf.link(href, instr.asString(currentPc, symFinder));
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 buf.append(instr.asString(currentPc, symFinder));
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1436
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1437 buf.br();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 if (isSafepoint && !prevWasCall) {
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 331
diff changeset
1439 buf.append(genSafepointInfo(nmethod, pcDesc));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1441
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 prevWasCall = instr.isCall();
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1444
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 public void epilogue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1448
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 disasm.decode(new NMethodVisitor());
a61af66fc99e Initial load
duke
parents:
diff changeset
1450
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 sun.jvm.hotspot.debugger.Address stubBegin = nmethod.stubBegin();
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 if (stubBegin != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 sun.jvm.hotspot.debugger.Address stubEnd = nmethod.stubEnd();
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 buf.h3("Stub");
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 long stubStartPc = addressToLong(stubBegin);
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 long stubEndPc = addressToLong(stubEnd);
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 int range = (int) (stubEndPc - stubStartPc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 byte[] stubCode = readBuffer(stubBegin, range);
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 Disassembler disasm2 = createDisassembler(stubStartPc, stubCode);
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 disasm2.decode(new NMethodVisitor());
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1468
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 public String genHTML(final CodeBlob blob) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 final Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 buf.genHTMLPrologue(genCodeBlobTitle(blob));
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 buf.h3("CodeBlob");
a61af66fc99e Initial load
duke
parents:
diff changeset
1474
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 buf.h3("Compiled Code");
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 final sun.jvm.hotspot.debugger.Address codeBegin = blob.instructionsBegin();
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 final int codeSize = blob.getInstructionsSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 final long startPc = addressToLong(codeBegin);
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 final byte[] code = new byte[codeSize];
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 for (int i=0; i < code.length; i++)
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 code[i] = codeBegin.getJByteAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1482
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 final SymbolFinder symFinder = createSymbolFinder();
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 final Disassembler disasm = createDisassembler(startPc, code);
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 class CodeBlobVisitor implements InstructionVisitor {
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 OopMapSet maps;
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 OopMap curMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 int curMapIndex;
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 long curMapOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 public void prologue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 maps = blob.getOopMaps();
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 if (maps != null && (maps.getSize() > 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 curMap = maps.getMapAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 if (curMap != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 curMapOffset = curMap.getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1499
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 public void visit(long currentPc, Instruction instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 String href = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 if (instr.isCall()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 CallInstruction call = (CallInstruction) instr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 sun.jvm.hotspot.asm.Address addr = call.getBranchDestination();
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 href = genPCHref(currentPc, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1507
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 buf.append("0x");
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 buf.append(Long.toHexString(currentPc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 buf.append(':');
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 buf.append(tab);
a61af66fc99e Initial load
duke
parents:
diff changeset
1512
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 if (href != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 buf.link(href, instr.asString(currentPc, symFinder));
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 buf.append(instr.asString(currentPc, symFinder));
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1519
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 // See whether we have an oop map at this PC
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 if (curMap != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1522 long curOffset = currentPc - startPc;
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 if (curOffset == curMapOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 buf.append(genOopMapInfo(curMap));
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 if (++curMapIndex >= maps.getSize()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 curMap = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 curMap = maps.getMapAt(curMapIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 if (curMap != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 curMapOffset = curMap.getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1536
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 public void epilogue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1540
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 disasm.decode(new CodeBlobVisitor());
a61af66fc99e Initial load
duke
parents:
diff changeset
1542
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1549
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 protected String genInterpreterCodeletTitle(InterpreterCodelet codelet) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1552 buf.append("Interpreter codelet [");
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 buf.append(codelet.codeBegin().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
1554 buf.append(',');
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 buf.append(codelet.codeEnd().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 buf.append(") - ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 buf.append(codelet.getDescription());
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1560
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 protected String genInterpreterCodeletLinkPageHref(StubQueue stubq) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 return genBaseHref() + "interp_codelets";
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1564
a61af66fc99e Initial load
duke
parents:
diff changeset
1565 public String genInterpreterCodeletLinksPage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 buf.genHTMLPrologue("Interpreter Codelets");
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 buf.beginTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
1569
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 Interpreter interp = VM.getVM().getInterpreter();
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 StubQueue code = interp.getCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 InterpreterCodelet stub = (InterpreterCodelet) code.getFirst();
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 while (stub != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 buf.beginTag("li");
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 sun.jvm.hotspot.debugger.Address addr = stub.codeBegin();
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 buf.link(genPCHref(addressToLong(addr)), stub.getDescription() + " @" + addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 buf.endTag("li");
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 stub = (InterpreterCodelet) code.getNext(stub);
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1580
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 buf.endTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1585
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 public String genHTML(InterpreterCodelet codelet) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 buf.genHTMLPrologue(genInterpreterCodeletTitle(codelet));
a61af66fc99e Initial load
duke
parents:
diff changeset
1589 Interpreter interp = VM.getVM().getInterpreter();
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 StubQueue stubq = interp.getCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
1591
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 if (genHTML) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1593 buf.beginTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 buf.link(genInterpreterCodeletLinkPageHref(stubq), "View links for all codelets");
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 buf.endTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1598
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 Stub prev = stubq.getPrev(codelet);
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 if (prev != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 if (genHTML) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 buf.beginTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 buf.link(genPCHref(addressToLong(prev.codeBegin())), "View Previous Codelet");
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 buf.endTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 buf.h3("Previous Codelet = 0x" + Long.toHexString(addressToLong(prev.codeBegin())));
a61af66fc99e Initial load
duke
parents:
diff changeset
1608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1610
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 buf.h3("Code");
a61af66fc99e Initial load
duke
parents:
diff changeset
1612 long stubStartPc = addressToLong(codelet.codeBegin());
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 long stubEndPc = addressToLong(codelet.codeEnd());
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 int range = (int) (stubEndPc - stubStartPc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 byte[] stubCode = readBuffer(codelet.codeBegin(), range);
a61af66fc99e Initial load
duke
parents:
diff changeset
1616 Disassembler disasm = createDisassembler(stubStartPc, stubCode);
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 disasm.decode(new RawCodeVisitor(buf));
a61af66fc99e Initial load
duke
parents:
diff changeset
1618
a61af66fc99e Initial load
duke
parents:
diff changeset
1619
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 Stub next = stubq.getNext(codelet);
a61af66fc99e Initial load
duke
parents:
diff changeset
1621 if (next != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 if (genHTML) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 buf.beginTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 buf.link(genPCHref(addressToLong(next.codeBegin())), "View Next Codelet");
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 buf.endTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1626 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 buf.h3("Next Codelet = 0x" + Long.toHexString(addressToLong(next.codeBegin())));
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1630
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1634
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 protected String genDumpKlassesTitle(InstanceKlass[] klasses) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 return (klasses.length == 1) ? "Create .class for this class"
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 : "Create .class for all classes";
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1639
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 protected String genDumpKlassesHref(InstanceKlass[] klasses) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 StringBuffer buf = new StringBuffer(genBaseHref());
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 buf.append("jcore_multiple=");
a61af66fc99e Initial load
duke
parents:
diff changeset
1643 for (int k = 0; k < klasses.length; k++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 buf.append(klasses[k].getHandle().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 buf.append(',');
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1647 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1649
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 protected String genDumpKlassesLink(InstanceKlass[] klasses) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1651 if (!genHTML) return "";
a61af66fc99e Initial load
duke
parents:
diff changeset
1652
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 buf.link(genDumpKlassesHref(klasses), genDumpKlassesTitle(klasses));
a61af66fc99e Initial load
duke
parents:
diff changeset
1655 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1657
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 public String genHTMLForKlassNames(InstanceKlass[] klasses) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1659 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 buf.genHTMLPrologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 buf.h3(genDumpKlassesLink(klasses));
a61af66fc99e Initial load
duke
parents:
diff changeset
1663
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 buf.append(genHTMLListForKlassNames(klasses));
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1668 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1671
a61af66fc99e Initial load
duke
parents:
diff changeset
1672 protected String genHTMLListForKlassNames(InstanceKlass[] klasses) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 final Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 buf.beginTable(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 for (int i = 0; i < klasses.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1676 InstanceKlass ik = klasses[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 buf.beginTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 buf.cell(genKlassLink(ik));
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 buf.endTag("tr");
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1681
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 buf.endTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1685
a61af66fc99e Initial load
duke
parents:
diff changeset
1686 public String genHTMLForMethodNames(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 buf.genHTMLPrologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1690 buf.append(genHTMLListForMethods(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1692 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1697
a61af66fc99e Initial load
duke
parents:
diff changeset
1698 protected String genHTMLListForMethods(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 ObjArray methods = klass.getMethods();
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 int numMethods = (int) methods.getLength();
a61af66fc99e Initial load
duke
parents:
diff changeset
1702 if (numMethods != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 buf.h3("Methods");
a61af66fc99e Initial load
duke
parents:
diff changeset
1704 buf.beginTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 for (int m = 0; m < numMethods; m++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 Method mtd = (Method) methods.getObjAt(m);
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 buf.li(genMethodLink(mtd) + ";");
a61af66fc99e Initial load
duke
parents:
diff changeset
1708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 buf.endTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1713
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 protected String genHTMLListForInterfaces(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1717 ObjArray interfaces = klass.getLocalInterfaces();
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 int numInterfaces = (int) interfaces.getLength();
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 if (numInterfaces != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 buf.h3("Interfaces");
a61af66fc99e Initial load
duke
parents:
diff changeset
1721 buf.beginTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
1722 for (int i = 0; i < numInterfaces; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1723 InstanceKlass inf = (InstanceKlass) interfaces.getObjAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 buf.li(genKlassLink(inf));
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 buf.endTag("ul");
a61af66fc99e Initial load
duke
parents:
diff changeset
1727 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1729 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1733
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 protected String genFieldModifierString(AccessFlags acc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 if (acc.isPrivate()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 buf.append("private ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1738 } else if (acc.isProtected()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 buf.append("protected ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 } else if (acc.isPublic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 buf.append("public ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1743
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 if (acc.isStatic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 buf.append("static ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1747
a61af66fc99e Initial load
duke
parents:
diff changeset
1748 if (acc.isFinal()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 buf.append("final ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 if (acc.isVolatile()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1752 buf.append("volatile ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 if (acc.isTransient()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 buf.append("transient ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1756 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1757
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 // javac generated flags
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 if (acc.isSynthetic()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 buf.append("[synthetic] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1761 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1764
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 public String genHTMLForFieldNames(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1766 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 buf.genHTMLPrologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 buf.append(genHTMLListForFields(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1770 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1771 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1776
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 protected String genHTMLListForFields(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 TypeArray fields = klass.getFields();
a61af66fc99e Initial load
duke
parents:
diff changeset
1780 int numFields = (int) fields.getLength();
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 ConstantPool cp = klass.getConstants();
a61af66fc99e Initial load
duke
parents:
diff changeset
1782 if (numFields != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 buf.h3("Fields");
a61af66fc99e Initial load
duke
parents:
diff changeset
1784 buf.beginList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 int nameIndex = fields.getShortAt(f + InstanceKlass.NAME_INDEX_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 int sigIndex = fields.getShortAt(f + InstanceKlass.SIGNATURE_INDEX_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 int genSigIndex = fields.getShortAt(f + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
1789 Symbol f_name = cp.getSymbolAt(nameIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 Symbol f_sig = cp.getSymbolAt(sigIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 Symbol f_genSig = (genSigIndex != 0)? cp.getSymbolAt(genSigIndex) : null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 AccessFlags acc = new AccessFlags(fields.getShortAt(f + InstanceKlass.ACCESS_FLAGS_OFFSET));
a61af66fc99e Initial load
duke
parents:
diff changeset
1793
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 buf.beginTag("li");
a61af66fc99e Initial load
duke
parents:
diff changeset
1795 buf.append(genFieldModifierString(acc));
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 buf.append(' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 Formatter sigBuf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 new SignatureConverter(f_sig, sigBuf.getBuffer()).dispatchField();
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 buf.append(sigBuf.toString().replace('/', '.'));
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 buf.append(' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 buf.append(f_name.asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 buf.append(';');
a61af66fc99e Initial load
duke
parents:
diff changeset
1803 // is it generic?
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 if (f_genSig != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 buf.append(" [signature ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 buf.append(escapeHTMLSpecialChars(f_genSig.asString()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1807 buf.append("] ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 buf.endTag("li");
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 buf.endList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1815
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 protected String genKlassHierarchyHref(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1817 return genBaseHref() + "hierarchy=" + klass.getHandle();
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1819
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 protected String genKlassHierarchyTitle(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1821 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 buf.append("Class Hierarchy of ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 buf.append(genKlassTitle(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1825 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1826
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 protected String genKlassHierarchyLink(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 buf.link(genKlassHierarchyHref(klass), genKlassHierarchyTitle(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1830 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1832
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 protected String genHTMLListForSubKlasses(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1835 Klass subklass = klass.getSubklassKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 if (subklass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 buf.beginList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 while (subklass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 if (subklass instanceof InstanceKlass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1840 buf.li(genKlassLink((InstanceKlass)subklass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1842 subklass = subklass.getNextSiblingKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1844 buf.endList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1848
a61af66fc99e Initial load
duke
parents:
diff changeset
1849 public String genHTMLForKlassHierarchy(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1851 buf.genHTMLPrologue(genKlassHierarchyTitle(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1852
a61af66fc99e Initial load
duke
parents:
diff changeset
1853
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 buf.beginTag("pre");
a61af66fc99e Initial load
duke
parents:
diff changeset
1855 buf.append(genKlassLink(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1857 StringBuffer tabs = new StringBuffer(tab);
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 InstanceKlass superKlass = klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 while ( (superKlass = (InstanceKlass) superKlass.getSuper()) != null ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 buf.append(tabs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1861 buf.append(genKlassLink(superKlass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 tabs.append(tab);
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 buf.endTag("pre");
a61af66fc99e Initial load
duke
parents:
diff changeset
1866
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 // generate subklass list
a61af66fc99e Initial load
duke
parents:
diff changeset
1868 Klass subklass = klass.getSubklassKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
1869 if (subklass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 buf.h3("Direct Subclasses");
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 buf.append(genHTMLListForSubKlasses(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1873
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1877
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 protected String genDumpKlassHref(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 return genBaseHref() + "jcore=" + klass.getHandle();
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1881
a61af66fc99e Initial load
duke
parents:
diff changeset
1882 protected String genDumpKlassLink(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 if (!genHTML) return "";
a61af66fc99e Initial load
duke
parents:
diff changeset
1884
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 buf.link(genDumpKlassHref(klass), "Create .class File");
a61af66fc99e Initial load
duke
parents:
diff changeset
1887 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1888 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1889
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 public String genHTML(InstanceKlass klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 buf.genHTMLPrologue(genKlassTitle(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 InstanceKlass superKlass = (InstanceKlass) klass.getSuper();
a61af66fc99e Initial load
duke
parents:
diff changeset
1894
a61af66fc99e Initial load
duke
parents:
diff changeset
1895 if (genHTML) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 // super class tree and subclass list
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 buf.beginTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 buf.link(genKlassHierarchyHref(klass), "View Class Hierarchy");
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 buf.endTag("h3");
a61af66fc99e Initial load
duke
parents:
diff changeset
1900 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1901
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 // jcore - create .class link
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 buf.h3(genDumpKlassLink(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1904
a61af66fc99e Initial load
duke
parents:
diff changeset
1905 // super class
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 if (superKlass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 buf.h3("Super Class");
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 buf.append(genKlassLink(superKlass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1909 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1910
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 // interfaces
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 buf.append(genHTMLListForInterfaces(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1913
a61af66fc99e Initial load
duke
parents:
diff changeset
1914 // fields
a61af66fc99e Initial load
duke
parents:
diff changeset
1915 buf.append(genHTMLListForFields(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1916
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 // methods
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 buf.append(genHTMLListForMethods(klass));
a61af66fc99e Initial load
duke
parents:
diff changeset
1919
a61af66fc99e Initial load
duke
parents:
diff changeset
1920 // constant pool link
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 buf.h3("Constant Pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 buf.append(genConstantPoolLink(klass.getConstants()));
a61af66fc99e Initial load
duke
parents:
diff changeset
1923
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1925 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1927
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 protected sun.jvm.hotspot.debugger.Address parseAddress(String address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 VM vm = VM.getVM();
a61af66fc99e Initial load
duke
parents:
diff changeset
1930 sun.jvm.hotspot.debugger.Address addr = vm.getDebugger().parseAddress(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
1932 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1933
a61af66fc99e Initial load
duke
parents:
diff changeset
1934 protected long addressToLong(sun.jvm.hotspot.debugger.Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1935 return VM.getVM().getDebugger().getAddressValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1937
a61af66fc99e Initial load
duke
parents:
diff changeset
1938 protected sun.jvm.hotspot.debugger.Address longToAddress(long addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 return parseAddress("0x" + Long.toHexString(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1941
a61af66fc99e Initial load
duke
parents:
diff changeset
1942 protected Oop getOopAtAddress(sun.jvm.hotspot.debugger.Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 OopHandle oopHandle = addr.addOffsetToAsOopHandle(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1944 return VM.getVM().getObjectHeap().newOop(oopHandle);
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1946
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 protected Oop getOopAtAddress(String address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 sun.jvm.hotspot.debugger.Address addr = parseAddress(address);
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 return getOopAtAddress(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1951
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 private void dumpKlass(InstanceKlass kls) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 String klassName = kls.getName().asString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 klassName = klassName.replace('/', File.separatorChar);
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 int index = klassName.lastIndexOf(File.separatorChar);
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 File dir = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1957 if (index != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 String dirName = klassName.substring(0, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 dir = new File(DUMP_KLASS_OUTPUT_DIR, dirName);
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 dir = new File(DUMP_KLASS_OUTPUT_DIR);
a61af66fc99e Initial load
duke
parents:
diff changeset
1962 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1963
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 dir.mkdirs();
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 File f = new File(dir, klassName.substring(klassName.lastIndexOf(File.separatorChar) + 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
1966 + ".class");
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 f.createNewFile();
a61af66fc99e Initial load
duke
parents:
diff changeset
1968 FileOutputStream fis = new FileOutputStream(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 ClassWriter cw = new ClassWriter(kls, fis);
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 cw.write();
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1972
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 public String genDumpKlass(InstanceKlass kls) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 dumpKlass(kls);
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 buf.genHTMLPrologue(genKlassTitle(kls));
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 buf.append(".class created for ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1979 buf.append(genKlassLink(kls));
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 } catch(IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 return genHTMLErrorMessage(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
1984 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1986
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 protected String genJavaStackTraceTitle(JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1988 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1989 buf.append("Java Stack Trace for ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 buf.append(thread.getThreadName());
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1993
a61af66fc99e Initial load
duke
parents:
diff changeset
1994 public String genHTMLForJavaStackTrace(JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
1996 buf.genHTMLPrologue(genJavaStackTraceTitle(thread));
a61af66fc99e Initial load
duke
parents:
diff changeset
1997
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 buf.append("Thread state = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1999 buf.append(thread.getThreadState().toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 buf.beginTag("pre");
a61af66fc99e Initial load
duke
parents:
diff changeset
2002 for (JavaVFrame vf = thread.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2003 Method method = vf.getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
2004 buf.append(" - ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 buf.append(genMethodLink(method));
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 buf.append(" @bci = " + vf.getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
2007
a61af66fc99e Initial load
duke
parents:
diff changeset
2008 int lineNumber = method.getLineNumberFromBCI(vf.getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
2009 if (lineNumber != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2010 buf.append(", line = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 buf.append(lineNumber);
a61af66fc99e Initial load
duke
parents:
diff changeset
2012 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2013
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 sun.jvm.hotspot.debugger.Address pc = vf.getFrame().getPC();
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 if (pc != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 buf.append(", pc = ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2017 buf.link(genPCHref(addressToLong(pc)), pc.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2019
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 if (vf.isCompiledFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2021 buf.append(" (Compiled");
a61af66fc99e Initial load
duke
parents:
diff changeset
2022 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 else if (vf.isInterpretedFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 buf.append(" (Interpreted");
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2026
a61af66fc99e Initial load
duke
parents:
diff changeset
2027 if (vf.mayBeImpreciseDbg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 buf.append("; information may be imprecise");
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 buf.append(")");
a61af66fc99e Initial load
duke
parents:
diff changeset
2031 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
2032 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2033
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 buf.endTag("pre");
a61af66fc99e Initial load
duke
parents:
diff changeset
2035 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
2037 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2038
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 public String genHTMLForHyperlink(String href) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 if (href.startsWith("klass=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 href = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 Oop obj = getOopAtAddress(href);
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2044 Assert.that(obj instanceof InstanceKlass, "class= href with improper InstanceKlass!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 return genHTML((InstanceKlass) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
2047 } else if (href.startsWith("method=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 href = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 Oop obj = getOopAtAddress(href);
a61af66fc99e Initial load
duke
parents:
diff changeset
2050 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 Assert.that(obj instanceof Method, "method= href with improper Method!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 return genHTML((Method) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 } else if (href.startsWith("nmethod=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 String addr = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 Object obj = VMObjectFactory.newObject(NMethod.class, parseAddress(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 Assert.that(obj instanceof NMethod, "nmethod= href with improper NMethod!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2059 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 return genHTML((NMethod) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
2061 } else if (href.startsWith("pc=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 String address = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 return genHTML(parseAddress(address));
a61af66fc99e Initial load
duke
parents:
diff changeset
2064 } else if (href.startsWith("pc_multiple=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 int indexOfComma = href.indexOf(',');
a61af66fc99e Initial load
duke
parents:
diff changeset
2066 if (indexOfComma == -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 String firstPC = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 return genHTMLForRawDisassembly(parseAddress(firstPC), null);
a61af66fc99e Initial load
duke
parents:
diff changeset
2069 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 String firstPC = href.substring(href.indexOf('=') + 1, indexOfComma);
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 return genHTMLForRawDisassembly(parseAddress(firstPC), href.substring(indexOfComma + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
2072 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 } else if (href.startsWith("interp_codelets")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2074 return genInterpreterCodeletLinksPage();
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 } else if (href.startsWith("hierarchy=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2076 href = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2077 Oop obj = getOopAtAddress(href);
a61af66fc99e Initial load
duke
parents:
diff changeset
2078 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 Assert.that(obj instanceof InstanceKlass, "class= href with improper InstanceKlass!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 return genHTMLForKlassHierarchy((InstanceKlass) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
2082 } else if (href.startsWith("cpool=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 href = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2084 Oop obj = getOopAtAddress(href);
a61af66fc99e Initial load
duke
parents:
diff changeset
2085 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2086 Assert.that(obj instanceof ConstantPool, "cpool= href with improper ConstantPool!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2088 return genHTML((ConstantPool) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 } else if (href.startsWith("jcore=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2090 href = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2091 Oop obj = getOopAtAddress(href);
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2093 Assert.that(obj instanceof InstanceKlass, "jcore= href with improper InstanceKlass!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2094 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 return genDumpKlass((InstanceKlass) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 } else if (href.startsWith("jcore_multiple=")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2097 href = href.substring(href.indexOf('=') + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
2098 Formatter buf = new Formatter(genHTML);
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 buf.genHTMLPrologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 StringTokenizer st = new StringTokenizer(href, ",");
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 while (st.hasMoreTokens()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 Oop obj = getOopAtAddress(st.nextToken());
a61af66fc99e Initial load
duke
parents:
diff changeset
2103 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2104 Assert.that(obj instanceof InstanceKlass, "jcore_multiple= href with improper InstanceKlass!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2106
a61af66fc99e Initial load
duke
parents:
diff changeset
2107 InstanceKlass kls = (InstanceKlass) obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 dumpKlass(kls);
a61af66fc99e Initial load
duke
parents:
diff changeset
2110 buf.append(".class created for ");
a61af66fc99e Initial load
duke
parents:
diff changeset
2111 buf.append(genKlassLink(kls));
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 } catch(Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 buf.bold("can't .class for " +
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 genKlassTitle(kls) +
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 " : " +
a61af66fc99e Initial load
duke
parents:
diff changeset
2116 exp.getMessage());
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 buf.br();
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2120
a61af66fc99e Initial load
duke
parents:
diff changeset
2121 buf.genHTMLEpilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 return buf.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
2123 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 Assert.that(false, "unknown href link!");
a61af66fc99e Initial load
duke
parents:
diff changeset
2126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2130 }