annotate agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java @ 1040:873ec3787992

6892186: SA does not dump debug info for scalar replaced objects Summary: Implement scalar replaced objects debug info dump in SA. Reviewed-by: twisti
author kvn
date Wed, 21 Oct 2009 09:15:33 -0700
parents 148e5441d916
children c18cbe5936b8 1a5913bf5e19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
931
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 0
diff changeset
2 * Copyright 2000-2009 Sun Microsystems, Inc. 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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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.code;
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.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 public class NMethod extends CodeBlob {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private static long pcDescSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private static CIntegerField zombieInstructionSizeField;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private static sun.jvm.hotspot.types.OopField methodField;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 /** != InvocationEntryBci if this nmethod is an on-stack replacement method */
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private static CIntegerField entryBCIField;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 /** To support simple linked-list chaining of nmethods */
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
43 private static AddressField osrLinkField;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
44 private static AddressField scavengeRootLinkField;
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
45 private static JByteField scavengeRootStateField;
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
46
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 /** Offsets for different nmethod parts */
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static CIntegerField exceptionOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private static CIntegerField deoptOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static CIntegerField origPCOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static CIntegerField stubOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private static CIntegerField scopesDataOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private static CIntegerField scopesPCsOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private static CIntegerField dependenciesOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 private static CIntegerField handlerTableOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 private static CIntegerField nulChkTableOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private static CIntegerField nmethodEndOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 /** Offsets for entry points */
a61af66fc99e Initial load
duke
parents:
diff changeset
60 /** Entry point with class check */
a61af66fc99e Initial load
duke
parents:
diff changeset
61 private static AddressField entryPointField;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 /** Entry point without class check */
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private static AddressField verifiedEntryPointField;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 /** Entry point for on stack replacement */
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private static AddressField osrEntryPointField;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // FIXME: add access to flags (how?)
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 /** NMethod Flushing lock (if non-zero, then the nmethod is not removed) */
a61af66fc99e Initial load
duke
parents:
diff changeset
70 private static JIntField lockCountField;
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 /** not_entrant method removal. Each mark_sweep pass will update
a61af66fc99e Initial load
duke
parents:
diff changeset
73 this mark to current sweep invocation count if it is seen on the
a61af66fc99e Initial load
duke
parents:
diff changeset
74 stack. An not_entrant method can be removed when there is no
a61af66fc99e Initial load
duke
parents:
diff changeset
75 more activations, i.e., when the _stack_traversal_mark is less than
a61af66fc99e Initial load
duke
parents:
diff changeset
76 current sweep traversal index. */
a61af66fc99e Initial load
duke
parents:
diff changeset
77 private static CIntegerField stackTraversalMarkField;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 });
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 Type type = db.lookupType("nmethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 zombieInstructionSizeField = type.getCIntegerField("_zombie_instruction_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
91 methodField = type.getOopField("_method");
a61af66fc99e Initial load
duke
parents:
diff changeset
92 entryBCIField = type.getCIntegerField("_entry_bci");
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
93 osrLinkField = type.getAddressField("_osr_link");
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
94 scavengeRootLinkField = type.getAddressField("_scavenge_root_link");
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
95 scavengeRootStateField = type.getJByteField("_scavenge_root_state");
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
96
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97 exceptionOffsetField = type.getCIntegerField("_exception_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
98 deoptOffsetField = type.getCIntegerField("_deoptimize_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
99 origPCOffsetField = type.getCIntegerField("_orig_pc_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
100 stubOffsetField = type.getCIntegerField("_stub_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
101 scopesDataOffsetField = type.getCIntegerField("_scopes_data_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 scopesPCsOffsetField = type.getCIntegerField("_scopes_pcs_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
103 dependenciesOffsetField = type.getCIntegerField("_dependencies_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 handlerTableOffsetField = type.getCIntegerField("_handler_table_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 nulChkTableOffsetField = type.getCIntegerField("_nul_chk_table_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
106 nmethodEndOffsetField = type.getCIntegerField("_nmethod_end_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 entryPointField = type.getAddressField("_entry_point");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 verifiedEntryPointField = type.getAddressField("_verified_entry_point");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 osrEntryPointField = type.getAddressField("_osr_entry_point");
a61af66fc99e Initial load
duke
parents:
diff changeset
110 lockCountField = type.getJIntField("_lock_count");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 stackTraversalMarkField = type.getCIntegerField("_stack_traversal_mark");
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 pcDescSize = db.lookupType("PcDesc").getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public NMethod(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public Address getAddress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public Method getMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return (Method) VM.getVM().getObjectHeap().newOop(methodField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Type info
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public boolean isNMethod() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public boolean isJavaMethod() { return !getMethod().isNative(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public boolean isNativeMethod() { return getMethod().isNative(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 public boolean isOSRMethod() { return getEntryBCI() != VM.getVM().getInvocationEntryBCI(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 /** Boundaries for different parts */
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public Address constantsBegin() { return instructionsBegin(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public Address constantsEnd() { return getEntryPoint(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public Address codeBegin() { return getEntryPoint(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public Address codeEnd() { return headerBegin().addOffsetTo(getStubOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public Address exceptionBegin() { return headerBegin().addOffsetTo(getExceptionOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 public Address deoptBegin() { return headerBegin().addOffsetTo(getDeoptOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public Address stubBegin() { return headerBegin().addOffsetTo(getStubOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 public Address stubEnd() { return headerBegin().addOffsetTo(getScopesDataOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 public Address scopesDataBegin() { return headerBegin().addOffsetTo(getScopesDataOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 public Address scopesDataEnd() { return headerBegin().addOffsetTo(getScopesPCsOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public Address scopesPCsBegin() { return headerBegin().addOffsetTo(getScopesPCsOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 public Address scopesPCsEnd() { return headerBegin().addOffsetTo(getDependenciesOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 public Address dependenciesBegin() { return headerBegin().addOffsetTo(getDependenciesOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public Address dependenciesEnd() { return headerBegin().addOffsetTo(getHandlerTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 public Address handlerTableBegin() { return headerBegin().addOffsetTo(getHandlerTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public Address handlerTableEnd() { return headerBegin().addOffsetTo(getNulChkTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 public Address nulChkTableBegin() { return headerBegin().addOffsetTo(getNulChkTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public Address nulChkTableEnd() { return headerBegin().addOffsetTo(getNMethodEndOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 public int constantsSize() { return (int) constantsEnd() .minus(constantsBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 public int codeSize() { return (int) codeEnd() .minus(codeBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public int stubSize() { return (int) stubEnd() .minus(stubBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 public int scopesDataSize() { return (int) scopesDataEnd() .minus(scopesDataBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 public int scopesPCsSize() { return (int) scopesPCsEnd() .minus(scopesPCsBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 public int dependenciesSize() { return (int) dependenciesEnd().minus(dependenciesBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 public int handlerTableSize() { return (int) handlerTableEnd().minus(handlerTableBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public int nulChkTableSize() { return (int) nulChkTableEnd() .minus(nulChkTableBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public int origPCOffset() { return (int) origPCOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 public int totalSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return
a61af66fc99e Initial load
duke
parents:
diff changeset
168 constantsSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
169 codeSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
170 stubSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
171 scopesDataSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
172 scopesPCsSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
173 dependenciesSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
174 handlerTableSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
175 nulChkTableSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 public boolean constantsContains (Address addr) { return constantsBegin() .lessThanOrEqual(addr) && constantsEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 public boolean codeContains (Address addr) { return codeBegin() .lessThanOrEqual(addr) && codeEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public boolean stubContains (Address addr) { return stubBegin() .lessThanOrEqual(addr) && stubEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public boolean scopesDataContains (Address addr) { return scopesDataBegin() .lessThanOrEqual(addr) && scopesDataEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 public boolean scopesPCsContains (Address addr) { return scopesPCsBegin() .lessThanOrEqual(addr) && scopesPCsEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public boolean handlerTableContains(Address addr) { return handlerTableBegin().lessThanOrEqual(addr) && handlerTableEnd().greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 public boolean nulChkTableContains (Address addr) { return nulChkTableBegin() .lessThanOrEqual(addr) && nulChkTableEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 /** Entry points */
a61af66fc99e Initial load
duke
parents:
diff changeset
187 public Address getEntryPoint() { return entryPointField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 public Address getVerifiedEntryPoint() { return verifiedEntryPointField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // FIXME: add interpreter_entry_point()
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // FIXME: add lazy_interpreter_entry_point() for C2
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // **********
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // * FIXME: * ADD ACCESS TO FLAGS!!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // **********
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // public boolean isInUse();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // public boolean isAlive();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // public boolean isNotEntrant();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // public boolean isZombie();
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // ********************************
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // * MAJOR FIXME: MAJOR HACK HERE *
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // ********************************
a61af66fc99e Initial load
duke
parents:
diff changeset
204 public boolean isZombie() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // public boolean isUnloaded();
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // public boolean isYoung();
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // public boolean isOld();
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // public int age();
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // public boolean isMarkedForDeoptimization();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // public boolean isMarkedForUnloading();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // public boolean isMarkedForReclamation();
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // public int level();
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // public int version();
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // FIXME: add mutators for above
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // FIXME: add exception cache access?
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 /** On-stack replacement support */
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // FIXME: add mutators
a61af66fc99e Initial load
duke
parents:
diff changeset
221 public int getOSREntryBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 Assert.that(getEntryBCI() != VM.getVM().getInvocationEntryBCI(), "wrong kind of nmethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 return getEntryBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
228 public NMethod getOSRLink() {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
229 return (NMethod) VMObjectFactory.newObject(NMethod.class, osrLinkField.getValue(addr));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
232 public NMethod getScavengeRootLink() {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
233 return (NMethod) VMObjectFactory.newObject(NMethod.class, scavengeRootLinkField.getValue(addr));
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
234 }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
235
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
236 public int getScavengeRootState() {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
237 return (int) scavengeRootStateField.getValue(addr);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
238 }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
239
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
240
0
a61af66fc99e Initial load
duke
parents:
diff changeset
241 /** Tells whether frames described by this nmethod can be
a61af66fc99e Initial load
duke
parents:
diff changeset
242 deoptimized. Note: native wrappers cannot be deoptimized. */
a61af66fc99e Initial load
duke
parents:
diff changeset
243 public boolean canBeDeoptimized() { return isJavaMethod(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // FIXME: add inline cache support
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // FIXME: add flush()
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 public boolean isLockedByVM() { return lockCountField.getValue(addr) > 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // FIXME: add mark_as_seen_on_stack
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // FIXME: add can_not_entrant_be_converted
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // FIXME: add GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // void follow_roots_or_mark_for_unloading(bool unloading_occurred, bool& marked_for_unloading);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // void follow_root_or_mark_for_unloading(oop* root, bool unloading_occurred, bool& marked_for_unloading);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, void f(oop*));
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // void adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 /** Finds a PCDesc with real-pc equal to "pc" */
a61af66fc99e Initial load
duke
parents:
diff changeset
260 public PCDesc getPCDescAt(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // FIXME: consider adding cache like the one down in the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
262 for (Address p = scopesPCsBegin(); p.lessThan(scopesPCsEnd()); p = p.addOffsetTo(pcDescSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 PCDesc pcDesc = new PCDesc(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (pcDesc.getRealPC(this).equals(pc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 return pcDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 /** ScopeDesc for an instruction */
a61af66fc99e Initial load
duke
parents:
diff changeset
272 public ScopeDesc getScopeDescAt(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 PCDesc pd = getPCDescAt(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 Assert.that(pd != null, "scope must be present");
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
277 return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 /** This is only for use by the debugging system, and is only
a61af66fc99e Initial load
duke
parents:
diff changeset
281 intended for use in the topmost frame, where we are not
a61af66fc99e Initial load
duke
parents:
diff changeset
282 guaranteed to be at a PC for which we have a PCDesc. It finds
a61af66fc99e Initial load
duke
parents:
diff changeset
283 the PCDesc with realPC closest to the current PC. */
a61af66fc99e Initial load
duke
parents:
diff changeset
284 public PCDesc getPCDescNearDbg(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 PCDesc bestGuessPCDesc = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 long bestDistance = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 for (Address p = scopesPCsBegin(); p.lessThan(scopesPCsEnd()); p = p.addOffsetTo(pcDescSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 PCDesc pcDesc = new PCDesc(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // In case pc is null
a61af66fc99e Initial load
duke
parents:
diff changeset
290 long distance = -pcDesc.getRealPC(this).minus(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
291 if ((bestGuessPCDesc == null) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
292 ((distance >= 0) && (distance < bestDistance))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 bestGuessPCDesc = pcDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
294 bestDistance = distance;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 return bestGuessPCDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 /** This is only for use by the debugging system, and is only
a61af66fc99e Initial load
duke
parents:
diff changeset
301 intended for use in the topmost frame, where we are not
a61af66fc99e Initial load
duke
parents:
diff changeset
302 guaranteed to be at a PC for which we have a PCDesc. It finds
a61af66fc99e Initial load
duke
parents:
diff changeset
303 the ScopeDesc closest to the current PC. NOTE that this may
a61af66fc99e Initial load
duke
parents:
diff changeset
304 return NULL for compiled methods which don't have any
a61af66fc99e Initial load
duke
parents:
diff changeset
305 ScopeDescs! */
a61af66fc99e Initial load
duke
parents:
diff changeset
306 public ScopeDesc getScopeDescNearDbg(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 PCDesc pd = getPCDescNearDbg(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if (pd == null) return null;
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
309 return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
312 public Map/*<Address, PCDesc>*/ getSafepoints() {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
313 Map safepoints = new HashMap(); // Map<Address, PCDesc>
0
a61af66fc99e Initial load
duke
parents:
diff changeset
314 sun.jvm.hotspot.debugger.Address p = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 for (p = scopesPCsBegin(); p.lessThan(scopesPCsEnd());
a61af66fc99e Initial load
duke
parents:
diff changeset
316 p = p.addOffsetTo(pcDescSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 PCDesc pcDesc = new PCDesc(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
318 sun.jvm.hotspot.debugger.Address pc = pcDesc.getRealPC(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 safepoints.put(pc, pcDesc);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return safepoints;
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // FIXME: add getPCOffsetForBCI()
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // FIXME: add embeddedOopAt()
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // FIXME: add isDependentOn()
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // FIXME: add isPatchableAt()
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 /** Support for code generation. Only here for proof-of-concept. */
a61af66fc99e Initial load
duke
parents:
diff changeset
330 public static int getEntryPointOffset() { return (int) entryPointField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 public static int getVerifiedEntryPointOffset() { return (int) verifiedEntryPointField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
332 public static int getOSREntryPointOffset() { return (int) osrEntryPointField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
333 public static int getEntryBCIOffset() { return (int) entryBCIField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
334 /** NOTE: renamed from "method_offset_in_bytes" */
a61af66fc99e Initial load
duke
parents:
diff changeset
335 public static int getMethodOffset() { return (int) methodField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 printOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 Method method = getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 return "NMethod for " +
a61af66fc99e Initial load
duke
parents:
diff changeset
344 method.getMethodHolder().getName().asString() + "." +
a61af66fc99e Initial load
duke
parents:
diff changeset
345 method.getName().asString() + method.getSignature().asString() + "==>n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
346 super.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 public String flagsToString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // FIXME need access to flags...
a61af66fc99e Initial load
duke
parents:
diff changeset
351 return "";
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 public String getName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 Method method = getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
356 return "NMethod for " +
a61af66fc99e Initial load
duke
parents:
diff changeset
357 method.getMethodHolder().getName().asString() + "." +
a61af66fc99e Initial load
duke
parents:
diff changeset
358 method.getName().asString() +
a61af66fc99e Initial load
duke
parents:
diff changeset
359 method.getSignature().asString();
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
364 //
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 private int getEntryBCI() { return (int) entryBCIField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
367 private int getExceptionOffset() { return (int) exceptionOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
368 private int getDeoptOffset() { return (int) deoptOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
369 private int getStubOffset() { return (int) stubOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
370 private int getScopesDataOffset() { return (int) scopesDataOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
371 private int getScopesPCsOffset() { return (int) scopesPCsOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
372 private int getDependenciesOffset() { return (int) dependenciesOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
373 private int getHandlerTableOffset() { return (int) handlerTableOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
374 private int getNulChkTableOffset() { return (int) nulChkTableOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
375 private int getNMethodEndOffset() { return (int) nmethodEndOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }