Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java @ 6213:8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
Summary: Change constMethodOop::_exception_table to optionally inlined u2 table.
Reviewed-by: bdelsart, coleenp, kamg
author | jiangli |
---|---|
date | Tue, 26 Jun 2012 19:08:44 -0400 |
parents | 2fe087c3e814 |
children | da91efe96a93 |
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 | |
37 public class ConstMethod extends Oop { | |
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 { | |
53 Type type = db.lookupType("constMethodOopDesc"); | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
54 constants = new OopField(type.getOopField("_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 | |
59 HAS_LINENUMBER_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_linenumber_table").intValue(); | |
60 HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("constMethodOopDesc::_has_checked_exceptions").intValue(); | |
61 HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_localvariable_table").intValue(); | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
62 HAS_EXCEPTION_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_exception_table").intValue(); |
0 | 63 |
64 // Size of Java bytecodes allocated immediately after constMethodOop. | |
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 | |
84 ConstMethod(OopHandle handle, ObjectHeap heap) { | |
85 super(handle, heap); | |
86 } | |
87 | |
88 // Fields | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
89 private static OopField 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(); |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
107 ObjArray methods = ik.getMethods(); |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
108 return (Method)methods.getObjAt(getIdNum()); |
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) { | |
160 return getHandle().getJByteAt(bytecodeOffset + bci) & 0xFF; | |
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; | |
218 bc[i] = getHandle().getJByteAt( offs ); | |
219 } | |
220 return bc; | |
221 } | |
222 | |
223 public long getObjectSize() { | |
224 return getConstMethodSize() * getHeap().getOopSize(); | |
225 } | |
226 | |
227 public void printValueOn(PrintStream tty) { | |
228 tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getHandle()); | |
229 } | |
230 | |
231 public void iterateFields(OopVisitor visitor, boolean doVMFields) { | |
232 super.iterateFields(visitor, doVMFields); | |
233 if (doVMFields) { | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
234 visitor.doOop(constants, true); |
0 | 235 visitor.doCInt(constMethodSize, true); |
236 visitor.doByte(flags, true); | |
237 visitor.doCInt(codeSize, true); | |
238 visitor.doCInt(nameIndex, true); | |
239 visitor.doCInt(signatureIndex, true); | |
240 visitor.doCInt(genericSignatureIndex, true); | |
241 visitor.doCInt(codeSize, true); | |
242 } | |
243 } | |
244 | |
245 // Accessors | |
246 | |
247 public boolean hasLineNumberTable() { | |
248 return (getFlags() & HAS_LINENUMBER_TABLE) != 0; | |
249 } | |
250 | |
251 public int getLineNumberFromBCI(int bci) { | |
252 if (!VM.getVM().isCore()) { | |
253 if (bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) bci = 0; | |
254 } | |
255 | |
256 if (isNative()) { | |
257 return -1; | |
258 } | |
259 | |
260 if (Assert.ASSERTS_ENABLED) { | |
261 Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci"); | |
262 } | |
263 int bestBCI = 0; | |
264 int bestLine = -1; | |
265 if (hasLineNumberTable()) { | |
266 // The line numbers are a short array of 2-tuples [start_pc, line_number]. | |
267 // Not necessarily sorted and not necessarily one-to-one. | |
268 CompressedLineNumberReadStream stream = | |
269 new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); | |
270 while (stream.readPair()) { | |
271 if (stream.bci() == bci) { | |
272 // perfect match | |
273 return stream.line(); | |
274 } else { | |
275 // update best_bci/line | |
276 if (stream.bci() < bci && stream.bci() >= bestBCI) { | |
277 bestBCI = stream.bci(); | |
278 bestLine = stream.line(); | |
279 } | |
280 } | |
281 } | |
282 } | |
283 return bestLine; | |
284 } | |
285 | |
286 public LineNumberTableElement[] getLineNumberTable() { | |
287 if (Assert.ASSERTS_ENABLED) { | |
288 Assert.that(hasLineNumberTable(), | |
289 "should only be called if table is present"); | |
290 } | |
291 int len = getLineNumberTableLength(); | |
292 CompressedLineNumberReadStream stream = | |
293 new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); | |
294 LineNumberTableElement[] ret = new LineNumberTableElement[len]; | |
295 | |
296 for (int idx = 0; idx < len; idx++) { | |
297 stream.readPair(); | |
298 ret[idx] = new LineNumberTableElement(stream.bci(), stream.line()); | |
299 } | |
300 return ret; | |
301 } | |
302 | |
303 public boolean hasLocalVariableTable() { | |
304 return (getFlags() & HAS_LOCALVARIABLE_TABLE) != 0; | |
305 } | |
306 | |
307 public Symbol getLocalVariableName(int bci, int slot) { | |
308 return getMethod().getLocalVariableName(bci, slot); | |
309 } | |
310 | |
311 /** Should only be called if table is present */ | |
312 public LocalVariableTableElement[] getLocalVariableTable() { | |
313 if (Assert.ASSERTS_ENABLED) { | |
314 Assert.that(hasLocalVariableTable(), "should only be called if table is present"); | |
315 } | |
316 LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()]; | |
317 long offset = offsetOfLocalVariableTable(); | |
318 for (int i = 0; i < ret.length; i++) { | |
319 ret[i] = new LocalVariableTableElement(getHandle(), offset); | |
320 offset += localVariableTableElementSize; | |
321 } | |
322 return ret; | |
323 } | |
324 | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
325 public boolean hasExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
326 return (getFlags() & HAS_EXCEPTION_TABLE) != 0; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
327 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
328 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
329 public ExceptionTableElement[] getExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
330 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
331 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
|
332 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
333 ExceptionTableElement[] ret = new ExceptionTableElement[getExceptionTableLength()]; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
334 long offset = offsetOfExceptionTable(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
335 for (int i = 0; i < ret.length; i++) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
336 ret[i] = new ExceptionTableElement(getHandle(), offset); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
337 offset += exceptionTableElementSize; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
338 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
339 return ret; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
340 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
341 |
0 | 342 public boolean hasCheckedExceptions() { |
343 return (getFlags() & HAS_CHECKED_EXCEPTIONS) != 0; | |
344 } | |
345 | |
346 public CheckedExceptionElement[] getCheckedExceptions() { | |
347 if (Assert.ASSERTS_ENABLED) { | |
348 Assert.that(hasCheckedExceptions(), "should only be called if table is present"); | |
349 } | |
350 CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()]; | |
351 long offset = offsetOfCheckedExceptions(); | |
352 for (int i = 0; i < ret.length; i++) { | |
353 ret[i] = new CheckedExceptionElement(getHandle(), offset); | |
354 offset += checkedExceptionElementSize; | |
355 } | |
356 return ret; | |
357 } | |
358 | |
359 | |
360 //--------------------------------------------------------------------------- | |
361 // Internals only below this point | |
362 // | |
363 | |
364 private boolean isNative() { | |
365 return getMethod().isNative(); | |
366 } | |
367 | |
368 // Offset of end of code | |
369 private long offsetOfCodeEnd() { | |
370 return bytecodeOffset + getCodeSize(); | |
371 } | |
372 | |
373 // Offset of start of compressed line number table (see methodOop.hpp) | |
374 private long offsetOfCompressedLineNumberTable() { | |
375 return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0); | |
376 } | |
377 | |
378 // Offset of last short in methodOop | |
379 private long offsetOfLastU2Element() { | |
380 return getObjectSize() - 2; | |
381 } | |
382 | |
383 private long offsetOfCheckedExceptionsLength() { | |
384 return offsetOfLastU2Element(); | |
385 } | |
386 | |
387 private int getCheckedExceptionsLength() { | |
388 if (hasCheckedExceptions()) { | |
389 return (int) getHandle().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); | |
390 } else { | |
391 return 0; | |
392 } | |
393 } | |
394 | |
395 // Offset of start of checked exceptions | |
396 private long offsetOfCheckedExceptions() { | |
397 long offset = offsetOfCheckedExceptionsLength(); | |
398 long length = getCheckedExceptionsLength(); | |
399 if (Assert.ASSERTS_ENABLED) { | |
400 Assert.that(length > 0, "should only be called if table is present"); | |
401 } | |
402 offset -= length * checkedExceptionElementSize; | |
403 return offset; | |
404 } | |
405 | |
406 private int getLineNumberTableLength() { | |
407 int len = 0; | |
408 if (hasLineNumberTable()) { | |
409 CompressedLineNumberReadStream stream = | |
410 new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); | |
411 while (stream.readPair()) { | |
412 len += 1; | |
413 } | |
414 } | |
415 return len; | |
416 } | |
417 | |
418 private int getLocalVariableTableLength() { | |
419 if (hasLocalVariableTable()) { | |
420 return (int) getHandle().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true); | |
421 } else { | |
422 return 0; | |
423 } | |
424 } | |
425 | |
426 // Offset of local variable table length | |
427 private long offsetOfLocalVariableTableLength() { | |
428 if (Assert.ASSERTS_ENABLED) { | |
429 Assert.that(hasLocalVariableTable(), "should only be called if table is present"); | |
430 } | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
431 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
432 if (hasExceptionTable()) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
433 return offsetOfExceptionTable() - 2; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
434 } else if (hasCheckedExceptions()) { |
0 | 435 return offsetOfCheckedExceptions() - 2; |
436 } else { | |
437 return offsetOfLastU2Element(); | |
438 } | |
439 } | |
440 | |
441 private long offsetOfLocalVariableTable() { | |
442 long offset = offsetOfLocalVariableTableLength(); | |
443 long length = getLocalVariableTableLength(); | |
444 if (Assert.ASSERTS_ENABLED) { | |
445 Assert.that(length > 0, "should only be called if table is present"); | |
446 } | |
447 offset -= length * localVariableTableElementSize; | |
448 return offset; | |
449 } | |
450 | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
451 private int getExceptionTableLength() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
452 if (hasExceptionTable()) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
453 return (int) getHandle().getCIntegerAt(offsetOfExceptionTableLength(), 2, true); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
454 } else { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
455 return 0; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
456 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
457 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
458 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
459 private long offsetOfExceptionTableLength() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
460 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
461 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
|
462 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
463 if (hasCheckedExceptions()) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
464 return offsetOfCheckedExceptions() - 2; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
465 } else { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
466 return offsetOfLastU2Element(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
467 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
468 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
469 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
470 private long offsetOfExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
471 long offset = offsetOfExceptionTableLength(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
472 long length = getExceptionTableLength(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
473 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
474 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
|
475 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
476 offset -= length * exceptionTableElementSize; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
477 return offset; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
478 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
479 |
0 | 480 } |