author | jiangli |
Wed, 06 Jun 2012 14:33:43 -0400 | |
changeset 12937 | 0032fb2caff6 |
parent 10251 | 71b8938a2821 |
child 13282 | 9872915dd78d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
2 |
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 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; |
|
50 |
||
51 |
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { |
|
52 |
Type type = db.lookupType("constMethodOopDesc"); |
|
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
53 |
constants = new OopField(type.getOopField("_constants"), 0); |
1 | 54 |
// The exception handler table. 4-tuples of ints [start_pc, end_pc, |
55 |
// handler_pc, catch_type index] For methods with no exceptions the |
|
56 |
// table is pointing to Universe::the_empty_int_array |
|
57 |
exceptionTable = new OopField(type.getOopField("_exception_table"), 0); |
|
58 |
constMethodSize = new CIntField(type.getCIntegerField("_constMethod_size"), 0); |
|
59 |
flags = new ByteField(type.getJByteField("_flags"), 0); |
|
60 |
||
61 |
// enum constants for flags |
|
62 |
HAS_LINENUMBER_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_linenumber_table").intValue(); |
|
63 |
HAS_CHECKED_EXCEPTIONS = db.lookupIntConstant("constMethodOopDesc::_has_checked_exceptions").intValue(); |
|
64 |
HAS_LOCALVARIABLE_TABLE = db.lookupIntConstant("constMethodOopDesc::_has_localvariable_table").intValue(); |
|
65 |
||
66 |
// Size of Java bytecodes allocated immediately after constMethodOop. |
|
67 |
codeSize = new CIntField(type.getCIntegerField("_code_size"), 0); |
|
68 |
nameIndex = new CIntField(type.getCIntegerField("_name_index"), 0); |
|
69 |
signatureIndex = new CIntField(type.getCIntegerField("_signature_index"), 0); |
|
70 |
genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"),0); |
|
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
71 |
idnum = new CIntField(type.getCIntegerField("_method_idnum"), 0); |
1 | 72 |
|
73 |
// start of byte code |
|
74 |
bytecodeOffset = type.getSize(); |
|
75 |
||
76 |
type = db.lookupType("CheckedExceptionElement"); |
|
77 |
checkedExceptionElementSize = type.getSize(); |
|
78 |
||
79 |
type = db.lookupType("LocalVariableTableElement"); |
|
80 |
localVariableTableElementSize = type.getSize(); |
|
81 |
} |
|
82 |
||
83 |
ConstMethod(OopHandle handle, ObjectHeap heap) { |
|
84 |
super(handle, heap); |
|
85 |
} |
|
86 |
||
87 |
// Fields |
|
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
88 |
private static OopField constants; |
1 | 89 |
private static OopField exceptionTable; |
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; |
|
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
96 |
private static CIntField idnum; |
1 | 97 |
|
98 |
// start of bytecode |
|
99 |
private static long bytecodeOffset; |
|
100 |
||
101 |
private static long checkedExceptionElementSize; |
|
102 |
private static long localVariableTableElementSize; |
|
103 |
||
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
104 |
public Method getMethod() { |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
105 |
InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder(); |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
106 |
ObjArray methods = ik.getMethods(); |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
107 |
return (Method)methods.getObjAt(getIdNum()); |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
108 |
} |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
109 |
|
1 | 110 |
// Accessors for declared fields |
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
111 |
public ConstantPool getConstants() { |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
112 |
return (ConstantPool) constants.getValue(this); |
1 | 113 |
} |
114 |
||
115 |
public TypeArray getExceptionTable() { |
|
116 |
return (TypeArray) exceptionTable.getValue(this); |
|
117 |
} |
|
118 |
||
119 |
public long getConstMethodSize() { |
|
120 |
return constMethodSize.getValue(this); |
|
121 |
} |
|
122 |
||
123 |
public byte getFlags() { |
|
124 |
return flags.getValue(this); |
|
125 |
} |
|
126 |
||
127 |
public long getCodeSize() { |
|
128 |
return codeSize.getValue(this); |
|
129 |
} |
|
130 |
||
131 |
public long getNameIndex() { |
|
132 |
return nameIndex.getValue(this); |
|
133 |
} |
|
134 |
||
135 |
public long getSignatureIndex() { |
|
136 |
return signatureIndex.getValue(this); |
|
137 |
} |
|
138 |
||
139 |
public long getGenericSignatureIndex() { |
|
140 |
return genericSignatureIndex.getValue(this); |
|
141 |
} |
|
142 |
||
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
143 |
public long getIdNum() { |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
144 |
return idnum.getValue(this); |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
145 |
} |
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
146 |
|
1 | 147 |
public Symbol getName() { |
148 |
return getMethod().getName(); |
|
149 |
} |
|
150 |
||
151 |
public Symbol getSignature() { |
|
152 |
return getMethod().getSignature(); |
|
153 |
} |
|
154 |
||
155 |
public Symbol getGenericSignature() { |
|
156 |
return getMethod().getGenericSignature(); |
|
157 |
} |
|
158 |
||
159 |
// bytecode accessors |
|
160 |
||
161 |
/** Get a bytecode or breakpoint at the given bci */ |
|
162 |
public int getBytecodeOrBPAt(int bci) { |
|
163 |
return getHandle().getJByteAt(bytecodeOffset + bci) & 0xFF; |
|
164 |
} |
|
165 |
||
166 |
public byte getBytecodeByteArg(int bci) { |
|
167 |
return (byte) getBytecodeOrBPAt(bci); |
|
168 |
} |
|
169 |
||
170 |
/** Fetches a 16-bit big-endian ("Java ordered") value from the |
|
171 |
bytecode stream */ |
|
172 |
public short getBytecodeShortArg(int bci) { |
|
173 |
int hi = getBytecodeOrBPAt(bci); |
|
174 |
int lo = getBytecodeOrBPAt(bci + 1); |
|
175 |
return (short) ((hi << 8) | lo); |
|
176 |
} |
|
177 |
||
10251
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
178 |
/** Fetches a 16-bit native ordered value from the |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
179 |
bytecode stream */ |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
180 |
public short getNativeShortArg(int bci) { |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
181 |
int hi = getBytecodeOrBPAt(bci); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
182 |
int lo = getBytecodeOrBPAt(bci + 1); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
183 |
if (VM.getVM().isBigEndian()) { |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
184 |
return (short) ((hi << 8) | lo); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
185 |
} else { |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
186 |
return (short) ((lo << 8) | hi); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
187 |
} |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
188 |
} |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
189 |
|
1 | 190 |
/** Fetches a 32-bit big-endian ("Java ordered") value from the |
191 |
bytecode stream */ |
|
192 |
public int getBytecodeIntArg(int bci) { |
|
193 |
int b4 = getBytecodeOrBPAt(bci); |
|
194 |
int b3 = getBytecodeOrBPAt(bci + 1); |
|
195 |
int b2 = getBytecodeOrBPAt(bci + 2); |
|
196 |
int b1 = getBytecodeOrBPAt(bci + 3); |
|
197 |
||
198 |
return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; |
|
199 |
} |
|
200 |
||
10251
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
201 |
/** Fetches a 32-bit native ordered value from the |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
202 |
bytecode stream */ |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
203 |
public int getNativeIntArg(int bci) { |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
204 |
int b4 = getBytecodeOrBPAt(bci); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
205 |
int b3 = getBytecodeOrBPAt(bci + 1); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
206 |
int b2 = getBytecodeOrBPAt(bci + 2); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
207 |
int b1 = getBytecodeOrBPAt(bci + 3); |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
208 |
|
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
209 |
if (VM.getVM().isBigEndian()) { |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
210 |
return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
211 |
} else { |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
212 |
return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
213 |
} |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
214 |
} |
71b8938a2821
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
5547
diff
changeset
|
215 |
|
1 | 216 |
public byte[] getByteCode() { |
217 |
byte[] bc = new byte[ (int) getCodeSize() ]; |
|
218 |
for( int i=0; i < bc.length; i++ ) |
|
219 |
{ |
|
220 |
long offs = bytecodeOffset + i; |
|
221 |
bc[i] = getHandle().getJByteAt( offs ); |
|
222 |
} |
|
223 |
return bc; |
|
224 |
} |
|
225 |
||
226 |
public long getObjectSize() { |
|
227 |
return getConstMethodSize() * getHeap().getOopSize(); |
|
228 |
} |
|
229 |
||
230 |
public void printValueOn(PrintStream tty) { |
|
231 |
tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getHandle()); |
|
232 |
} |
|
233 |
||
234 |
public void iterateFields(OopVisitor visitor, boolean doVMFields) { |
|
235 |
super.iterateFields(visitor, doVMFields); |
|
236 |
if (doVMFields) { |
|
12937
0032fb2caff6
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
10251
diff
changeset
|
237 |
visitor.doOop(constants, true); |
1 | 238 |
visitor.doOop(exceptionTable, true); |
239 |
visitor.doCInt(constMethodSize, true); |
|
240 |
visitor.doByte(flags, true); |
|
241 |
visitor.doCInt(codeSize, true); |
|
242 |
visitor.doCInt(nameIndex, true); |
|
243 |
visitor.doCInt(signatureIndex, true); |
|
244 |
visitor.doCInt(genericSignatureIndex, true); |
|
245 |
visitor.doCInt(codeSize, true); |
|
246 |
} |
|
247 |
} |
|
248 |
||
249 |
// Accessors |
|
250 |
||
251 |
public boolean hasLineNumberTable() { |
|
252 |
return (getFlags() & HAS_LINENUMBER_TABLE) != 0; |
|
253 |
} |
|
254 |
||
255 |
public int getLineNumberFromBCI(int bci) { |
|
256 |
if (!VM.getVM().isCore()) { |
|
257 |
if (bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) bci = 0; |
|
258 |
} |
|
259 |
||
260 |
if (isNative()) { |
|
261 |
return -1; |
|
262 |
} |
|
263 |
||
264 |
if (Assert.ASSERTS_ENABLED) { |
|
265 |
Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci"); |
|
266 |
} |
|
267 |
int bestBCI = 0; |
|
268 |
int bestLine = -1; |
|
269 |
if (hasLineNumberTable()) { |
|
270 |
// The line numbers are a short array of 2-tuples [start_pc, line_number]. |
|
271 |
// Not necessarily sorted and not necessarily one-to-one. |
|
272 |
CompressedLineNumberReadStream stream = |
|
273 |
new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); |
|
274 |
while (stream.readPair()) { |
|
275 |
if (stream.bci() == bci) { |
|
276 |
// perfect match |
|
277 |
return stream.line(); |
|
278 |
} else { |
|
279 |
// update best_bci/line |
|
280 |
if (stream.bci() < bci && stream.bci() >= bestBCI) { |
|
281 |
bestBCI = stream.bci(); |
|
282 |
bestLine = stream.line(); |
|
283 |
} |
|
284 |
} |
|
285 |
} |
|
286 |
} |
|
287 |
return bestLine; |
|
288 |
} |
|
289 |
||
290 |
public LineNumberTableElement[] getLineNumberTable() { |
|
291 |
if (Assert.ASSERTS_ENABLED) { |
|
292 |
Assert.that(hasLineNumberTable(), |
|
293 |
"should only be called if table is present"); |
|
294 |
} |
|
295 |
int len = getLineNumberTableLength(); |
|
296 |
CompressedLineNumberReadStream stream = |
|
297 |
new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); |
|
298 |
LineNumberTableElement[] ret = new LineNumberTableElement[len]; |
|
299 |
||
300 |
for (int idx = 0; idx < len; idx++) { |
|
301 |
stream.readPair(); |
|
302 |
ret[idx] = new LineNumberTableElement(stream.bci(), stream.line()); |
|
303 |
} |
|
304 |
return ret; |
|
305 |
} |
|
306 |
||
307 |
public boolean hasLocalVariableTable() { |
|
308 |
return (getFlags() & HAS_LOCALVARIABLE_TABLE) != 0; |
|
309 |
} |
|
310 |
||
311 |
public Symbol getLocalVariableName(int bci, int slot) { |
|
312 |
return getMethod().getLocalVariableName(bci, slot); |
|
313 |
} |
|
314 |
||
315 |
/** Should only be called if table is present */ |
|
316 |
public LocalVariableTableElement[] getLocalVariableTable() { |
|
317 |
if (Assert.ASSERTS_ENABLED) { |
|
318 |
Assert.that(hasLocalVariableTable(), "should only be called if table is present"); |
|
319 |
} |
|
320 |
LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()]; |
|
321 |
long offset = offsetOfLocalVariableTable(); |
|
322 |
for (int i = 0; i < ret.length; i++) { |
|
323 |
ret[i] = new LocalVariableTableElement(getHandle(), offset); |
|
324 |
offset += localVariableTableElementSize; |
|
325 |
} |
|
326 |
return ret; |
|
327 |
} |
|
328 |
||
329 |
public boolean hasCheckedExceptions() { |
|
330 |
return (getFlags() & HAS_CHECKED_EXCEPTIONS) != 0; |
|
331 |
} |
|
332 |
||
333 |
public CheckedExceptionElement[] getCheckedExceptions() { |
|
334 |
if (Assert.ASSERTS_ENABLED) { |
|
335 |
Assert.that(hasCheckedExceptions(), "should only be called if table is present"); |
|
336 |
} |
|
337 |
CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()]; |
|
338 |
long offset = offsetOfCheckedExceptions(); |
|
339 |
for (int i = 0; i < ret.length; i++) { |
|
340 |
ret[i] = new CheckedExceptionElement(getHandle(), offset); |
|
341 |
offset += checkedExceptionElementSize; |
|
342 |
} |
|
343 |
return ret; |
|
344 |
} |
|
345 |
||
346 |
||
347 |
//--------------------------------------------------------------------------- |
|
348 |
// Internals only below this point |
|
349 |
// |
|
350 |
||
351 |
private boolean isNative() { |
|
352 |
return getMethod().isNative(); |
|
353 |
} |
|
354 |
||
355 |
// Offset of end of code |
|
356 |
private long offsetOfCodeEnd() { |
|
357 |
return bytecodeOffset + getCodeSize(); |
|
358 |
} |
|
359 |
||
360 |
// Offset of start of compressed line number table (see methodOop.hpp) |
|
361 |
private long offsetOfCompressedLineNumberTable() { |
|
362 |
return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0); |
|
363 |
} |
|
364 |
||
365 |
// Offset of last short in methodOop |
|
366 |
private long offsetOfLastU2Element() { |
|
367 |
return getObjectSize() - 2; |
|
368 |
} |
|
369 |
||
370 |
private long offsetOfCheckedExceptionsLength() { |
|
371 |
return offsetOfLastU2Element(); |
|
372 |
} |
|
373 |
||
374 |
private int getCheckedExceptionsLength() { |
|
375 |
if (hasCheckedExceptions()) { |
|
376 |
return (int) getHandle().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); |
|
377 |
} else { |
|
378 |
return 0; |
|
379 |
} |
|
380 |
} |
|
381 |
||
382 |
// Offset of start of checked exceptions |
|
383 |
private long offsetOfCheckedExceptions() { |
|
384 |
long offset = offsetOfCheckedExceptionsLength(); |
|
385 |
long length = getCheckedExceptionsLength(); |
|
386 |
if (Assert.ASSERTS_ENABLED) { |
|
387 |
Assert.that(length > 0, "should only be called if table is present"); |
|
388 |
} |
|
389 |
offset -= length * checkedExceptionElementSize; |
|
390 |
return offset; |
|
391 |
} |
|
392 |
||
393 |
private int getLineNumberTableLength() { |
|
394 |
int len = 0; |
|
395 |
if (hasLineNumberTable()) { |
|
396 |
CompressedLineNumberReadStream stream = |
|
397 |
new CompressedLineNumberReadStream(getHandle(), (int) offsetOfCompressedLineNumberTable()); |
|
398 |
while (stream.readPair()) { |
|
399 |
len += 1; |
|
400 |
} |
|
401 |
} |
|
402 |
return len; |
|
403 |
} |
|
404 |
||
405 |
private int getLocalVariableTableLength() { |
|
406 |
if (hasLocalVariableTable()) { |
|
407 |
return (int) getHandle().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true); |
|
408 |
} else { |
|
409 |
return 0; |
|
410 |
} |
|
411 |
} |
|
412 |
||
413 |
// Offset of local variable table length |
|
414 |
private long offsetOfLocalVariableTableLength() { |
|
415 |
if (Assert.ASSERTS_ENABLED) { |
|
416 |
Assert.that(hasLocalVariableTable(), "should only be called if table is present"); |
|
417 |
} |
|
418 |
if (hasCheckedExceptions()) { |
|
419 |
return offsetOfCheckedExceptions() - 2; |
|
420 |
} else { |
|
421 |
return offsetOfLastU2Element(); |
|
422 |
} |
|
423 |
} |
|
424 |
||
425 |
private long offsetOfLocalVariableTable() { |
|
426 |
long offset = offsetOfLocalVariableTableLength(); |
|
427 |
long length = getLocalVariableTableLength(); |
|
428 |
if (Assert.ASSERTS_ENABLED) { |
|
429 |
Assert.that(length > 0, "should only be called if table is present"); |
|
430 |
} |
|
431 |
offset -= length * localVariableTableElementSize; |
|
432 |
return offset; |
|
433 |
} |
|
434 |
||
435 |
} |