annotate agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 4ca6dc0799b6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14909
diff changeset
2 * Copyright (c) 2004, 2013, 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: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
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: 196
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.utilities;
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 sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
34 * This is abstract base class for heap graph writers. This class does
a61af66fc99e Initial load
duke
parents:
diff changeset
35 * not assume any file format for the heap graph. It hides heap
a61af66fc99e Initial load
duke
parents:
diff changeset
36 * iteration, object (fields) iteration mechanism from derived
a61af66fc99e Initial load
duke
parents:
diff changeset
37 * classes. This class does not even accept OutputStream etc. so that
a61af66fc99e Initial load
duke
parents:
diff changeset
38 * derived class can construct specific writer/filter from input
a61af66fc99e Initial load
duke
parents:
diff changeset
39 * stream.
a61af66fc99e Initial load
duke
parents:
diff changeset
40 */
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public abstract class AbstractHeapGraphWriter implements HeapGraphWriter {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // the function iterates heap and calls Oop type specific writers
a61af66fc99e Initial load
duke
parents:
diff changeset
44 protected void write() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 SymbolTable symTbl = VM.getVM().getSymbolTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
46 javaLangClass = symTbl.probe("java/lang/Class");
a61af66fc99e Initial load
duke
parents:
diff changeset
47 javaLangString = symTbl.probe("java/lang/String");
a61af66fc99e Initial load
duke
parents:
diff changeset
48 javaLangThread = symTbl.probe("java/lang/Thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
49 ObjectHeap heap = VM.getVM().getObjectHeap();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 heap.iterate(new DefaultHeapVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public void prologue(long usedSize) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 writeHeapHeader();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public boolean doObj(Oop oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 try {
12820
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
62 writeHeapRecordPrologue();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 if (oop instanceof TypeArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 writePrimitiveArray((TypeArray)oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 } else if (oop instanceof ObjArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 Klass klass = oop.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 ObjArrayKlass oak = (ObjArrayKlass) klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 Klass bottomType = oak.getBottomKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (bottomType instanceof InstanceKlass ||
a61af66fc99e Initial load
duke
parents:
diff changeset
70 bottomType instanceof TypeArrayKlass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 writeObjectArray((ObjArray)oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 writeInternalObject(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 } else if (oop instanceof Instance) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Instance instance = (Instance) oop;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 Klass klass = instance.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 Symbol name = klass.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 if (name.equals(javaLangString)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 writeString(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 } else if (name.equals(javaLangClass)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 writeClass(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 } else if (name.equals(javaLangThread)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 writeThread(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 klass = klass.getSuper();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 while (klass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 name = klass.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if (name.equals(javaLangThread)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 writeThread(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 klass = klass.getSuper();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // not-a-Java-visible oop
a61af66fc99e Initial load
duke
parents:
diff changeset
99 writeInternalObject(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
12820
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
101 writeHeapRecordEpilogue();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 public void epilogue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 writeHeapFooter();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 });
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // write JavaThreads
a61af66fc99e Initial load
duke
parents:
diff changeset
118 writeJavaThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // write JNI global handles
a61af66fc99e Initial load
duke
parents:
diff changeset
121 writeGlobalJNIHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 } catch (RuntimeException re) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 handleRuntimeException(re);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 protected void writeJavaThreads() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 Threads threads = VM.getVM().getThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 JavaThread jt = threads.first();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 int index = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 while (jt != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (jt.getThreadObj() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Note that the thread serial number range is 1-to-N
a61af66fc99e Initial load
duke
parents:
diff changeset
135 writeJavaThread(jt, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 jt = jt.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 protected void writeJavaThread(JavaThread jt, int index)
a61af66fc99e Initial load
duke
parents:
diff changeset
143 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 protected void writeGlobalJNIHandles() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 JNIHandles handles = VM.getVM().getJNIHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
148 JNIHandleBlock blk = handles.globalHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
149 if (blk != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 blk.oopsDo(new AddressVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public void visitAddress(Address handleAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (handleAddr != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 writeGlobalJNIHandle(handleAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
161 public void visitCompOopAddress(Address handleAddr) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
162 throw new RuntimeException("Should not reach here. JNIHandles are not compressed");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
163 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
164 });
a61af66fc99e Initial load
duke
parents:
diff changeset
165 } catch (RuntimeException re) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 handleRuntimeException(re);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 protected void writeGlobalJNIHandle(Address handleAddr) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 protected void writeHeapHeader() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // write non-Java-visible (hotspot internal) object
a61af66fc99e Initial load
duke
parents:
diff changeset
178 protected void writeInternalObject(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // write Java primitive array
a61af66fc99e Initial load
duke
parents:
diff changeset
182 protected void writePrimitiveArray(TypeArray array) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 writeObject(array);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // write Java object array
a61af66fc99e Initial load
duke
parents:
diff changeset
187 protected void writeObjectArray(ObjArray array) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 writeObject(array);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 protected void writeInstance(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 writeObject(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 protected void writeString(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 protected void writeClass(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 protected void writeThread(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 protected void writeObject(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 writeObjectHeader(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 writeObjectFields(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 writeObjectFooter(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 protected void writeObjectHeader(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // write instance fields of given object
a61af66fc99e Initial load
duke
parents:
diff changeset
217 protected void writeObjectFields(final Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 oop.iterate(new DefaultOopVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 public void doOop(OopField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 writeReferenceField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 public void doByte(ByteField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 writeByteField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 public void doChar(CharField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 writeCharField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public void doBoolean(BooleanField field, boolean vField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 writeBooleanField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 public void doShort(ShortField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 writeShortField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 public void doInt(IntField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 writeIntField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 public void doLong(LongField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 writeLongField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 public void doFloat(FloatField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 writeFloatField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
279 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282 }
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 public void doDouble(DoubleField field, boolean vField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 writeDoubleField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 } catch (RuntimeException re) {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 handleRuntimeException(re);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
297 // write instance fields of given object
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
298 protected void writeObjectFields(final InstanceKlass oop) throws IOException {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
299 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
300 oop.iterateStaticFields(new DefaultOopVisitor() {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
301 public void doOop(OopField field, boolean isVMField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
302 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
303 writeReferenceField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
304 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
305 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
306 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
309 public void doByte(ByteField field, boolean isVMField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
310 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
311 writeByteField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
312 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
313 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
314 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
315 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
316
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
317 public void doChar(CharField field, boolean isVMField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
318 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
319 writeCharField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
320 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
321 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
322 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
323 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
324
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
325 public void doBoolean(BooleanField field, boolean vField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
326 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
327 writeBooleanField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
328 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
329 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
330 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
331 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
332
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
333 public void doShort(ShortField field, boolean isVMField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
334 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
335 writeShortField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
336 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
337 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
338 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
339 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
340
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
341 public void doInt(IntField field, boolean isVMField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
342 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
343 writeIntField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
344 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
345 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
346 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
347 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
348
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
349 public void doLong(LongField field, boolean isVMField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
350 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
351 writeLongField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
352 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
353 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
354 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
355 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
356
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
357 public void doFloat(FloatField field, boolean isVMField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
358 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
359 writeFloatField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
360 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
361 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
362 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
363 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
364
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
365 public void doDouble(DoubleField field, boolean vField) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
366 try {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
367 writeDoubleField(null, field);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
368 } catch (IOException exp) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
369 throw new RuntimeException(exp);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
370 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
371 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
372 });
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
373 } catch (RuntimeException re) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
374 handleRuntimeException(re);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
375 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
376 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
377
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1552
diff changeset
378 // object field writers
0
a61af66fc99e Initial load
duke
parents:
diff changeset
379 protected void writeReferenceField(Oop oop, OopField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
380 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 protected void writeByteField(Oop oop, ByteField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
384 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 protected void writeCharField(Oop oop, CharField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
388 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 protected void writeBooleanField(Oop oop, BooleanField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
392 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 protected void writeShortField(Oop oop, ShortField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
396 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398
a61af66fc99e Initial load
duke
parents:
diff changeset
399 protected void writeIntField(Oop oop, IntField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
400 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 protected void writeLongField(Oop oop, LongField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
404 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 protected void writeFloatField(Oop oop, FloatField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
408 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 protected void writeDoubleField(Oop oop, DoubleField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
412 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 protected void writeObjectFooter(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 protected void writeHeapFooter() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
420
12820
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
421 protected void writeHeapRecordPrologue() throws IOException {
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
422 }
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
423
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
424 protected void writeHeapRecordEpilogue() throws IOException {
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
425 }
8ef918538e22 6313383: SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"
sla
parents: 6725
diff changeset
426
0
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // HeapVisitor, OopVisitor methods can't throw any non-runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // exception. But, derived class write methods (which are called
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // from visitor callbacks) may throw IOException. Hence, we throw
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // RuntimeException with origianal IOException as cause from the
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // visitor methods. This method gets back the original IOException
a61af66fc99e Initial load
duke
parents:
diff changeset
432 // (if any) and re-throws the same.
a61af66fc99e Initial load
duke
parents:
diff changeset
433 protected void handleRuntimeException(RuntimeException re)
a61af66fc99e Initial load
duke
parents:
diff changeset
434 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 Throwable cause = re.getCause();
a61af66fc99e Initial load
duke
parents:
diff changeset
436 if (cause != null && cause instanceof IOException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
437 throw (IOException) cause;
a61af66fc99e Initial load
duke
parents:
diff changeset
438 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // some other RuntimeException, just re-throw
a61af66fc99e Initial load
duke
parents:
diff changeset
440 throw re;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443
a61af66fc99e Initial load
duke
parents:
diff changeset
444 // whether a given oop is Java visible or hotspot internal?
a61af66fc99e Initial load
duke
parents:
diff changeset
445 protected boolean isJavaVisible(Oop oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 if (oop instanceof Instance || oop instanceof TypeArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
447 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
448 } else if (oop instanceof ObjArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 ObjArrayKlass oak = (ObjArrayKlass) oop.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
450 Klass bottomKlass = oak.getBottomKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
451 return bottomKlass instanceof InstanceKlass ||
a61af66fc99e Initial load
duke
parents:
diff changeset
452 bottomKlass instanceof TypeArrayKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
453 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
454 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 protected Symbol javaLangClass;
a61af66fc99e Initial load
duke
parents:
diff changeset
459 protected Symbol javaLangString;
a61af66fc99e Initial load
duke
parents:
diff changeset
460 protected Symbol javaLangThread;
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }