annotate agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java @ 10197:7b23cb975cf2

8011675: adding compilation level to replay data Reviewed-by: kvn, vlivanov
author iignatyev
date Thu, 25 Apr 2013 11:09:24 -0700
parents bd7a7ce2e264
children de6a9e811145
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
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: 1040
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1040
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: 1040
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.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;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
38 private static AddressField methodField;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 /** != InvocationEntryBci if this nmethod is an on-stack replacement method */
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private static CIntegerField entryBCIField;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 /** 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
42 private static AddressField osrLinkField;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
43 private static AddressField scavengeRootLinkField;
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
44 private static JByteField scavengeRootStateField;
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
45
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46 /** Offsets for different nmethod parts */
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private static CIntegerField exceptionOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static CIntegerField deoptOffsetField;
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
49 private static CIntegerField deoptMhOffsetField;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static CIntegerField origPCOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static CIntegerField stubOffsetField;
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
52 private static CIntegerField oopsOffsetField;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
53 private static CIntegerField metadataOffsetField;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private static CIntegerField scopesDataOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 private static CIntegerField scopesPCsOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 private static CIntegerField dependenciesOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private static CIntegerField handlerTableOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private static CIntegerField nulChkTableOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private static CIntegerField nmethodEndOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 /** Offsets for entry points */
a61af66fc99e Initial load
duke
parents:
diff changeset
62 /** Entry point with class check */
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private static AddressField entryPointField;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 /** Entry point without class check */
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private static AddressField verifiedEntryPointField;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 /** Entry point for on stack replacement */
a61af66fc99e Initial load
duke
parents:
diff changeset
67 private static AddressField osrEntryPointField;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // FIXME: add access to flags (how?)
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 /** NMethod Flushing lock (if non-zero, then the nmethod is not removed) */
a61af66fc99e Initial load
duke
parents:
diff changeset
72 private static JIntField lockCountField;
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 /** not_entrant method removal. Each mark_sweep pass will update
a61af66fc99e Initial load
duke
parents:
diff changeset
75 this mark to current sweep invocation count if it is seen on the
a61af66fc99e Initial load
duke
parents:
diff changeset
76 stack. An not_entrant method can be removed when there is no
a61af66fc99e Initial load
duke
parents:
diff changeset
77 more activations, i.e., when the _stack_traversal_mark is less than
a61af66fc99e Initial load
duke
parents:
diff changeset
78 current sweep traversal index. */
a61af66fc99e Initial load
duke
parents:
diff changeset
79 private static CIntegerField stackTraversalMarkField;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
10197
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 6972
diff changeset
81 private static CIntegerField compLevelField;
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 6972
diff changeset
82
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 });
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 Type type = db.lookupType("nmethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
93
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
94 methodField = type.getAddressField("_method");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
95 entryBCIField = type.getCIntegerField("_entry_bci");
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
96 osrLinkField = type.getAddressField("_osr_link");
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
97 scavengeRootLinkField = type.getAddressField("_scavenge_root_link");
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
98 scavengeRootStateField = type.getJByteField("_scavenge_root_state");
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
99
0
a61af66fc99e Initial load
duke
parents:
diff changeset
100 exceptionOffsetField = type.getCIntegerField("_exception_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
101 deoptOffsetField = type.getCIntegerField("_deoptimize_offset");
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
102 deoptMhOffsetField = type.getCIntegerField("_deoptimize_mh_offset");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
103 origPCOffsetField = type.getCIntegerField("_orig_pc_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 stubOffsetField = type.getCIntegerField("_stub_offset");
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
105 oopsOffsetField = type.getCIntegerField("_oops_offset");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
106 metadataOffsetField = type.getCIntegerField("_metadata_offset");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107 scopesDataOffsetField = type.getCIntegerField("_scopes_data_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 scopesPCsOffsetField = type.getCIntegerField("_scopes_pcs_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 dependenciesOffsetField = type.getCIntegerField("_dependencies_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
110 handlerTableOffsetField = type.getCIntegerField("_handler_table_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 nulChkTableOffsetField = type.getCIntegerField("_nul_chk_table_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
112 nmethodEndOffsetField = type.getCIntegerField("_nmethod_end_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 entryPointField = type.getAddressField("_entry_point");
a61af66fc99e Initial load
duke
parents:
diff changeset
114 verifiedEntryPointField = type.getAddressField("_verified_entry_point");
a61af66fc99e Initial load
duke
parents:
diff changeset
115 osrEntryPointField = type.getAddressField("_osr_entry_point");
a61af66fc99e Initial load
duke
parents:
diff changeset
116 lockCountField = type.getJIntField("_lock_count");
a61af66fc99e Initial load
duke
parents:
diff changeset
117 stackTraversalMarkField = type.getCIntegerField("_stack_traversal_mark");
10197
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 6972
diff changeset
118 compLevelField = type.getCIntegerField("_comp_level");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 pcDescSize = db.lookupType("PcDesc").getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public NMethod(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 super(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
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
128 public Address getAddress() {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public Method getMethod() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
133 return (Method)Metadata.instantiateWrapperFor(methodField.getValue(addr));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Type info
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public boolean isNMethod() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public boolean isJavaMethod() { return !getMethod().isNative(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public boolean isNativeMethod() { return getMethod().isNative(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public boolean isOSRMethod() { return getEntryBCI() != VM.getVM().getInvocationEntryBCI(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 /** Boundaries for different parts */
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1644
diff changeset
143 public Address constantsBegin() { return contentBegin(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 public Address constantsEnd() { return getEntryPoint(); }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
145 public Address instsBegin() { return codeBegin(); }
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1644
diff changeset
146 public Address instsEnd() { return headerBegin().addOffsetTo(getStubOffset()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public Address exceptionBegin() { return headerBegin().addOffsetTo(getExceptionOffset()); }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
148 public Address deoptHandlerBegin() { return headerBegin().addOffsetTo(getDeoptOffset()); }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
149 public Address deoptMhHandlerBegin() { return headerBegin().addOffsetTo(getDeoptMhOffset()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
150 public Address stubBegin() { return headerBegin().addOffsetTo(getStubOffset()); }
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
151 public Address stubEnd() { return headerBegin().addOffsetTo(getOopsOffset()); }
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
152 public Address oopsBegin() { return headerBegin().addOffsetTo(getOopsOffset()); }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
153 public Address oopsEnd() { return headerBegin().addOffsetTo(getMetadataOffset()); }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
154 public Address metadataBegin() { return headerBegin().addOffsetTo(getMetadataOffset()); }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
155 public Address metadataEnd() { return headerBegin().addOffsetTo(getScopesDataOffset()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
156 public Address scopesDataBegin() { return headerBegin().addOffsetTo(getScopesDataOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 public Address scopesDataEnd() { return headerBegin().addOffsetTo(getScopesPCsOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public Address scopesPCsBegin() { return headerBegin().addOffsetTo(getScopesPCsOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 public Address scopesPCsEnd() { return headerBegin().addOffsetTo(getDependenciesOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 public Address dependenciesBegin() { return headerBegin().addOffsetTo(getDependenciesOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 public Address dependenciesEnd() { return headerBegin().addOffsetTo(getHandlerTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 public Address handlerTableBegin() { return headerBegin().addOffsetTo(getHandlerTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 public Address handlerTableEnd() { return headerBegin().addOffsetTo(getNulChkTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public Address nulChkTableBegin() { return headerBegin().addOffsetTo(getNulChkTableOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 public Address nulChkTableEnd() { return headerBegin().addOffsetTo(getNMethodEndOffset()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 public int constantsSize() { return (int) constantsEnd() .minus(constantsBegin()); }
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1644
diff changeset
168 public int instsSize() { return (int) instsEnd() .minus(instsBegin()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
169 public int stubSize() { return (int) stubEnd() .minus(stubBegin()); }
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
170 public int oopsSize() { return (int) oopsEnd() .minus(oopsBegin()); }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
171 public int metadataSize() { return (int) metadataEnd() .minus(metadataBegin()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
172 public int scopesDataSize() { return (int) scopesDataEnd() .minus(scopesDataBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 public int scopesPCsSize() { return (int) scopesPCsEnd() .minus(scopesPCsBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 public int dependenciesSize() { return (int) dependenciesEnd().minus(dependenciesBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 public int handlerTableSize() { return (int) handlerTableEnd().minus(handlerTableBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 public int nulChkTableSize() { return (int) nulChkTableEnd() .minus(nulChkTableBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 public int origPCOffset() { return (int) origPCOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 public int totalSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 return
a61af66fc99e Initial load
duke
parents:
diff changeset
181 constantsSize() +
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1644
diff changeset
182 instsSize() +
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183 stubSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
184 scopesDataSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
185 scopesPCsSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
186 dependenciesSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
187 handlerTableSize() +
a61af66fc99e Initial load
duke
parents:
diff changeset
188 nulChkTableSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 public boolean constantsContains (Address addr) { return constantsBegin() .lessThanOrEqual(addr) && constantsEnd() .greaterThan(addr); }
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1644
diff changeset
192 public boolean instsContains (Address addr) { return instsBegin() .lessThanOrEqual(addr) && instsEnd() .greaterThan(addr); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
193 public boolean stubContains (Address addr) { return stubBegin() .lessThanOrEqual(addr) && stubEnd() .greaterThan(addr); }
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
194 public boolean oopsContains (Address addr) { return oopsBegin() .lessThanOrEqual(addr) && oopsEnd() .greaterThan(addr); }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
195 public boolean metadataContains (Address addr) { return metadataBegin() .lessThanOrEqual(addr) && metadataEnd() .greaterThan(addr); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 public boolean scopesDataContains (Address addr) { return scopesDataBegin() .lessThanOrEqual(addr) && scopesDataEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 public boolean scopesPCsContains (Address addr) { return scopesPCsBegin() .lessThanOrEqual(addr) && scopesPCsEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 public boolean handlerTableContains(Address addr) { return handlerTableBegin().lessThanOrEqual(addr) && handlerTableEnd().greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 public boolean nulChkTableContains (Address addr) { return nulChkTableBegin() .lessThanOrEqual(addr) && nulChkTableEnd() .greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3908
diff changeset
201 public int getOopsLength() { return (int) (oopsSize() / VM.getVM().getOopSize()); }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
202 public int getMetadataLength() { return (int) (metadataSize() / VM.getVM().getOopSize()); }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3908
diff changeset
203
0
a61af66fc99e Initial load
duke
parents:
diff changeset
204 /** Entry points */
a61af66fc99e Initial load
duke
parents:
diff changeset
205 public Address getEntryPoint() { return entryPointField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public Address getVerifiedEntryPoint() { return verifiedEntryPointField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
208 /** Support for oops in scopes and relocs. Note: index 0 is reserved for null. */
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
209 public OopHandle getOopAt(int index) {
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
210 if (index == 0) return null;
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
211 if (Assert.ASSERTS_ENABLED) {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3908
diff changeset
212 Assert.that(index > 0 && index <= getOopsLength(), "must be a valid non-zero index");
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
213 }
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
214 return oopsBegin().getOopHandleAt((index - 1) * VM.getVM().getOopSize());
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
215 }
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
216
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
217 /** Support for metadata in scopes and relocs. Note: index 0 is reserved for null. */
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
218 public Address getMetadataAt(int index) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
219 if (index == 0) return null;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
220 if (Assert.ASSERTS_ENABLED) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
221 Assert.that(index > 0 && index <= getMetadataLength(), "must be a valid non-zero index");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
222 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
223 return metadataBegin().getAddressAt((index - 1) * VM.getVM().getOopSize());
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
224 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
225
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
226 public Method getMethodAt(int index) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
227 return (Method)Metadata.instantiateWrapperFor(getMetadataAt(index));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
228 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
229
0
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // FIXME: add interpreter_entry_point()
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // FIXME: add lazy_interpreter_entry_point() for C2
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // **********
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // * FIXME: * ADD ACCESS TO FLAGS!!!!
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // **********
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // public boolean isInUse();
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // public boolean isAlive();
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // public boolean isNotEntrant();
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // public boolean isZombie();
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // ********************************
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // * MAJOR FIXME: MAJOR HACK HERE *
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // ********************************
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public boolean isZombie() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // public boolean isUnloaded();
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // public boolean isYoung();
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // public boolean isOld();
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // public int age();
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // public boolean isMarkedForDeoptimization();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // public boolean isMarkedForUnloading();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // public boolean isMarkedForReclamation();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // public int level();
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // public int version();
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // FIXME: add mutators for above
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // FIXME: add exception cache access?
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 /** On-stack replacement support */
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // FIXME: add mutators
a61af66fc99e Initial load
duke
parents:
diff changeset
261 public int getOSREntryBCI() {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 Assert.that(getEntryBCI() != VM.getVM().getInvocationEntryBCI(), "wrong kind of nmethod");
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 return getEntryBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
268 public NMethod getOSRLink() {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
269 return (NMethod) VMObjectFactory.newObject(NMethod.class, osrLinkField.getValue(addr));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
272 public NMethod getScavengeRootLink() {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
273 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
274 }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
275
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
276 public int getScavengeRootState() {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
277 return (int) scavengeRootStateField.getValue(addr);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
278 }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
279
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
280 // MethodHandle
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
281 public boolean isMethodHandleReturn(Address returnPc) {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
282 // Hard to read a bit fields from Java and it's only there for performance
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
283 // so just go directly to the PCDesc
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
284 // if (!hasMethodHandleInvokes()) return false;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
285 PCDesc pd = getPCDescAt(returnPc);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
286 if (pd == null)
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
287 return false;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
288 return pd.isMethodHandleInvoke();
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
289 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
290
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
291 // Deopt
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
292 // Return true is the PC is one would expect if the frame is being deopted.
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
293 public boolean isDeoptPc (Address pc) { return isDeoptEntry(pc) || isDeoptMhEntry(pc); }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
294 public boolean isDeoptEntry (Address pc) { return pc == deoptHandlerBegin(); }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
295 public boolean isDeoptMhEntry (Address pc) { return pc == deoptMhHandlerBegin(); }
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 931
diff changeset
296
0
a61af66fc99e Initial load
duke
parents:
diff changeset
297 /** Tells whether frames described by this nmethod can be
a61af66fc99e Initial load
duke
parents:
diff changeset
298 deoptimized. Note: native wrappers cannot be deoptimized. */
a61af66fc99e Initial load
duke
parents:
diff changeset
299 public boolean canBeDeoptimized() { return isJavaMethod(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // FIXME: add inline cache support
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // FIXME: add flush()
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 public boolean isLockedByVM() { return lockCountField.getValue(addr) > 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // FIXME: add mark_as_seen_on_stack
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // FIXME: add can_not_entrant_be_converted
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // FIXME: add GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
310 // void follow_roots_or_mark_for_unloading(bool unloading_occurred, bool& marked_for_unloading);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // void follow_root_or_mark_for_unloading(oop* root, bool unloading_occurred, bool& marked_for_unloading);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, void f(oop*));
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // void adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 /** Finds a PCDesc with real-pc equal to "pc" */
a61af66fc99e Initial load
duke
parents:
diff changeset
316 public PCDesc getPCDescAt(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // FIXME: consider adding cache like the one down in the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
318 for (Address p = scopesPCsBegin(); p.lessThan(scopesPCsEnd()); p = p.addOffsetTo(pcDescSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 PCDesc pcDesc = new PCDesc(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 if (pcDesc.getRealPC(this).equals(pc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return pcDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
324 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 /** ScopeDesc for an instruction */
a61af66fc99e Initial load
duke
parents:
diff changeset
328 public ScopeDesc getScopeDescAt(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 PCDesc pd = getPCDescAt(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 Assert.that(pd != null, "scope must be present");
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
333 return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 /** This is only for use by the debugging system, and is only
a61af66fc99e Initial load
duke
parents:
diff changeset
337 intended for use in the topmost frame, where we are not
a61af66fc99e Initial load
duke
parents:
diff changeset
338 guaranteed to be at a PC for which we have a PCDesc. It finds
a61af66fc99e Initial load
duke
parents:
diff changeset
339 the PCDesc with realPC closest to the current PC. */
a61af66fc99e Initial load
duke
parents:
diff changeset
340 public PCDesc getPCDescNearDbg(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 PCDesc bestGuessPCDesc = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
342 long bestDistance = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 for (Address p = scopesPCsBegin(); p.lessThan(scopesPCsEnd()); p = p.addOffsetTo(pcDescSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 PCDesc pcDesc = new PCDesc(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // In case pc is null
a61af66fc99e Initial load
duke
parents:
diff changeset
346 long distance = -pcDesc.getRealPC(this).minus(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 if ((bestGuessPCDesc == null) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
348 ((distance >= 0) && (distance < bestDistance))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
349 bestGuessPCDesc = pcDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 bestDistance = distance;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352 }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 return bestGuessPCDesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
356 PCDesc find_pc_desc(long pc, boolean approximate) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
357 return find_pc_desc_internal(pc, approximate);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
358 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
359
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
360 // Finds a PcDesc with real-pc equal to "pc"
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
361 PCDesc find_pc_desc_internal(long pc, boolean approximate) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
362 long base_address = VM.getAddressValue(codeBegin());
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
363 int pc_offset = (int) (pc - base_address);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
364
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
365 // Fallback algorithm: quasi-linear search for the PcDesc
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
366 // Find the last pc_offset less than the given offset.
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
367 // The successor must be the required match, if there is a match at all.
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
368 // (Use a fixed radix to avoid expensive affine pointer arithmetic.)
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
369 Address lower = scopesPCsBegin();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
370 Address upper = scopesPCsEnd();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
371 upper = upper.addOffsetTo(-pcDescSize); // exclude final sentinel
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
372 if (lower.greaterThan(upper)) return null; // native method; no PcDescs at all
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
373
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
374 // Take giant steps at first (4096, then 256, then 16, then 1)
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
375 int LOG2_RADIX = 4;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
376 int RADIX = (1 << LOG2_RADIX);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
377 Address mid;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
378 for (int step = (1 << (LOG2_RADIX*3)); step > 1; step >>= LOG2_RADIX) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
379 while ((mid = lower.addOffsetTo(step * pcDescSize)).lessThan(upper)) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
380 PCDesc m = new PCDesc(mid);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
381 if (m.getPCOffset() < pc_offset) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
382 lower = mid;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
383 } else {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
384 upper = mid;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
385 break;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
386 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
387 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
388 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
389 // Sneak up on the value with a linear search of length ~16.
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
390 while (true) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
391 mid = lower.addOffsetTo(pcDescSize);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
392 PCDesc m = new PCDesc(mid);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
393 if (m.getPCOffset() < pc_offset) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
394 lower = mid;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
395 } else {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
396 upper = mid;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
397 break;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
398 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
399 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
400
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
401 PCDesc u = new PCDesc(upper);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
402 if (match_desc(u, pc_offset, approximate)) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
403 return u;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
404 } else {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
405 return null;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
406 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
407 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
408
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
409 // ScopeDesc retrieval operation
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
410 PCDesc pc_desc_at(long pc) { return find_pc_desc(pc, false); }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
411 // pc_desc_near returns the first PCDesc at or after the givne pc.
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
412 PCDesc pc_desc_near(long pc) { return find_pc_desc(pc, true); }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
413
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
414 // Return a the last scope in (begin..end]
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
415 public ScopeDesc scope_desc_in(long begin, long end) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
416 PCDesc p = pc_desc_near(begin+1);
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
417 if (p != null && VM.getAddressValue(p.getRealPC(this)) <= end) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
418 return new ScopeDesc(this, p.getScopeDecodeOffset(), p.getObjDecodeOffset(), p.getReexecute());
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
419 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
420 return null;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
421 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
422
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
423 static boolean match_desc(PCDesc pc, int pc_offset, boolean approximate) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
424 if (!approximate) {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
425 return pc.getPCOffset() == pc_offset;
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
426 } else {
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
427 PCDesc prev = new PCDesc(pc.getAddress().addOffsetTo(-pcDescSize));
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
428 return prev.getPCOffset() < pc_offset && pc_offset <= pc.getPCOffset();
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
429 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
430 }
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 6725
diff changeset
431
0
a61af66fc99e Initial load
duke
parents:
diff changeset
432 /** This is only for use by the debugging system, and is only
a61af66fc99e Initial load
duke
parents:
diff changeset
433 intended for use in the topmost frame, where we are not
a61af66fc99e Initial load
duke
parents:
diff changeset
434 guaranteed to be at a PC for which we have a PCDesc. It finds
a61af66fc99e Initial load
duke
parents:
diff changeset
435 the ScopeDesc closest to the current PC. NOTE that this may
a61af66fc99e Initial load
duke
parents:
diff changeset
436 return NULL for compiled methods which don't have any
a61af66fc99e Initial load
duke
parents:
diff changeset
437 ScopeDescs! */
a61af66fc99e Initial load
duke
parents:
diff changeset
438 public ScopeDesc getScopeDescNearDbg(Address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
439 PCDesc pd = getPCDescNearDbg(pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
440 if (pd == null) return null;
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
441 return new ScopeDesc(this, pd.getScopeDecodeOffset(), pd.getObjDecodeOffset(), pd.getReexecute());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
444 public Map/*<Address, PCDesc>*/ getSafepoints() {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 989
diff changeset
445 Map safepoints = new HashMap(); // Map<Address, PCDesc>
0
a61af66fc99e Initial load
duke
parents:
diff changeset
446 sun.jvm.hotspot.debugger.Address p = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
447 for (p = scopesPCsBegin(); p.lessThan(scopesPCsEnd());
a61af66fc99e Initial load
duke
parents:
diff changeset
448 p = p.addOffsetTo(pcDescSize)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 PCDesc pcDesc = new PCDesc(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 sun.jvm.hotspot.debugger.Address pc = pcDesc.getRealPC(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
451 safepoints.put(pc, pcDesc);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
453 return safepoints;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
455
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // FIXME: add getPCOffsetForBCI()
a61af66fc99e Initial load
duke
parents:
diff changeset
457 // FIXME: add embeddedOopAt()
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // FIXME: add isDependentOn()
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // FIXME: add isPatchableAt()
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 /** Support for code generation. Only here for proof-of-concept. */
a61af66fc99e Initial load
duke
parents:
diff changeset
462 public static int getEntryPointOffset() { return (int) entryPointField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
463 public static int getVerifiedEntryPointOffset() { return (int) verifiedEntryPointField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
464 public static int getOSREntryPointOffset() { return (int) osrEntryPointField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
465 public static int getEntryBCIOffset() { return (int) entryBCIField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
466 /** NOTE: renamed from "method_offset_in_bytes" */
a61af66fc99e Initial load
duke
parents:
diff changeset
467 public static int getMethodOffset() { return (int) methodField.getOffset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
470 printOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
473 protected void printComponentsOn(PrintStream tty) {
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
474 // FIXME: add relocation information
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1644
diff changeset
475 tty.println(" content: [" + contentBegin() + ", " + contentEnd() + "), " +
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1644
diff changeset
476 " code: [" + codeBegin() + ", " + codeEnd() + "), " +
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
477 " data: [" + dataBegin() + ", " + dataEnd() + "), " +
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
478 " oops: [" + oopsBegin() + ", " + oopsEnd() + "), " +
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
479 " frame size: " + getFrameSize());
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
480 }
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
481
0
a61af66fc99e Initial load
duke
parents:
diff changeset
482 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
483 Method method = getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
484 return "NMethod for " +
a61af66fc99e Initial load
duke
parents:
diff changeset
485 method.getMethodHolder().getName().asString() + "." +
a61af66fc99e Initial load
duke
parents:
diff changeset
486 method.getName().asString() + method.getSignature().asString() + "==>n" +
a61af66fc99e Initial load
duke
parents:
diff changeset
487 super.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 public String flagsToString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 // FIXME need access to flags...
a61af66fc99e Initial load
duke
parents:
diff changeset
492 return "";
a61af66fc99e Initial load
duke
parents:
diff changeset
493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 public String getName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
496 Method method = getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
497 return "NMethod for " +
a61af66fc99e Initial load
duke
parents:
diff changeset
498 method.getMethodHolder().getName().asString() + "." +
a61af66fc99e Initial load
duke
parents:
diff changeset
499 method.getName().asString() +
a61af66fc99e Initial load
duke
parents:
diff changeset
500 method.getSignature().asString();
a61af66fc99e Initial load
duke
parents:
diff changeset
501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
502
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
503 public void dumpReplayData(PrintStream out) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
504 HashMap h = new HashMap();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
505 for (int i = 1; i < getMetadataLength(); i++) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
506 Metadata meta = Metadata.instantiateWrapperFor(getMetadataAt(i));
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
507 System.err.println(meta);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
508 if (h.get(meta) != null) continue;
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
509 h.put(meta, meta);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
510 if (meta instanceof InstanceKlass) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
511 ((InstanceKlass)meta).dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
512 } else if (meta instanceof Method) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
513 ((Method)meta).dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
514 MethodData mdo = ((Method)meta).getMethodData();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
515 if (mdo != null) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
516 mdo.dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
517 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
518 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
519 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
520 Method method = getMethod();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
521 if (h.get(method) == null) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
522 method.dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
523 MethodData mdo = method.getMethodData();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
524 if (mdo != null) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
525 mdo.dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
526 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
527 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
528 if (h.get(method.getMethodHolder()) == null) {
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
529 ((InstanceKlass)method.getMethodHolder()).dumpReplayData(out);
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
530 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
531 Klass holder = method.getMethodHolder();
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
532 out.println("compile " + holder.getName().asString() + " " +
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
533 OopUtilities.escapeString(method.getName().asString()) + " " +
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
534 method.getSignature().asString() + " " +
10197
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 6972
diff changeset
535 getEntryBCI() + " " + getCompLevel());
6972
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
536
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
537 }
bd7a7ce2e264 6830717: replay of compilations would help with debugging
minqi
parents: 6782
diff changeset
538
0
a61af66fc99e Initial load
duke
parents:
diff changeset
539 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
540 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
541 //
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 private int getEntryBCI() { return (int) entryBCIField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
544 private int getExceptionOffset() { return (int) exceptionOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
545 private int getDeoptOffset() { return (int) deoptOffsetField .getValue(addr); }
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
546 private int getDeoptMhOffset() { return (int) deoptMhOffsetField .getValue(addr); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
547 private int getStubOffset() { return (int) stubOffsetField .getValue(addr); }
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 1040
diff changeset
548 private int getOopsOffset() { return (int) oopsOffsetField .getValue(addr); }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
549 private int getMetadataOffset() { return (int) metadataOffsetField .getValue(addr); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
550 private int getScopesDataOffset() { return (int) scopesDataOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
551 private int getScopesPCsOffset() { return (int) scopesPCsOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
552 private int getDependenciesOffset() { return (int) dependenciesOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
553 private int getHandlerTableOffset() { return (int) handlerTableOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
554 private int getNulChkTableOffset() { return (int) nulChkTableOffsetField .getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
555 private int getNMethodEndOffset() { return (int) nmethodEndOffsetField .getValue(addr); }
10197
7b23cb975cf2 8011675: adding compilation level to replay data
iignatyev
parents: 6972
diff changeset
556 private int getCompLevel() { return (int) compLevelField .getValue(addr); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
557 }