Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java @ 6735:aed758eda82a
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
Summary: Simple renaming to be consistent with instanceKlass->InstanceKlass renaming
Reviewed-by: stefank, jmasa
author | coleenp |
---|---|
date | Fri, 07 Sep 2012 12:04:16 -0400 |
parents | da91efe96a93 |
children | b2dbd323c668 |
rev | line source |
---|---|
0 | 1 /* |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
2 * Copyright (c) 2003, 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:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
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:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.oops; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.code.*; | |
30 import sun.jvm.hotspot.debugger.*; | |
31 import sun.jvm.hotspot.interpreter.*; | |
32 import sun.jvm.hotspot.memory.*; | |
33 import sun.jvm.hotspot.runtime.*; | |
34 import sun.jvm.hotspot.types.*; | |
35 import sun.jvm.hotspot.utilities.*; | |
36 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
37 public class ConstMethod extends VMObject { |
0 | 38 static { |
39 VM.registerVMInitializedObserver(new Observer() { | |
40 public void update(Observable o, Object data) { | |
41 initialize(VM.getVM().getTypeDataBase()); | |
42 } | |
43 }); | |
44 } | |
45 | |
46 // anon-enum constants for _flags. | |
47 private static int HAS_LINENUMBER_TABLE; | |
48 private static int HAS_CHECKED_EXCEPTIONS; | |
49 private static int HAS_LOCALVARIABLE_TABLE; | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
50 private static int HAS_EXCEPTION_TABLE; |
0 | 51 |
52 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
53 Type type = db.lookupType("ConstMethod"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
54 constants = new MetadataField(type.getAddressField("_constants"), 0); |
0 | 55 constMethodSize = new CIntField(type.getCIntegerField("_constMethod_size"), 0); |
56 flags = new ByteField(type.getJByteField("_flags"), 0); | |
57 | |
58 // enum constants for flags | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
59 HAS_LINENUMBER_TABLE = db.lookupIntConstant("ConstMethod::_has_linenumber_table").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
60 HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("ConstMethod::_has_checked_exceptions").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
61 HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("ConstMethod::_has_localvariable_table").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
62 HAS_EXCEPTION_TABLE = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue(); |
0 | 63 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
64 // Size of Java bytecodes allocated immediately after ConstMethod*. |
0 | 65 codeSize = new CIntField(type.getCIntegerField("_code_size"), 0); |
66 nameIndex = new CIntField(type.getCIntegerField("_name_index"), 0); | |
67 signatureIndex = new CIntField(type.getCIntegerField("_signature_index"), 0); | |
68 genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"),0); | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
69 idnum = new CIntField(type.getCIntegerField("_method_idnum"), 0); |
0 | 70 |
71 // start of byte code | |
72 bytecodeOffset = type.getSize(); | |
73 | |
74 type = db.lookupType("CheckedExceptionElement"); | |
75 checkedExceptionElementSize = type.getSize(); | |
76 | |
77 type = db.lookupType("LocalVariableTableElement"); | |
78 localVariableTableElementSize = type.getSize(); | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
79 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
80 type = db.lookupType("ExceptionTableElement"); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
81 exceptionTableElementSize = type.getSize(); |
0 | 82 } |
83 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
84 public ConstMethod(Address addr) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
85 super(addr); |
0 | 86 } |
87 | |
88 // Fields | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
89 private static MetadataField constants; |
0 | 90 private static CIntField constMethodSize; |
91 private static ByteField flags; | |
92 private static CIntField codeSize; | |
93 private static CIntField nameIndex; | |
94 private static CIntField signatureIndex; | |
95 private static CIntField genericSignatureIndex; | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
96 private static CIntField idnum; |
0 | 97 |
98 // start of bytecode | |
99 private static long bytecodeOffset; | |
100 | |
101 private static long checkedExceptionElementSize; | |
102 private static long localVariableTableElementSize; | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
103 private static long exceptionTableElementSize; |
0 | 104 |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
105 public Method getMethod() { |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
106 InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
107 MethodArray methods = ik.getMethods(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
108 return methods.at((int)getIdNum()); |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
109 } |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
110 |
0 | 111 // Accessors for declared fields |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
112 public ConstantPool getConstants() { |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
113 return (ConstantPool) constants.getValue(this); |
0 | 114 } |
115 | |
116 public long getConstMethodSize() { | |
117 return constMethodSize.getValue(this); | |
118 } | |
119 | |
120 public byte getFlags() { | |
121 return flags.getValue(this); | |
122 } | |
123 | |
124 public long getCodeSize() { | |
125 return codeSize.getValue(this); | |
126 } | |
127 | |
128 public long getNameIndex() { | |
129 return nameIndex.getValue(this); | |
130 } | |
131 | |
132 public long getSignatureIndex() { | |
133 return signatureIndex.getValue(this); | |
134 } | |
135 | |
136 public long getGenericSignatureIndex() { | |
137 return genericSignatureIndex.getValue(this); | |
138 } | |
139 | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
140 public long getIdNum() { |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
141 return idnum.getValue(this); |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
142 } |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
143 |
0 | 144 public Symbol getName() { |
145 return getMethod().getName(); | |
146 } | |
147 | |
148 public Symbol getSignature() { | |
149 return getMethod().getSignature(); | |
150 } | |
151 | |
152 public Symbol getGenericSignature() { | |
153 return getMethod().getGenericSignature(); | |
154 } | |
155 | |
156 // bytecode accessors | |
157 | |
158 /** Get a bytecode or breakpoint at the given bci */ | |
159 public int getBytecodeOrBPAt(int bci) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
160 return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF; |
0 | 161 } |
162 | |
163 public byte getBytecodeByteArg(int bci) { | |
164 return (byte) getBytecodeOrBPAt(bci); | |
165 } | |
166 | |
167 /** Fetches a 16-bit big-endian ("Java ordered") value from the | |
168 bytecode stream */ | |
169 public short getBytecodeShortArg(int bci) { | |
170 int hi = getBytecodeOrBPAt(bci); | |
171 int lo = getBytecodeOrBPAt(bci + 1); | |
172 return (short) ((hi << 8) | lo); | |
173 } | |
174 | |
3838
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
175 /** Fetches a 16-bit native ordered value from the |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
176 bytecode stream */ |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
177 public short getNativeShortArg(int bci) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
178 int hi = getBytecodeOrBPAt(bci); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
179 int lo = getBytecodeOrBPAt(bci + 1); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
180 if (VM.getVM().isBigEndian()) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
181 return (short) ((hi << 8) | lo); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
182 } else { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
183 return (short) ((lo << 8) | hi); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
184 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
185 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
186 |
0 | 187 /** Fetches a 32-bit big-endian ("Java ordered") value from the |
188 bytecode stream */ | |
189 public int getBytecodeIntArg(int bci) { | |
190 int b4 = getBytecodeOrBPAt(bci); | |
191 int b3 = getBytecodeOrBPAt(bci + 1); | |
192 int b2 = getBytecodeOrBPAt(bci + 2); | |
193 int b1 = getBytecodeOrBPAt(bci + 3); | |
194 | |
195 return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; | |
196 } | |
197 | |
3838
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
198 /** Fetches a 32-bit native ordered value from the |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
199 bytecode stream */ |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
200 public int getNativeIntArg(int bci) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
201 int b4 = getBytecodeOrBPAt(bci); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
202 int b3 = getBytecodeOrBPAt(bci + 1); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
203 int b2 = getBytecodeOrBPAt(bci + 2); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
204 int b1 = getBytecodeOrBPAt(bci + 3); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
205 |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
206 if (VM.getVM().isBigEndian()) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
207 return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
208 } else { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
209 return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
210 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
211 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
212 |
0 | 213 public byte[] getByteCode() { |
214 byte[] bc = new byte[ (int) getCodeSize() ]; | |
215 for( int i=0; i < bc.length; i++ ) | |
216 { | |
217 long offs = bytecodeOffset + i; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
218 bc[i] = getAddress().getJByteAt( offs ); |
0 | 219 } |
220 return bc; | |
221 } | |
222 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
223 public long getSize() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
224 return getConstMethodSize(); |
0 | 225 } |
226 | |
227 public void printValueOn(PrintStream tty) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
228 tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getAddress()); |
0 | 229 } |
230 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
231 public void iterateFields(MetadataVisitor visitor) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
232 visitor.doMetadata(constants, true); |
0 | 233 visitor.doCInt(constMethodSize, true); |
234 visitor.doByte(flags, true); | |
235 visitor.doCInt(codeSize, true); | |
236 visitor.doCInt(nameIndex, true); | |
237 visitor.doCInt(signatureIndex, true); | |
238 visitor.doCInt(genericSignatureIndex, true); | |
239 visitor.doCInt(codeSize, true); | |
240 } | |
241 | |
242 // Accessors | |
243 | |
244 public boolean hasLineNumberTable() { | |
245 return (getFlags() & HAS_LINENUMBER_TABLE) != 0; | |
246 } | |
247 | |
248 public int getLineNumberFromBCI(int bci) { | |
249 if (!VM.getVM().isCore()) { | |
250 if (bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) bci = 0; | |
251 } | |
252 | |
253 if (isNative()) { | |
254 return -1; | |
255 } | |
256 | |
257 if (Assert.ASSERTS_ENABLED) { | |
258 Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci"); | |
259 } | |
260 int bestBCI = 0; | |
261 int bestLine = -1; | |
262 if (hasLineNumberTable()) { | |
263 // The line numbers are a short array of 2-tuples [start_pc, line_number]. | |
264 // Not necessarily sorted and not necessarily one-to-one. | |
265 CompressedLineNumberReadStream stream = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
266 new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); |
0 | 267 while (stream.readPair()) { |
268 if (stream.bci() == bci) { | |
269 // perfect match | |
270 return stream.line(); | |
271 } else { | |
272 // update best_bci/line | |
273 if (stream.bci() < bci && stream.bci() >= bestBCI) { | |
274 bestBCI = stream.bci(); | |
275 bestLine = stream.line(); | |
276 } | |
277 } | |
278 } | |
279 } | |
280 return bestLine; | |
281 } | |
282 | |
283 public LineNumberTableElement[] getLineNumberTable() { | |
284 if (Assert.ASSERTS_ENABLED) { | |
285 Assert.that(hasLineNumberTable(), | |
286 "should only be called if table is present"); | |
287 } | |
288 int len = getLineNumberTableLength(); | |
289 CompressedLineNumberReadStream stream = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
290 new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); |
0 | 291 LineNumberTableElement[] ret = new LineNumberTableElement[len]; |
292 | |
293 for (int idx = 0; idx < len; idx++) { | |
294 stream.readPair(); | |
295 ret[idx] = new LineNumberTableElement(stream.bci(), stream.line()); | |
296 } | |
297 return ret; | |
298 } | |
299 | |
300 public boolean hasLocalVariableTable() { | |
301 return (getFlags() & HAS_LOCALVARIABLE_TABLE) != 0; | |
302 } | |
303 | |
304 public Symbol getLocalVariableName(int bci, int slot) { | |
305 return getMethod().getLocalVariableName(bci, slot); | |
306 } | |
307 | |
308 /** Should only be called if table is present */ | |
309 public LocalVariableTableElement[] getLocalVariableTable() { | |
310 if (Assert.ASSERTS_ENABLED) { | |
311 Assert.that(hasLocalVariableTable(), "should only be called if table is present"); | |
312 } | |
313 LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()]; | |
314 long offset = offsetOfLocalVariableTable(); | |
315 for (int i = 0; i < ret.length; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
316 ret[i] = new LocalVariableTableElement(getAddress(), offset); |
0 | 317 offset += localVariableTableElementSize; |
318 } | |
319 return ret; | |
320 } | |
321 | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
322 public boolean hasExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
323 return (getFlags() & HAS_EXCEPTION_TABLE) != 0; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
324 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
325 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
326 public ExceptionTableElement[] getExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
327 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
328 Assert.that(hasExceptionTable(), "should only be called if table is present"); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
329 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
330 ExceptionTableElement[] ret = new ExceptionTableElement[getExceptionTableLength()]; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
331 long offset = offsetOfExceptionTable(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
332 for (int i = 0; i < ret.length; i++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
333 ret[i] = new ExceptionTableElement(getAddress(), offset); |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
334 offset += exceptionTableElementSize; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
335 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
336 return ret; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
337 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
338 |
0 | 339 public boolean hasCheckedExceptions() { |
340 return (getFlags() & HAS_CHECKED_EXCEPTIONS) != 0; | |
341 } | |
342 | |
343 public CheckedExceptionElement[] getCheckedExceptions() { | |
344 if (Assert.ASSERTS_ENABLED) { | |
345 Assert.that(hasCheckedExceptions(), "should only be called if table is present"); | |
346 } | |
347 CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()]; | |
348 long offset = offsetOfCheckedExceptions(); | |
349 for (int i = 0; i < ret.length; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
350 ret[i] = new CheckedExceptionElement(getAddress(), offset); |
0 | 351 offset += checkedExceptionElementSize; |
352 } | |
353 return ret; | |
354 } | |
355 | |
356 | |
357 //--------------------------------------------------------------------------- | |
358 // Internals only below this point | |
359 // | |
360 | |
361 private boolean isNative() { | |
362 return getMethod().isNative(); | |
363 } | |
364 | |
365 // Offset of end of code | |
366 private long offsetOfCodeEnd() { | |
367 return bytecodeOffset + getCodeSize(); | |
368 } | |
369 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
370 // Offset of start of compressed line number table (see method.hpp) |
0 | 371 private long offsetOfCompressedLineNumberTable() { |
372 return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0); | |
373 } | |
374 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
375 // Offset of last short in Method* |
0 | 376 private long offsetOfLastU2Element() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
377 return getSize() * VM.getVM().getObjectHeap().getOopSize() - 2; |
0 | 378 } |
379 | |
380 private long offsetOfCheckedExceptionsLength() { | |
381 return offsetOfLastU2Element(); | |
382 } | |
383 | |
384 private int getCheckedExceptionsLength() { | |
385 if (hasCheckedExceptions()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
386 return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); |
0 | 387 } else { |
388 return 0; | |
389 } | |
390 } | |
391 | |
392 // Offset of start of checked exceptions | |
393 private long offsetOfCheckedExceptions() { | |
394 long offset = offsetOfCheckedExceptionsLength(); | |
395 long length = getCheckedExceptionsLength(); | |
396 if (Assert.ASSERTS_ENABLED) { | |
397 Assert.that(length > 0, "should only be called if table is present"); | |
398 } | |
399 offset -= length * checkedExceptionElementSize; | |
400 return offset; | |
401 } | |
402 | |
403 private int getLineNumberTableLength() { | |
404 int len = 0; | |
405 if (hasLineNumberTable()) { | |
406 CompressedLineNumberReadStream stream = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
407 new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); |
0 | 408 while (stream.readPair()) { |
409 len += 1; | |
410 } | |
411 } | |
412 return len; | |
413 } | |
414 | |
415 private int getLocalVariableTableLength() { | |
416 if (hasLocalVariableTable()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
417 return (int) getAddress().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true); |
0 | 418 } else { |
419 return 0; | |
420 } | |
421 } | |
422 | |
423 // Offset of local variable table length | |
424 private long offsetOfLocalVariableTableLength() { | |
425 if (Assert.ASSERTS_ENABLED) { | |
426 Assert.that(hasLocalVariableTable(), "should only be called if table is present"); | |
427 } | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
428 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
429 if (hasExceptionTable()) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
430 return offsetOfExceptionTable() - 2; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
431 } else if (hasCheckedExceptions()) { |
0 | 432 return offsetOfCheckedExceptions() - 2; |
433 } else { | |
434 return offsetOfLastU2Element(); | |
435 } | |
436 } | |
437 | |
438 private long offsetOfLocalVariableTable() { | |
439 long offset = offsetOfLocalVariableTableLength(); | |
440 long length = getLocalVariableTableLength(); | |
441 if (Assert.ASSERTS_ENABLED) { | |
442 Assert.that(length > 0, "should only be called if table is present"); | |
443 } | |
444 offset -= length * localVariableTableElementSize; | |
445 return offset; | |
446 } | |
447 | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
448 private int getExceptionTableLength() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
449 if (hasExceptionTable()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
450 return (int) getAddress().getCIntegerAt(offsetOfExceptionTableLength(), 2, true); |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
451 } else { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
452 return 0; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
453 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
454 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
455 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
456 private long offsetOfExceptionTableLength() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
457 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
458 Assert.that(hasExceptionTable(), "should only be called if table is present"); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
459 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
460 if (hasCheckedExceptions()) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
461 return offsetOfCheckedExceptions() - 2; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
462 } else { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
463 return offsetOfLastU2Element(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
464 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
465 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
466 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
467 private long offsetOfExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
468 long offset = offsetOfExceptionTableLength(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
469 long length = getExceptionTableLength(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
470 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
471 Assert.that(length > 0, "should only be called if table is present"); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
472 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
473 offset -= length * exceptionTableElementSize; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
474 return offset; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
475 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
476 |
0 | 477 } |