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