Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.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 | c18cbe5936b8 |
children | 8ef918538e22 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
2 * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
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 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.utilities; | |
26 | |
27 import java.io.*; | |
28 import sun.jvm.hotspot.debugger.*; | |
29 import sun.jvm.hotspot.memory.*; | |
30 import sun.jvm.hotspot.oops.*; | |
31 import sun.jvm.hotspot.runtime.*; | |
32 | |
33 /** | |
34 * This is abstract base class for heap graph writers. This class does | |
35 * not assume any file format for the heap graph. It hides heap | |
36 * iteration, object (fields) iteration mechanism from derived | |
37 * classes. This class does not even accept OutputStream etc. so that | |
38 * derived class can construct specific writer/filter from input | |
39 * stream. | |
40 */ | |
41 | |
42 public abstract class AbstractHeapGraphWriter implements HeapGraphWriter { | |
43 // the function iterates heap and calls Oop type specific writers | |
44 protected void write() throws IOException { | |
45 SymbolTable symTbl = VM.getVM().getSymbolTable(); | |
46 javaLangClass = symTbl.probe("java/lang/Class"); | |
47 javaLangString = symTbl.probe("java/lang/String"); | |
48 javaLangThread = symTbl.probe("java/lang/Thread"); | |
49 ObjectHeap heap = VM.getVM().getObjectHeap(); | |
50 try { | |
51 heap.iterate(new DefaultHeapVisitor() { | |
52 public void prologue(long usedSize) { | |
53 try { | |
54 writeHeapHeader(); | |
55 } catch (IOException exp) { | |
56 throw new RuntimeException(exp); | |
57 } | |
58 } | |
59 | |
60 public boolean doObj(Oop oop) { | |
61 try { | |
62 if (oop instanceof TypeArray) { | |
63 writePrimitiveArray((TypeArray)oop); | |
64 } else if (oop instanceof ObjArray) { | |
65 Klass klass = oop.getKlass(); | |
66 ObjArrayKlass oak = (ObjArrayKlass) klass; | |
67 Klass bottomType = oak.getBottomKlass(); | |
68 if (bottomType instanceof InstanceKlass || | |
69 bottomType instanceof TypeArrayKlass) { | |
70 writeObjectArray((ObjArray)oop); | |
71 } else { | |
72 writeInternalObject(oop); | |
73 } | |
74 } else if (oop instanceof Instance) { | |
75 Instance instance = (Instance) oop; | |
76 Klass klass = instance.getKlass(); | |
77 Symbol name = klass.getName(); | |
78 if (name.equals(javaLangString)) { | |
79 writeString(instance); | |
80 } else if (name.equals(javaLangClass)) { | |
81 writeClass(instance); | |
82 } else if (name.equals(javaLangThread)) { | |
83 writeThread(instance); | |
84 } else { | |
85 klass = klass.getSuper(); | |
86 while (klass != null) { | |
87 name = klass.getName(); | |
88 if (name.equals(javaLangThread)) { | |
89 writeThread(instance); | |
90 return false; | |
91 } | |
92 klass = klass.getSuper(); | |
93 } | |
94 writeInstance(instance); | |
95 } | |
96 } else { | |
97 // not-a-Java-visible oop | |
98 writeInternalObject(oop); | |
99 } | |
100 } catch (IOException exp) { | |
101 throw new RuntimeException(exp); | |
102 } | |
103 return false; | |
104 } | |
105 | |
106 public void epilogue() { | |
107 try { | |
108 writeHeapFooter(); | |
109 } catch (IOException exp) { | |
110 throw new RuntimeException(exp); | |
111 } | |
112 } | |
113 }); | |
114 | |
115 // write JavaThreads | |
116 writeJavaThreads(); | |
117 | |
118 // write JNI global handles | |
119 writeGlobalJNIHandles(); | |
120 | |
121 } catch (RuntimeException re) { | |
122 handleRuntimeException(re); | |
123 } | |
124 } | |
125 | |
126 protected void writeJavaThreads() throws IOException { | |
127 Threads threads = VM.getVM().getThreads(); | |
128 JavaThread jt = threads.first(); | |
129 int index = 1; | |
130 while (jt != null) { | |
131 if (jt.getThreadObj() != null) { | |
132 // Note that the thread serial number range is 1-to-N | |
133 writeJavaThread(jt, index); | |
134 index++; | |
135 } | |
136 jt = jt.next(); | |
137 } | |
138 } | |
139 | |
140 protected void writeJavaThread(JavaThread jt, int index) | |
141 throws IOException { | |
142 } | |
143 | |
144 protected void writeGlobalJNIHandles() throws IOException { | |
145 JNIHandles handles = VM.getVM().getJNIHandles(); | |
146 JNIHandleBlock blk = handles.globalHandles(); | |
147 if (blk != null) { | |
148 try { | |
149 blk.oopsDo(new AddressVisitor() { | |
150 public void visitAddress(Address handleAddr) { | |
151 try { | |
152 if (handleAddr != null) { | |
153 writeGlobalJNIHandle(handleAddr); | |
154 } | |
155 } catch (IOException exp) { | |
156 throw new RuntimeException(exp); | |
157 } | |
158 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
159 public void visitCompOopAddress(Address handleAddr) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
160 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
|
161 } |
0 | 162 }); |
163 } catch (RuntimeException re) { | |
164 handleRuntimeException(re); | |
165 } | |
166 } | |
167 } | |
168 | |
169 protected void writeGlobalJNIHandle(Address handleAddr) throws IOException { | |
170 } | |
171 | |
172 protected void writeHeapHeader() throws IOException { | |
173 } | |
174 | |
175 // write non-Java-visible (hotspot internal) object | |
176 protected void writeInternalObject(Oop oop) throws IOException { | |
177 } | |
178 | |
179 // write Java primitive array | |
180 protected void writePrimitiveArray(TypeArray array) throws IOException { | |
181 writeObject(array); | |
182 } | |
183 | |
184 // write Java object array | |
185 protected void writeObjectArray(ObjArray array) throws IOException { | |
186 writeObject(array); | |
187 } | |
188 | |
189 protected void writeInstance(Instance instance) throws IOException { | |
190 writeObject(instance); | |
191 } | |
192 | |
193 protected void writeString(Instance instance) throws IOException { | |
194 writeInstance(instance); | |
195 } | |
196 | |
197 protected void writeClass(Instance instance) throws IOException { | |
198 writeInstance(instance); | |
199 } | |
200 | |
201 protected void writeThread(Instance instance) throws IOException { | |
202 writeInstance(instance); | |
203 } | |
204 | |
205 protected void writeObject(Oop oop) throws IOException { | |
206 writeObjectHeader(oop); | |
207 writeObjectFields(oop); | |
208 writeObjectFooter(oop); | |
209 } | |
210 | |
211 protected void writeObjectHeader(Oop oop) throws IOException { | |
212 } | |
213 | |
214 // write instance fields of given object | |
215 protected void writeObjectFields(final Oop oop) throws IOException { | |
216 try { | |
217 oop.iterate(new DefaultOopVisitor() { | |
218 public void doOop(OopField field, boolean isVMField) { | |
219 try { | |
220 writeReferenceField(oop, field); | |
221 } catch (IOException exp) { | |
222 throw new RuntimeException(exp); | |
223 } | |
224 } | |
225 | |
226 public void doByte(ByteField field, boolean isVMField) { | |
227 try { | |
228 writeByteField(oop, field); | |
229 } catch (IOException exp) { | |
230 throw new RuntimeException(exp); | |
231 } | |
232 } | |
233 | |
234 public void doChar(CharField field, boolean isVMField) { | |
235 try { | |
236 writeCharField(oop, field); | |
237 } catch (IOException exp) { | |
238 throw new RuntimeException(exp); | |
239 } | |
240 } | |
241 | |
242 public void doBoolean(BooleanField field, boolean vField) { | |
243 try { | |
244 writeBooleanField(oop, field); | |
245 } catch (IOException exp) { | |
246 throw new RuntimeException(exp); | |
247 } | |
248 } | |
249 | |
250 public void doShort(ShortField field, boolean isVMField) { | |
251 try { | |
252 writeShortField(oop, field); | |
253 } catch (IOException exp) { | |
254 throw new RuntimeException(exp); | |
255 } | |
256 } | |
257 | |
258 public void doInt(IntField field, boolean isVMField) { | |
259 try { | |
260 writeIntField(oop, field); | |
261 } catch (IOException exp) { | |
262 throw new RuntimeException(exp); | |
263 } | |
264 } | |
265 | |
266 public void doLong(LongField field, boolean isVMField) { | |
267 try { | |
268 writeLongField(oop, field); | |
269 } catch (IOException exp) { | |
270 throw new RuntimeException(exp); | |
271 } | |
272 } | |
273 | |
274 public void doFloat(FloatField field, boolean isVMField) { | |
275 try { | |
276 writeFloatField(oop, field); | |
277 } catch (IOException exp) { | |
278 throw new RuntimeException(exp); | |
279 } | |
280 } | |
281 | |
282 public void doDouble(DoubleField field, boolean vField) { | |
283 try { | |
284 writeDoubleField(oop, field); | |
285 } catch (IOException exp) { | |
286 throw new RuntimeException(exp); | |
287 } | |
288 } | |
289 }, false); | |
290 } catch (RuntimeException re) { | |
291 handleRuntimeException(re); | |
292 } | |
293 } | |
294 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
295 // write instance fields of given object |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
296 protected void writeObjectFields(final InstanceKlass oop) throws IOException { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
297 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
298 oop.iterateStaticFields(new DefaultOopVisitor() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
299 public void doOop(OopField field, boolean isVMField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
300 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
301 writeReferenceField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
302 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
303 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
304 } |
0 | 305 } |
306 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
307 public void doByte(ByteField field, boolean isVMField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
308 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
309 writeByteField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
310 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
311 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
312 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
313 } |
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 public void doChar(CharField field, boolean isVMField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
316 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
317 writeCharField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
318 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
319 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
320 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
321 } |
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 public void doBoolean(BooleanField field, boolean vField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
324 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
325 writeBooleanField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
326 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
327 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
328 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
329 } |
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 public void doShort(ShortField field, boolean isVMField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
332 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
333 writeShortField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
334 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
335 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
336 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
337 } |
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 public void doInt(IntField field, boolean isVMField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
340 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
341 writeIntField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
342 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
343 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
344 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
345 } |
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 public void doLong(LongField field, boolean isVMField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
348 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
349 writeLongField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
350 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
351 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
352 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
353 } |
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 public void doFloat(FloatField field, boolean isVMField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
356 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
357 writeFloatField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
358 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
359 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
360 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
361 } |
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 public void doDouble(DoubleField field, boolean vField) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
364 try { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
365 writeDoubleField(null, field); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
366 } catch (IOException exp) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
367 throw new RuntimeException(exp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
368 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
369 } |
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 } catch (RuntimeException re) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
372 handleRuntimeException(re); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
373 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
374 } |
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 // object field writers |
0 | 377 protected void writeReferenceField(Oop oop, OopField field) |
378 throws IOException { | |
379 } | |
380 | |
381 protected void writeByteField(Oop oop, ByteField field) | |
382 throws IOException { | |
383 } | |
384 | |
385 protected void writeCharField(Oop oop, CharField field) | |
386 throws IOException { | |
387 } | |
388 | |
389 protected void writeBooleanField(Oop oop, BooleanField field) | |
390 throws IOException { | |
391 } | |
392 | |
393 protected void writeShortField(Oop oop, ShortField field) | |
394 throws IOException { | |
395 } | |
396 | |
397 protected void writeIntField(Oop oop, IntField field) | |
398 throws IOException { | |
399 } | |
400 | |
401 protected void writeLongField(Oop oop, LongField field) | |
402 throws IOException { | |
403 } | |
404 | |
405 protected void writeFloatField(Oop oop, FloatField field) | |
406 throws IOException { | |
407 } | |
408 | |
409 protected void writeDoubleField(Oop oop, DoubleField field) | |
410 throws IOException { | |
411 } | |
412 | |
413 protected void writeObjectFooter(Oop oop) throws IOException { | |
414 } | |
415 | |
416 protected void writeHeapFooter() throws IOException { | |
417 } | |
418 | |
419 // HeapVisitor, OopVisitor methods can't throw any non-runtime | |
420 // exception. But, derived class write methods (which are called | |
421 // from visitor callbacks) may throw IOException. Hence, we throw | |
422 // RuntimeException with origianal IOException as cause from the | |
423 // visitor methods. This method gets back the original IOException | |
424 // (if any) and re-throws the same. | |
425 protected void handleRuntimeException(RuntimeException re) | |
426 throws IOException { | |
427 Throwable cause = re.getCause(); | |
428 if (cause != null && cause instanceof IOException) { | |
429 throw (IOException) cause; | |
430 } else { | |
431 // some other RuntimeException, just re-throw | |
432 throw re; | |
433 } | |
434 } | |
435 | |
436 // whether a given oop is Java visible or hotspot internal? | |
437 protected boolean isJavaVisible(Oop oop) { | |
438 if (oop instanceof Instance || oop instanceof TypeArray) { | |
439 return true; | |
440 } else if (oop instanceof ObjArray) { | |
441 ObjArrayKlass oak = (ObjArrayKlass) oop.getKlass(); | |
442 Klass bottomKlass = oak.getBottomKlass(); | |
443 return bottomKlass instanceof InstanceKlass || | |
444 bottomKlass instanceof TypeArrayKlass; | |
445 } else { | |
446 return false; | |
447 } | |
448 } | |
449 | |
450 protected Symbol javaLangClass; | |
451 protected Symbol javaLangString; | |
452 protected Symbol javaLangThread; | |
453 } |