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