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