annotate agent/src/share/classes/sun/jvm/hotspot/oops/Method.java @ 6213:8150fa46d2ed

7178145: Change constMethodOop::_exception_table to optionally inlined u2 table. Summary: Change constMethodOop::_exception_table to optionally inlined u2 table. Reviewed-by: bdelsart, coleenp, kamg
author jiangli
date Tue, 26 Jun 2012 19:08:44 -0400
parents 2fe087c3e814
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3939
diff changeset
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.oops;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // A Method represents a Java method
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public class Method extends Oop {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
44 }
a61af66fc99e Initial load
duke
parents:
diff changeset
45 });
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 Type type = db.lookupType("methodOopDesc");
a61af66fc99e Initial load
duke
parents:
diff changeset
50 constMethod = new OopField(type.getOopField("_constMethod"), 0);
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
51 methodData = new OopField(type.getOopField("_method_data"), 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 methodSize = new CIntField(type.getCIntegerField("_method_size"), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 code = type.getAddressField("_code");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 vtableIndex = new CIntField(type.getCIntegerField("_vtable_index"), 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 invocationCounter = new CIntField(type.getCIntegerField("_invocation_counter"), 0);
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
61 backedgeCounter = new CIntField(type.getCIntegerField("_backedge_counter"), 0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 bytecodeOffset = type.getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
64
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
65 interpreterThrowoutCountField = new CIntField(type.getCIntegerField("_interpreter_throwout_count"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
66 interpreterInvocationCountField = new CIntField(type.getCIntegerField("_interpreter_invocation_count"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
67
0
a61af66fc99e Initial load
duke
parents:
diff changeset
68 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
69 interpreterEntry = type.getAddressField("_interpreter_entry");
a61af66fc99e Initial load
duke
parents:
diff changeset
70 fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point");
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 */
a61af66fc99e Initial load
duke
parents:
diff changeset
73 objectInitializerName = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 classInitializerName = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 Method(OopHandle handle, ObjectHeap heap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 super(handle, heap);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 public boolean isMethod() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Fields
a61af66fc99e Initial load
duke
parents:
diff changeset
84 private static OopField constMethod;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
85 private static OopField methodData;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 private static CIntField methodSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 private static CIntField maxStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 private static CIntField maxLocals;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 private static CIntField sizeOfParameters;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 private static CIntField accessFlags;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 private static CIntField vtableIndex;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 private static CIntField invocationCounter;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
93 private static CIntField backedgeCounter;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94 private static long bytecodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 private static AddressField code;
a61af66fc99e Initial load
duke
parents:
diff changeset
97
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
98 private static CIntField interpreterThrowoutCountField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
99 private static CIntField interpreterInvocationCountField;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
100
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // constant method names - <init>, <clinit>
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Initialized lazily to avoid initialization ordering dependencies between Method and SymbolTable
a61af66fc99e Initial load
duke
parents:
diff changeset
103 private static Symbol objectInitializerName;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 private static Symbol classInitializerName;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 private static Symbol objectInitializerName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 if (objectInitializerName == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 objectInitializerName = VM.getVM().getSymbolTable().probe("<init>");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return objectInitializerName;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 private static Symbol classInitializerName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (classInitializerName == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 classInitializerName = VM.getVM().getSymbolTable().probe("<clinit>");
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return classInitializerName;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
120 private static AddressCField interpreterEntry;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 private static AddressCField fromCompiledCodeEntryPoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 */
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Accessors for declared fields
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public ConstMethod getConstMethod() { return (ConstMethod) constMethod.getValue(this); }
6123
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3939
diff changeset
126 public ConstantPool getConstants() {
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3939
diff changeset
127 return getConstMethod().getConstants();
2fe087c3e814 7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents: 3939
diff changeset
128 }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
129 public MethodData getMethodData() { return (MethodData) methodData.getValue(this); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130 /** WARNING: this is in words, not useful in this system; use getObjectSize() instead */
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public long getMethodSize() { return methodSize.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public long getMaxStack() { return maxStack.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public long getMaxLocals() { return maxLocals.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 public long getSizeOfParameters() { return sizeOfParameters.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public long getNameIndex() { return getConstMethod().getNameIndex(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public long getSignatureIndex() { return getConstMethod().getSignatureIndex(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public long getGenericSignatureIndex() { return getConstMethod().getGenericSignatureIndex(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public long getAccessFlags() { return accessFlags.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public long getCodeSize() { return getConstMethod().getCodeSize(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public long getVtableIndex() { return vtableIndex.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public long getInvocationCounter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 Assert.that(!VM.getVM().isCore(), "must not be used in core build");
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return invocationCounter.getValue(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
147 public long getBackedgeCounter() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
148 if (Assert.ASSERTS_ENABLED) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
149 Assert.that(!VM.getVM().isCore(), "must not be used in core build");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
150 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
151 return backedgeCounter.getValue(this);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
152 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // get associated compiled native method, if available, else return null.
a61af66fc99e Initial load
duke
parents:
diff changeset
155 public NMethod getNativeMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 Address addr = code.getValue(getHandle());
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return (NMethod) VMObjectFactory.newObject(NMethod.class, addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Convenience routine
a61af66fc99e Initial load
duke
parents:
diff changeset
161 public AccessFlags getAccessFlagsObj() {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return new AccessFlags(getAccessFlags());
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 /** Get a bytecode or breakpoint at the given bci */
a61af66fc99e Initial load
duke
parents:
diff changeset
166 public int getBytecodeOrBPAt(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return getConstMethod().getBytecodeOrBPAt(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 /** Fetch the original non-breakpoint bytecode at the specified
a61af66fc99e Initial load
duke
parents:
diff changeset
171 bci. It is required that there is currently a bytecode at this
a61af66fc99e Initial load
duke
parents:
diff changeset
172 bci. */
a61af66fc99e Initial load
duke
parents:
diff changeset
173 public int getOrigBytecodeAt(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 BreakpointInfo bp = ((InstanceKlass) getMethodHolder()).getBreakpoints();
a61af66fc99e Initial load
duke
parents:
diff changeset
175 for (; bp != null; bp = bp.getNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (bp.match(this, bci)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 return bp.getOrigBytecode();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 System.err.println("Requested bci " + bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 for (; bp != null; bp = bp.getNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 System.err.println("Breakpoint at bci " + bp.getBCI() + ", bytecode " +
a61af66fc99e Initial load
duke
parents:
diff changeset
183 bp.getOrigBytecode());
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 Assert.that(false, "Should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return -1; // not reached
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 public byte getBytecodeByteArg(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return getConstMethod().getBytecodeByteArg(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 /** Fetches a 16-bit big-endian ("Java ordered") value from the
a61af66fc99e Initial load
duke
parents:
diff changeset
194 bytecode stream */
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public short getBytecodeShortArg(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return getConstMethod().getBytecodeShortArg(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
3838
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
199 /** 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: 2426
diff changeset
200 bytecode stream */
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
201 public short getNativeShortArg(int bci) {
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
202 return getConstMethod().getNativeShortArg(bci);
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
203 }
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
204
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205 /** Fetches a 32-bit big-endian ("Java ordered") value from the
a61af66fc99e Initial load
duke
parents:
diff changeset
206 bytecode stream */
a61af66fc99e Initial load
duke
parents:
diff changeset
207 public int getBytecodeIntArg(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 return getConstMethod().getBytecodeIntArg(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
3838
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
211 /** 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: 2426
diff changeset
212 bytecode stream */
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
213 public int getNativeIntArg(int bci) {
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
214 return getConstMethod().getNativeIntArg(bci);
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
215 }
6a991dcb52bb 7012081: JSR 292: SA-JDI can't read MH/MT/Indy ConstantPool entries
never
parents: 2426
diff changeset
216
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 public byte[] getByteCode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 return getConstMethod().getByteCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
222 public Address getCode() { return codeField.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 public Address getInterpreterEntry() { return interpreterEntryField.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 public Address getFromCompiledCodeEntryPoint() { return fromCompiledCodeEntryPointField.getValue(this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 */
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Accessors
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1552
diff changeset
227 public Symbol getName() { return getConstants().getSymbolAt(getNameIndex()); }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1552
diff changeset
228 public Symbol getSignature() { return getConstants().getSymbolAt(getSignatureIndex()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
229 public Symbol getGenericSignature() {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 long index = getGenericSignatureIndex();
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1552
diff changeset
231 return (index != 0L) ? getConstants().getSymbolAt(index) : null;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // Method holder (the Klass holding this method)
a61af66fc99e Initial load
duke
parents:
diff changeset
235 public Klass getMethodHolder() { return getConstants().getPoolHolder(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Access flags
a61af66fc99e Initial load
duke
parents:
diff changeset
238 public boolean isPublic() { return getAccessFlagsObj().isPublic(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 public boolean isPrivate() { return getAccessFlagsObj().isPrivate(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 public boolean isProtected() { return getAccessFlagsObj().isProtected(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 public boolean isPackagePrivate() { AccessFlags af = getAccessFlagsObj();
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return (!af.isPublic() && !af.isPrivate() && !af.isProtected()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 public boolean isStatic() { return getAccessFlagsObj().isStatic(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public boolean isFinal() { return getAccessFlagsObj().isFinal(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public boolean isSynchronized() { return getAccessFlagsObj().isSynchronized(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
246 public boolean isBridge() { return getAccessFlagsObj().isBridge(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
247 public boolean isVarArgs() { return getAccessFlagsObj().isVarArgs(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
248 public boolean isNative() { return getAccessFlagsObj().isNative(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 public boolean isAbstract() { return getAccessFlagsObj().isAbstract(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
250 public boolean isStrict() { return getAccessFlagsObj().isStrict(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
251 public boolean isSynthetic() { return getAccessFlagsObj().isSynthetic(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 public boolean isConstructor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 return (!isStatic()) && getName().equals(objectInitializerName());
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 public boolean isStaticInitializer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return isStatic() && getName().equals(classInitializerName());
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 public boolean isObsolete() {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 return getAccessFlagsObj().isObsolete();
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 public OopMapCacheEntry getMaskFor(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 OopMapCacheEntry entry = new OopMapCacheEntry();
a61af66fc99e Initial load
duke
parents:
diff changeset
267 entry.fill(this, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 public long getObjectSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 return getMethodSize() * getHeap().getOopSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 public void printValueOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 tty.print("Method " + getName().asString() + getSignature().asString() + "@" + getHandle());
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 public void iterateFields(OopVisitor visitor, boolean doVMFields) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 super.iterateFields(visitor, doVMFields);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 if (doVMFields) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 visitor.doOop(constMethod, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 visitor.doCInt(methodSize, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 visitor.doCInt(maxStack, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 visitor.doCInt(maxLocals, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 visitor.doCInt(sizeOfParameters, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 visitor.doCInt(accessFlags, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 public boolean hasLineNumberTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 return getConstMethod().hasLineNumberTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 public int getLineNumberFromBCI(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 return getConstMethod().getLineNumberFromBCI(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 public LineNumberTableElement[] getLineNumberTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 return getConstMethod().getLineNumberTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 public boolean hasLocalVariableTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
304 return getConstMethod().hasLocalVariableTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 /** Should only be called if table is present */
a61af66fc99e Initial load
duke
parents:
diff changeset
308 public LocalVariableTableElement[] getLocalVariableTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 return getConstMethod().getLocalVariableTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 public Symbol getLocalVariableName(int bci, int slot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 if (! hasLocalVariableTable()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 LocalVariableTableElement[] locals = getLocalVariableTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
318 for (int l = 0; l < locals.length; l++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 LocalVariableTableElement local = locals[l];
a61af66fc99e Initial load
duke
parents:
diff changeset
320 if ((bci >= local.getStartBCI()) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
321 (bci < (local.getStartBCI() + local.getLength())) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
322 slot == local.getSlot()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 return getConstants().getSymbolAt(local.getNameCPIndex());
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329
6213
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
330 public boolean hasExceptionTable() {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
331 return getConstMethod().hasExceptionTable();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
332 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
333
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
334 public ExceptionTableElement[] getExceptionTable() {
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
335 return getConstMethod().getExceptionTable();
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
336 }
8150fa46d2ed 7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents: 6123
diff changeset
337
0
a61af66fc99e Initial load
duke
parents:
diff changeset
338 public boolean hasCheckedExceptions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 return getConstMethod().hasCheckedExceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 /** Should only be called if table is present */
a61af66fc99e Initial load
duke
parents:
diff changeset
343 public CheckedExceptionElement[] getCheckedExceptions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 return getConstMethod().getCheckedExceptions();
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 /** Returns name and signature in external form for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
348 purposes */
a61af66fc99e Initial load
duke
parents:
diff changeset
349 public String externalNameAndSignature() {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 final StringBuffer buf = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
351 buf.append(getMethodHolder().getName().asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
352 buf.append(".");
a61af66fc99e Initial load
duke
parents:
diff changeset
353 buf.append(getName().asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
354 buf.append("(");
a61af66fc99e Initial load
duke
parents:
diff changeset
355 new SignatureConverter(getSignature(), buf).iterateParameters();
a61af66fc99e Initial load
duke
parents:
diff changeset
356 buf.append(")");
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return buf.toString().replace('/', '.');
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
359 public int interpreterThrowoutCount() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
360 return (int) interpreterThrowoutCountField.getValue(getHandle());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
361 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
362
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
363 public int interpreterInvocationCount() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
364 return (int) interpreterInvocationCountField.getValue(getHandle());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3838
diff changeset
365 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
366 }