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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
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
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 {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (oop instanceof TypeArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 writePrimitiveArray((TypeArray)oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 } else if (oop instanceof ObjArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 Klass klass = oop.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 ObjArrayKlass oak = (ObjArrayKlass) klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 Klass bottomType = oak.getBottomKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 if (bottomType instanceof InstanceKlass ||
a61af66fc99e Initial load
duke
parents:
diff changeset
69 bottomType instanceof TypeArrayKlass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 writeObjectArray((ObjArray)oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 writeInternalObject(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 } else if (oop instanceof Instance) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 Instance instance = (Instance) oop;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Klass klass = instance.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 Symbol name = klass.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (name.equals(javaLangString)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 writeString(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 } else if (name.equals(javaLangClass)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 writeClass(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } else if (name.equals(javaLangThread)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 writeThread(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 klass = klass.getSuper();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 while (klass != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 name = klass.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 if (name.equals(javaLangThread)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 writeThread(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 klass = klass.getSuper();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // not-a-Java-visible oop
a61af66fc99e Initial load
duke
parents:
diff changeset
98 writeInternalObject(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 public void epilogue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 writeHeapFooter();
a61af66fc99e Initial load
duke
parents:
diff changeset
109 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 });
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // write JavaThreads
a61af66fc99e Initial load
duke
parents:
diff changeset
116 writeJavaThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // write JNI global handles
a61af66fc99e Initial load
duke
parents:
diff changeset
119 writeGlobalJNIHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 } catch (RuntimeException re) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 handleRuntimeException(re);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 protected void writeJavaThreads() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 Threads threads = VM.getVM().getThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 JavaThread jt = threads.first();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 int index = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 while (jt != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (jt.getThreadObj() != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // Note that the thread serial number range is 1-to-N
a61af66fc99e Initial load
duke
parents:
diff changeset
133 writeJavaThread(jt, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 jt = jt.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 protected void writeJavaThread(JavaThread jt, int index)
a61af66fc99e Initial load
duke
parents:
diff changeset
141 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 protected void writeGlobalJNIHandles() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 JNIHandles handles = VM.getVM().getJNIHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 JNIHandleBlock blk = handles.globalHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (blk != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 blk.oopsDo(new AddressVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public void visitAddress(Address handleAddr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 if (handleAddr != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 writeGlobalJNIHandle(handleAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
162 });
a61af66fc99e Initial load
duke
parents:
diff changeset
163 } catch (RuntimeException re) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 handleRuntimeException(re);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 protected void writeGlobalJNIHandle(Address handleAddr) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 protected void writeHeapHeader() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // write non-Java-visible (hotspot internal) object
a61af66fc99e Initial load
duke
parents:
diff changeset
176 protected void writeInternalObject(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // write Java primitive array
a61af66fc99e Initial load
duke
parents:
diff changeset
180 protected void writePrimitiveArray(TypeArray array) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 writeObject(array);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // write Java object array
a61af66fc99e Initial load
duke
parents:
diff changeset
185 protected void writeObjectArray(ObjArray array) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 writeObject(array);
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 protected void writeInstance(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 writeObject(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 protected void writeString(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 protected void writeClass(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 protected void writeThread(Instance instance) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 writeInstance(instance);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 protected void writeObject(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 writeObjectHeader(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 writeObjectFields(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 writeObjectFooter(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 protected void writeObjectHeader(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // write instance fields of given object
a61af66fc99e Initial load
duke
parents:
diff changeset
215 protected void writeObjectFields(final Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 oop.iterate(new DefaultOopVisitor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 public void doOop(OopField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 writeReferenceField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 public void doByte(ByteField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 writeByteField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 public void doChar(CharField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 writeCharField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 public void doBoolean(BooleanField field, boolean vField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 writeBooleanField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
245 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 public void doShort(ShortField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 writeShortField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
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 void doInt(IntField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 writeIntField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 public void doLong(LongField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 writeLongField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 public void doFloat(FloatField field, boolean isVMField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 writeFloatField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 public void doDouble(DoubleField field, boolean vField) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 writeDoubleField(oop, field);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } catch (IOException exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 throw new RuntimeException(exp);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 } catch (RuntimeException re) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 handleRuntimeException(re);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
377 protected void writeReferenceField(Oop oop, OopField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
378 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 protected void writeByteField(Oop oop, ByteField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
382 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384
a61af66fc99e Initial load
duke
parents:
diff changeset
385 protected void writeCharField(Oop oop, CharField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
386 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 protected void writeBooleanField(Oop oop, BooleanField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
390 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 protected void writeShortField(Oop oop, ShortField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
394 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
396
a61af66fc99e Initial load
duke
parents:
diff changeset
397 protected void writeIntField(Oop oop, IntField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
398 throws IOException {
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 void writeLongField(Oop oop, LongField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
402 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 protected void writeFloatField(Oop oop, FloatField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
406 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 protected void writeDoubleField(Oop oop, DoubleField field)
a61af66fc99e Initial load
duke
parents:
diff changeset
410 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 protected void writeObjectFooter(Oop oop) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 protected void writeHeapFooter() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }
a61af66fc99e Initial load
duke
parents:
diff changeset
418
a61af66fc99e Initial load
duke
parents:
diff changeset
419 // HeapVisitor, OopVisitor methods can't throw any non-runtime
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // exception. But, derived class write methods (which are called
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // from visitor callbacks) may throw IOException. Hence, we throw
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // RuntimeException with origianal IOException as cause from the
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // visitor methods. This method gets back the original IOException
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // (if any) and re-throws the same.
a61af66fc99e Initial load
duke
parents:
diff changeset
425 protected void handleRuntimeException(RuntimeException re)
a61af66fc99e Initial load
duke
parents:
diff changeset
426 throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
427 Throwable cause = re.getCause();
a61af66fc99e Initial load
duke
parents:
diff changeset
428 if (cause != null && cause instanceof IOException) {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 throw (IOException) cause;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // some other RuntimeException, just re-throw
a61af66fc99e Initial load
duke
parents:
diff changeset
432 throw re;
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 // whether a given oop is Java visible or hotspot internal?
a61af66fc99e Initial load
duke
parents:
diff changeset
437 protected boolean isJavaVisible(Oop oop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 if (oop instanceof Instance || oop instanceof TypeArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
439 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
440 } else if (oop instanceof ObjArray) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 ObjArrayKlass oak = (ObjArrayKlass) oop.getKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
442 Klass bottomKlass = oak.getBottomKlass();
a61af66fc99e Initial load
duke
parents:
diff changeset
443 return bottomKlass instanceof InstanceKlass ||
a61af66fc99e Initial load
duke
parents:
diff changeset
444 bottomKlass instanceof TypeArrayKlass;
a61af66fc99e Initial load
duke
parents:
diff changeset
445 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
447 }
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 protected Symbol javaLangClass;
a61af66fc99e Initial load
duke
parents:
diff changeset
451 protected Symbol javaLangString;
a61af66fc99e Initial load
duke
parents:
diff changeset
452 protected Symbol javaLangThread;
a61af66fc99e Initial load
duke
parents:
diff changeset
453 }