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