Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java @ 12939:d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
Summary: Hotspot was updated to store method parameter reflection and generic type signature data at runtime. Serviceability agent support was updated for this data
Reviewed-by: coleenp, minqi, sla
Contributed-by: eric.mccorkle@oracle.com
author | dsamersoff |
---|---|
date | Thu, 17 Oct 2013 16:45:08 +0400 |
parents | 927a311d00f9 |
children |
rev | line source |
---|---|
0 | 1 /* |
8031 | 2 * Copyright (c) 2003, 2013, 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; |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
51 private static int HAS_GENERIC_SIGNATURE; |
8031 | 52 private static int HAS_METHOD_ANNOTATIONS; |
53 private static int HAS_PARAMETER_ANNOTATIONS; | |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
54 private static int HAS_METHOD_PARAMETERS; |
8031 | 55 private static int HAS_DEFAULT_ANNOTATIONS; |
56 private static int HAS_TYPE_ANNOTATIONS; | |
57 | |
58 private static final int sizeofShort = 2; | |
0 | 59 |
60 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
|
61 Type type = db.lookupType("ConstMethod"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
62 constants = new MetadataField(type.getAddressField("_constants"), 0); |
0 | 63 constMethodSize = new CIntField(type.getCIntegerField("_constMethod_size"), 0); |
8031 | 64 flags = new CIntField(type.getCIntegerField("_flags"), 0); |
0 | 65 |
66 // enum constants for flags | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 HAS_EXCEPTION_TABLE = db.lookupIntConstant("ConstMethod::_has_exception_table").intValue(); |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
71 HAS_GENERIC_SIGNATURE = db.lookupIntConstant("ConstMethod::_has_generic_signature").intValue(); |
8031 | 72 HAS_METHOD_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_method_annotations").intValue(); |
73 HAS_PARAMETER_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_parameter_annotations").intValue(); | |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
74 HAS_METHOD_PARAMETERS = db.lookupIntConstant("ConstMethod::_has_method_parameters").intValue(); |
8031 | 75 HAS_DEFAULT_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_default_annotations").intValue(); |
76 HAS_TYPE_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_type_annotations").intValue(); | |
0 | 77 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
78 // Size of Java bytecodes allocated immediately after ConstMethod*. |
0 | 79 codeSize = new CIntField(type.getCIntegerField("_code_size"), 0); |
80 nameIndex = new CIntField(type.getCIntegerField("_name_index"), 0); | |
81 signatureIndex = new CIntField(type.getCIntegerField("_signature_index"), 0); | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
82 idnum = new CIntField(type.getCIntegerField("_method_idnum"), 0); |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
83 maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0); |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
84 maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
85 sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0); |
0 | 86 |
87 // start of byte code | |
88 bytecodeOffset = type.getSize(); | |
89 | |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
90 type = db.lookupType("MethodParametersElement"); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
91 methodParametersElementSize = type.getSize(); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
92 |
0 | 93 type = db.lookupType("CheckedExceptionElement"); |
94 checkedExceptionElementSize = type.getSize(); | |
95 | |
96 type = db.lookupType("LocalVariableTableElement"); | |
97 localVariableTableElementSize = type.getSize(); | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
98 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
99 type = db.lookupType("ExceptionTableElement"); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
100 exceptionTableElementSize = type.getSize(); |
0 | 101 } |
102 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
103 public ConstMethod(Address addr) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
104 super(addr); |
0 | 105 } |
106 | |
107 // Fields | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
108 private static MetadataField constants; |
0 | 109 private static CIntField constMethodSize; |
8031 | 110 private static CIntField flags; |
0 | 111 private static CIntField codeSize; |
112 private static CIntField nameIndex; | |
113 private static CIntField signatureIndex; | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
114 private static CIntField idnum; |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
115 private static CIntField maxStack; |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
116 private static CIntField maxLocals; |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
117 private static CIntField sizeOfParameters; |
0 | 118 |
119 // start of bytecode | |
120 private static long bytecodeOffset; | |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
121 private static long methodParametersElementSize; |
0 | 122 private static long checkedExceptionElementSize; |
123 private static long localVariableTableElementSize; | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
124 private static long exceptionTableElementSize; |
0 | 125 |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
126 public Method getMethod() { |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
127 InstanceKlass ik = (InstanceKlass)getConstants().getPoolHolder(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
128 MethodArray methods = ik.getMethods(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
129 return methods.at((int)getIdNum()); |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
130 } |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
131 |
0 | 132 // Accessors for declared fields |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
133 public ConstantPool getConstants() { |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
134 return (ConstantPool) constants.getValue(this); |
0 | 135 } |
136 | |
137 public long getConstMethodSize() { | |
138 return constMethodSize.getValue(this); | |
139 } | |
140 | |
8031 | 141 public long getFlags() { |
0 | 142 return flags.getValue(this); |
143 } | |
144 | |
145 public long getCodeSize() { | |
146 return codeSize.getValue(this); | |
147 } | |
148 | |
149 public long getNameIndex() { | |
150 return nameIndex.getValue(this); | |
151 } | |
152 | |
153 public long getSignatureIndex() { | |
154 return signatureIndex.getValue(this); | |
155 } | |
156 | |
157 public long getGenericSignatureIndex() { | |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
158 if (hasGenericSignature()) { |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
159 return getAddress().getCIntegerAt(offsetOfGenericSignatureIndex(), 2, true); |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
160 } else { |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
161 return 0; |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
162 } |
0 | 163 } |
164 | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
165 public long getIdNum() { |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
166 return idnum.getValue(this); |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
167 } |
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
3838
diff
changeset
|
168 |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
169 public long getMaxStack() { |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
170 return maxStack.getValue(this); |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
171 } |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
172 |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
173 public long getMaxLocals() { |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
174 return maxLocals.getValue(this); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
175 } |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
176 |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
177 public long getSizeOfParameters() { |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
178 return sizeOfParameters.getValue(this); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
179 } |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
180 |
0 | 181 public Symbol getName() { |
182 return getMethod().getName(); | |
183 } | |
184 | |
185 public Symbol getSignature() { | |
186 return getMethod().getSignature(); | |
187 } | |
188 | |
189 public Symbol getGenericSignature() { | |
190 return getMethod().getGenericSignature(); | |
191 } | |
192 | |
193 // bytecode accessors | |
194 | |
195 /** Get a bytecode or breakpoint at the given bci */ | |
196 public int getBytecodeOrBPAt(int bci) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
197 return getAddress().getJByteAt(bytecodeOffset + bci) & 0xFF; |
0 | 198 } |
199 | |
200 public byte getBytecodeByteArg(int bci) { | |
201 return (byte) getBytecodeOrBPAt(bci); | |
202 } | |
203 | |
204 /** Fetches a 16-bit big-endian ("Java ordered") value from the | |
205 bytecode stream */ | |
206 public short getBytecodeShortArg(int bci) { | |
207 int hi = getBytecodeOrBPAt(bci); | |
208 int lo = getBytecodeOrBPAt(bci + 1); | |
209 return (short) ((hi << 8) | lo); | |
210 } | |
211 | |
3838
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
212 /** 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
|
213 bytecode stream */ |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
214 public short getNativeShortArg(int bci) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
215 int hi = getBytecodeOrBPAt(bci); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
216 int lo = getBytecodeOrBPAt(bci + 1); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
217 if (VM.getVM().isBigEndian()) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
218 return (short) ((hi << 8) | lo); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
219 } else { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
220 return (short) ((lo << 8) | hi); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
221 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
222 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
223 |
0 | 224 /** Fetches a 32-bit big-endian ("Java ordered") value from the |
225 bytecode stream */ | |
226 public int getBytecodeIntArg(int bci) { | |
227 int b4 = getBytecodeOrBPAt(bci); | |
228 int b3 = getBytecodeOrBPAt(bci + 1); | |
229 int b2 = getBytecodeOrBPAt(bci + 2); | |
230 int b1 = getBytecodeOrBPAt(bci + 3); | |
231 | |
232 return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; | |
233 } | |
234 | |
3838
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
235 /** 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
|
236 bytecode stream */ |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
237 public int getNativeIntArg(int bci) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
238 int b4 = getBytecodeOrBPAt(bci); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
239 int b3 = getBytecodeOrBPAt(bci + 1); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
240 int b2 = getBytecodeOrBPAt(bci + 2); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
241 int b1 = getBytecodeOrBPAt(bci + 3); |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
242 |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
243 if (VM.getVM().isBigEndian()) { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
244 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
|
245 } else { |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
246 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
|
247 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
248 } |
6a991dcb52bb
7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents:
1552
diff
changeset
|
249 |
0 | 250 public byte[] getByteCode() { |
251 byte[] bc = new byte[ (int) getCodeSize() ]; | |
252 for( int i=0; i < bc.length; i++ ) | |
253 { | |
254 long offs = bytecodeOffset + i; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
255 bc[i] = getAddress().getJByteAt( offs ); |
0 | 256 } |
257 return bc; | |
258 } | |
259 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
260 public long getSize() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
261 return getConstMethodSize(); |
0 | 262 } |
263 | |
264 public void printValueOn(PrintStream tty) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
265 tty.print("ConstMethod " + getName().asString() + getSignature().asString() + "@" + getAddress()); |
0 | 266 } |
267 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
268 public void iterateFields(MetadataVisitor visitor) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
269 visitor.doMetadata(constants, true); |
0 | 270 visitor.doCInt(constMethodSize, true); |
8031 | 271 visitor.doCInt(flags, true); |
0 | 272 visitor.doCInt(codeSize, true); |
273 visitor.doCInt(nameIndex, true); | |
274 visitor.doCInt(signatureIndex, true); | |
275 visitor.doCInt(codeSize, true); | |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
276 visitor.doCInt(maxStack, true); |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
277 visitor.doCInt(maxLocals, true); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
278 visitor.doCInt(sizeOfParameters, true); |
0 | 279 } |
280 | |
281 // Accessors | |
282 | |
283 public boolean hasLineNumberTable() { | |
284 return (getFlags() & HAS_LINENUMBER_TABLE) != 0; | |
285 } | |
286 | |
287 public int getLineNumberFromBCI(int bci) { | |
288 if (!VM.getVM().isCore()) { | |
289 if (bci == DebugInformationRecorder.SYNCHRONIZATION_ENTRY_BCI) bci = 0; | |
290 } | |
291 | |
292 if (isNative()) { | |
293 return -1; | |
294 } | |
295 | |
296 if (Assert.ASSERTS_ENABLED) { | |
297 Assert.that(bci == 0 || 0 <= bci && bci < getCodeSize(), "illegal bci"); | |
298 } | |
299 int bestBCI = 0; | |
300 int bestLine = -1; | |
301 if (hasLineNumberTable()) { | |
302 // The line numbers are a short array of 2-tuples [start_pc, line_number]. | |
303 // Not necessarily sorted and not necessarily one-to-one. | |
304 CompressedLineNumberReadStream stream = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
305 new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); |
0 | 306 while (stream.readPair()) { |
307 if (stream.bci() == bci) { | |
308 // perfect match | |
309 return stream.line(); | |
310 } else { | |
311 // update best_bci/line | |
312 if (stream.bci() < bci && stream.bci() >= bestBCI) { | |
313 bestBCI = stream.bci(); | |
314 bestLine = stream.line(); | |
315 } | |
316 } | |
317 } | |
318 } | |
319 return bestLine; | |
320 } | |
321 | |
322 public LineNumberTableElement[] getLineNumberTable() { | |
323 if (Assert.ASSERTS_ENABLED) { | |
324 Assert.that(hasLineNumberTable(), | |
325 "should only be called if table is present"); | |
326 } | |
327 int len = getLineNumberTableLength(); | |
328 CompressedLineNumberReadStream stream = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
329 new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); |
0 | 330 LineNumberTableElement[] ret = new LineNumberTableElement[len]; |
331 | |
332 for (int idx = 0; idx < len; idx++) { | |
333 stream.readPair(); | |
334 ret[idx] = new LineNumberTableElement(stream.bci(), stream.line()); | |
335 } | |
336 return ret; | |
337 } | |
338 | |
339 public boolean hasLocalVariableTable() { | |
340 return (getFlags() & HAS_LOCALVARIABLE_TABLE) != 0; | |
341 } | |
342 | |
343 public Symbol getLocalVariableName(int bci, int slot) { | |
344 return getMethod().getLocalVariableName(bci, slot); | |
345 } | |
346 | |
347 /** Should only be called if table is present */ | |
348 public LocalVariableTableElement[] getLocalVariableTable() { | |
349 if (Assert.ASSERTS_ENABLED) { | |
350 Assert.that(hasLocalVariableTable(), "should only be called if table is present"); | |
351 } | |
352 LocalVariableTableElement[] ret = new LocalVariableTableElement[getLocalVariableTableLength()]; | |
353 long offset = offsetOfLocalVariableTable(); | |
354 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
|
355 ret[i] = new LocalVariableTableElement(getAddress(), offset); |
0 | 356 offset += localVariableTableElementSize; |
357 } | |
358 return ret; | |
359 } | |
360 | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
361 public boolean hasExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
362 return (getFlags() & HAS_EXCEPTION_TABLE) != 0; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
363 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
364 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
365 public ExceptionTableElement[] getExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
366 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
367 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
|
368 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
369 ExceptionTableElement[] ret = new ExceptionTableElement[getExceptionTableLength()]; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
370 long offset = offsetOfExceptionTable(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
371 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
|
372 ret[i] = new ExceptionTableElement(getAddress(), offset); |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
373 offset += exceptionTableElementSize; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
374 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
375 return ret; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
376 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
377 |
0 | 378 public boolean hasCheckedExceptions() { |
379 return (getFlags() & HAS_CHECKED_EXCEPTIONS) != 0; | |
380 } | |
381 | |
382 public CheckedExceptionElement[] getCheckedExceptions() { | |
383 if (Assert.ASSERTS_ENABLED) { | |
384 Assert.that(hasCheckedExceptions(), "should only be called if table is present"); | |
385 } | |
386 CheckedExceptionElement[] ret = new CheckedExceptionElement[getCheckedExceptionsLength()]; | |
387 long offset = offsetOfCheckedExceptions(); | |
388 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
|
389 ret[i] = new CheckedExceptionElement(getAddress(), offset); |
0 | 390 offset += checkedExceptionElementSize; |
391 } | |
392 return ret; | |
393 } | |
394 | |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
395 private boolean hasMethodParameters() { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
396 return (getFlags() & HAS_METHOD_PARAMETERS) != 0; |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
397 } |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
398 |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
399 private boolean hasGenericSignature() { |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
400 return (getFlags() & HAS_GENERIC_SIGNATURE) != 0; |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
401 } |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
402 |
8031 | 403 private boolean hasMethodAnnotations() { |
404 return (getFlags() & HAS_METHOD_ANNOTATIONS) != 0; | |
405 } | |
406 | |
407 private boolean hasParameterAnnotations() { | |
408 return (getFlags() & HAS_PARAMETER_ANNOTATIONS) != 0; | |
409 } | |
410 | |
411 private boolean hasDefaultAnnotations() { | |
412 return (getFlags() & HAS_DEFAULT_ANNOTATIONS) != 0; | |
413 } | |
414 | |
415 private boolean hasTypeAnnotations() { | |
416 return (getFlags() & HAS_TYPE_ANNOTATIONS) != 0; | |
417 } | |
418 | |
0 | 419 |
420 //--------------------------------------------------------------------------- | |
421 // Internals only below this point | |
422 // | |
423 | |
424 private boolean isNative() { | |
425 return getMethod().isNative(); | |
426 } | |
427 | |
428 // Offset of end of code | |
429 private long offsetOfCodeEnd() { | |
430 return bytecodeOffset + getCodeSize(); | |
431 } | |
432 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
433 // Offset of start of compressed line number table (see method.hpp) |
0 | 434 private long offsetOfCompressedLineNumberTable() { |
435 return offsetOfCodeEnd() + (isNative() ? 2 * VM.getVM().getAddressSize() : 0); | |
436 } | |
437 | |
8031 | 438 // Offset of last short in Method* before annotations, if present |
0 | 439 private long offsetOfLastU2Element() { |
8031 | 440 int offset = 0; |
441 if (hasMethodAnnotations()) offset++; | |
442 if (hasParameterAnnotations()) offset++; | |
443 if (hasTypeAnnotations()) offset++; | |
444 if (hasDefaultAnnotations()) offset++; | |
445 long wordSize = VM.getVM().getObjectHeap().getOopSize(); | |
446 return (getSize() * wordSize) - (offset * wordSize) - sizeofShort; | |
0 | 447 } |
448 | |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
449 // Offset of the generic signature index |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
450 private long offsetOfGenericSignatureIndex() { |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
451 return offsetOfLastU2Element(); |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
452 } |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
453 |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
454 private long offsetOfMethodParametersLength() { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
455 if (Assert.ASSERTS_ENABLED) { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
456 Assert.that(hasMethodParameters(), "should only be called if table is present"); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
457 } |
8031 | 458 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
459 offsetOfLastU2Element(); |
0 | 460 } |
461 | |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
462 private int getMethodParametersLength() { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
463 if (hasMethodParameters()) |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
464 return (int) getAddress().getCIntegerAt(offsetOfMethodParametersLength(), 2, true); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
465 else |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
466 return 0; |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
467 } |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
468 |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
469 // Offset of start of checked exceptions |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
470 private long offsetOfMethodParameters() { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
471 long offset = offsetOfMethodParametersLength(); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
472 long length = getMethodParametersLength(); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
473 if (Assert.ASSERTS_ENABLED) { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
474 Assert.that(length > 0, "should only be called if method parameter information is present"); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
475 } |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
476 offset -= length * methodParametersElementSize; |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
477 return offset; |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
478 } |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
479 |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
480 private long offsetOfCheckedExceptionsLength() { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
481 if (hasMethodParameters()) |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
482 return offsetOfMethodParameters() - sizeofShort; |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
483 else { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
484 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
485 offsetOfLastU2Element(); |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
486 } |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
487 } |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
488 |
0 | 489 private int getCheckedExceptionsLength() { |
490 if (hasCheckedExceptions()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
491 return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); |
0 | 492 } else { |
493 return 0; | |
494 } | |
495 } | |
496 | |
497 // Offset of start of checked exceptions | |
498 private long offsetOfCheckedExceptions() { | |
499 long offset = offsetOfCheckedExceptionsLength(); | |
500 long length = getCheckedExceptionsLength(); | |
501 if (Assert.ASSERTS_ENABLED) { | |
502 Assert.that(length > 0, "should only be called if table is present"); | |
503 } | |
504 offset -= length * checkedExceptionElementSize; | |
505 return offset; | |
506 } | |
507 | |
508 private int getLineNumberTableLength() { | |
509 int len = 0; | |
510 if (hasLineNumberTable()) { | |
511 CompressedLineNumberReadStream stream = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
512 new CompressedLineNumberReadStream(getAddress(), (int) offsetOfCompressedLineNumberTable()); |
0 | 513 while (stream.readPair()) { |
514 len += 1; | |
515 } | |
516 } | |
517 return len; | |
518 } | |
519 | |
520 private int getLocalVariableTableLength() { | |
521 if (hasLocalVariableTable()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
522 return (int) getAddress().getCIntegerAt(offsetOfLocalVariableTableLength(), 2, true); |
0 | 523 } else { |
524 return 0; | |
525 } | |
526 } | |
527 | |
528 // Offset of local variable table length | |
529 private long offsetOfLocalVariableTableLength() { | |
530 if (Assert.ASSERTS_ENABLED) { | |
531 Assert.that(hasLocalVariableTable(), "should only be called if table is present"); | |
532 } | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
533 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
534 if (hasExceptionTable()) { |
8031 | 535 return offsetOfExceptionTable() - sizeofShort; |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
536 } else if (hasCheckedExceptions()) { |
8031 | 537 return offsetOfCheckedExceptions() - sizeofShort; |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
538 } else if (hasMethodParameters()) { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
539 return offsetOfMethodParameters() - sizeofShort; |
0 | 540 } else { |
8031 | 541 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
542 offsetOfLastU2Element(); |
0 | 543 } |
544 } | |
545 | |
546 private long offsetOfLocalVariableTable() { | |
547 long offset = offsetOfLocalVariableTableLength(); | |
548 long length = getLocalVariableTableLength(); | |
549 if (Assert.ASSERTS_ENABLED) { | |
550 Assert.that(length > 0, "should only be called if table is present"); | |
551 } | |
552 offset -= length * localVariableTableElementSize; | |
553 return offset; | |
554 } | |
555 | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
556 private int getExceptionTableLength() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
557 if (hasExceptionTable()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6213
diff
changeset
|
558 return (int) getAddress().getCIntegerAt(offsetOfExceptionTableLength(), 2, true); |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
559 } else { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
560 return 0; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
561 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
562 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
563 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
564 private long offsetOfExceptionTableLength() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
565 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
566 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
|
567 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
568 if (hasCheckedExceptions()) { |
8031 | 569 return offsetOfCheckedExceptions() - sizeofShort; |
12939
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
570 } else if (hasMethodParameters()) { |
d2db09f281ca
8005810: Update Hotspot Serviceability Agent for Method Parameter Reflection and Generic Type Signature Data
dsamersoff
parents:
8031
diff
changeset
|
571 return offsetOfMethodParameters() - sizeofShort; |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
572 } else { |
8031 | 573 return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
574 offsetOfLastU2Element(); |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
575 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
576 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
577 |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
578 private long offsetOfExceptionTable() { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
579 long offset = offsetOfExceptionTableLength(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
580 long length = getExceptionTableLength(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
581 if (Assert.ASSERTS_ENABLED) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
582 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
|
583 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
584 offset -= length * exceptionTableElementSize; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
585 return offset; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
586 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6123
diff
changeset
|
587 |
0 | 588 } |