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

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