Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @ 6972:bd7a7ce2e264
6830717: replay of compilations would help with debugging
Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method.
Reviewed-by: kvn, twisti, sspitsyn
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 12 Nov 2012 14:03:53 -0800 |
parents | da91efe96a93 |
children | 4a916f2ce331 |
rev | line source |
---|---|
0 | 1 /* |
5998
49036505ab5f
7154670: The instanceKlass _implementors[] and _nof_implementors are not needed for non-interface klass.
jiangli
parents:
5967
diff
changeset
|
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
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:
196
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.oops; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
29 import sun.jvm.hotspot.classfile.ClassLoaderData; |
0 | 30 import sun.jvm.hotspot.debugger.*; |
31 import sun.jvm.hotspot.memory.*; | |
32 import sun.jvm.hotspot.runtime.*; | |
33 import sun.jvm.hotspot.types.*; | |
34 import sun.jvm.hotspot.utilities.*; | |
35 | |
36 // An InstanceKlass is the VM level representation of a Java class. | |
37 | |
38 public class InstanceKlass extends Klass { | |
39 static { | |
40 VM.registerVMInitializedObserver(new Observer() { | |
41 public void update(Observable o, Object data) { | |
42 initialize(VM.getVM().getTypeDataBase()); | |
43 } | |
44 }); | |
45 } | |
46 | |
47 // field offset constants | |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
48 private static int ACCESS_FLAGS_OFFSET; |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
49 private static int NAME_INDEX_OFFSET; |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
50 private static int SIGNATURE_INDEX_OFFSET; |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
51 private static int INITVAL_INDEX_OFFSET; |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
52 private static int LOW_OFFSET; |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
53 private static int HIGH_OFFSET; |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
54 private static int FIELD_SLOTS; |
0 | 55 |
56 // ClassState constants | |
57 private static int CLASS_STATE_ALLOCATED; | |
58 private static int CLASS_STATE_LOADED; | |
59 private static int CLASS_STATE_LINKED; | |
60 private static int CLASS_STATE_BEING_INITIALIZED; | |
61 private static int CLASS_STATE_FULLY_INITIALIZED; | |
62 private static int CLASS_STATE_INITIALIZATION_ERROR; | |
63 | |
64 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
65 Type type = db.lookupType("InstanceKlass"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
66 arrayKlasses = new MetadataField(type.getAddressField("_array_klasses"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
67 methods = type.getAddressField("_methods"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
68 methodOrdering = type.getAddressField("_method_ordering"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
69 localInterfaces = type.getAddressField("_local_interfaces"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
70 transitiveInterfaces = type.getAddressField("_transitive_interfaces"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
71 fields = type.getAddressField("_fields"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
72 javaFieldsCount = new CIntField(type.getCIntegerField("_java_fields_count"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
73 constants = new MetadataField(type.getAddressField("_constants"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
74 classLoaderData = type.getAddressField("_class_loader_data"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
75 protectionDomain = new OopField(type.getOopField("_protection_domain"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
76 signers = new OopField(type.getOopField("_signers"), 0); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
77 sourceFileName = type.getAddressField("_source_file_name"); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
78 sourceDebugExtension = type.getAddressField("_source_debug_extension"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
79 innerClasses = type.getAddressField("_inner_classes"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
80 nonstaticFieldSize = new CIntField(type.getCIntegerField("_nonstatic_field_size"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
81 staticFieldSize = new CIntField(type.getCIntegerField("_static_field_size"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
82 staticOopFieldCount = new CIntField(type.getCIntegerField("_static_oop_field_count"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
83 nonstaticOopMapSize = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
84 isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
85 initState = new CIntField(type.getCIntegerField("_init_state"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
86 vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
87 itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0); |
0 | 88 breakpoints = type.getAddressField("_breakpoints"); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
89 genericSignature = type.getAddressField("_generic_signature"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
90 majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
91 minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
92 headerSize = Oop.alignObjectOffset(type.getSize()); |
0 | 93 |
94 // read field offset constants | |
3938 | 95 ACCESS_FLAGS_OFFSET = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue(); |
96 NAME_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::name_index_offset").intValue(); | |
97 SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue(); | |
98 INITVAL_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue(); | |
99 LOW_OFFSET = db.lookupIntConstant("FieldInfo::low_offset").intValue(); | |
100 HIGH_OFFSET = db.lookupIntConstant("FieldInfo::high_offset").intValue(); | |
101 FIELD_SLOTS = db.lookupIntConstant("FieldInfo::field_slots").intValue(); | |
0 | 102 // read ClassState constants |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
103 CLASS_STATE_ALLOCATED = db.lookupIntConstant("InstanceKlass::allocated").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
104 CLASS_STATE_LOADED = db.lookupIntConstant("InstanceKlass::loaded").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
105 CLASS_STATE_LINKED = db.lookupIntConstant("InstanceKlass::linked").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
106 CLASS_STATE_BEING_INITIALIZED = db.lookupIntConstant("InstanceKlass::being_initialized").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
107 CLASS_STATE_FULLY_INITIALIZED = db.lookupIntConstant("InstanceKlass::fully_initialized").intValue(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
108 CLASS_STATE_INITIALIZATION_ERROR = db.lookupIntConstant("InstanceKlass::initialization_error").intValue(); |
0 | 109 |
110 } | |
111 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
112 public InstanceKlass(Address addr) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
113 super(addr); |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
114 if (getJavaFieldsCount() != getAllFieldsCount()) { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
115 // Exercise the injected field logic |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
116 for (int i = getJavaFieldsCount(); i < getAllFieldsCount(); i++) { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
117 getFieldName(i); |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
118 getFieldSignature(i); |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
119 } |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
120 } |
0 | 121 } |
122 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
123 private static MetadataField arrayKlasses; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
124 private static AddressField methods; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
125 private static AddressField methodOrdering; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
126 private static AddressField localInterfaces; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
127 private static AddressField transitiveInterfaces; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
128 private static AddressField fields; |
3938 | 129 private static CIntField javaFieldsCount; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
130 private static MetadataField constants; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
131 private static AddressField classLoaderData; |
0 | 132 private static OopField protectionDomain; |
133 private static OopField signers; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
134 private static AddressField sourceFileName; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
135 private static AddressField sourceDebugExtension; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
136 private static AddressField innerClasses; |
0 | 137 private static CIntField nonstaticFieldSize; |
138 private static CIntField staticFieldSize; | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
139 private static CIntField staticOopFieldCount; |
0 | 140 private static CIntField nonstaticOopMapSize; |
4772
8f8b94305aff
7129240: backout fix for 7102776 until 7128770 is resolved
dcubed
parents:
4737
diff
changeset
|
141 private static CIntField isMarkedDependent; |
0 | 142 private static CIntField initState; |
143 private static CIntField vtableLen; | |
144 private static CIntField itableLen; | |
145 private static AddressField breakpoints; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
146 private static AddressField genericSignature; |
0 | 147 private static CIntField majorVersion; |
148 private static CIntField minorVersion; | |
149 | |
150 // type safe enum for ClassState from instanceKlass.hpp | |
151 public static class ClassState { | |
152 public static final ClassState ALLOCATED = new ClassState("allocated"); | |
153 public static final ClassState LOADED = new ClassState("loaded"); | |
154 public static final ClassState LINKED = new ClassState("linked"); | |
155 public static final ClassState BEING_INITIALIZED = new ClassState("beingInitialized"); | |
156 public static final ClassState FULLY_INITIALIZED = new ClassState("fullyInitialized"); | |
157 public static final ClassState INITIALIZATION_ERROR = new ClassState("initializationError"); | |
158 | |
159 private ClassState(String value) { | |
160 this.value = value; | |
161 } | |
162 | |
163 public String toString() { | |
164 return value; | |
165 } | |
166 | |
167 private String value; | |
168 } | |
169 | |
3939 | 170 public int getInitStateAsInt() { return (int) initState.getValue(this); } |
0 | 171 public ClassState getInitState() { |
172 int state = getInitStateAsInt(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
173 if (state == CLASS_STATE_ALLOCATED) { |
0 | 174 return ClassState.ALLOCATED; |
175 } else if (state == CLASS_STATE_LOADED) { | |
176 return ClassState.LOADED; | |
177 } else if (state == CLASS_STATE_LINKED) { | |
178 return ClassState.LINKED; | |
179 } else if (state == CLASS_STATE_BEING_INITIALIZED) { | |
180 return ClassState.BEING_INITIALIZED; | |
181 } else if (state == CLASS_STATE_FULLY_INITIALIZED) { | |
182 return ClassState.FULLY_INITIALIZED; | |
183 } else if (state == CLASS_STATE_INITIALIZATION_ERROR) { | |
184 return ClassState.INITIALIZATION_ERROR; | |
185 } else { | |
186 throw new RuntimeException("should not reach here"); | |
187 } | |
188 } | |
189 | |
190 // initialization state quaries | |
191 public boolean isLoaded() { | |
192 return getInitStateAsInt() >= CLASS_STATE_LOADED; | |
193 } | |
194 | |
195 public boolean isLinked() { | |
196 return getInitStateAsInt() >= CLASS_STATE_LINKED; | |
197 } | |
198 | |
199 public boolean isInitialized() { | |
200 return getInitStateAsInt() == CLASS_STATE_FULLY_INITIALIZED; | |
201 } | |
202 | |
203 public boolean isNotInitialized() { | |
204 return getInitStateAsInt() < CLASS_STATE_BEING_INITIALIZED; | |
205 } | |
206 | |
207 public boolean isBeingInitialized() { | |
208 return getInitStateAsInt() == CLASS_STATE_BEING_INITIALIZED; | |
209 } | |
210 | |
211 public boolean isInErrorState() { | |
212 return getInitStateAsInt() == CLASS_STATE_INITIALIZATION_ERROR; | |
213 } | |
214 | |
215 public int getClassStatus() { | |
216 int result = 0; | |
217 if (isLinked()) { | |
218 result |= JVMDIClassStatus.VERIFIED | JVMDIClassStatus.PREPARED; | |
219 } | |
220 | |
221 if (isInitialized()) { | |
222 if (Assert.ASSERTS_ENABLED) { | |
223 Assert.that(isLinked(), "Class status is not consistent"); | |
224 } | |
225 result |= JVMDIClassStatus.INITIALIZED; | |
226 } | |
227 | |
228 if (isInErrorState()) { | |
229 result |= JVMDIClassStatus.ERROR; | |
230 } | |
231 return result; | |
232 } | |
233 | |
234 // Byteside of the header | |
235 private static long headerSize; | |
236 | |
2411
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
237 public long getObjectSize(Oop object) { |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
238 return getSizeHelper() * VM.getVM().getAddressSize(); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
239 } |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
240 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
241 public long getSize() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
242 return Oop.alignObjectSize(getHeaderSize() + Oop.alignObjectOffset(getVtableLen()) + |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
243 Oop.alignObjectOffset(getItableLen()) + Oop.alignObjectOffset(getNonstaticOopMapSize())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
244 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
245 |
0 | 246 public static long getHeaderSize() { return headerSize; } |
247 | |
3938 | 248 public short getFieldAccessFlags(int index) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
249 return getFields().at(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET); |
3938 | 250 } |
251 | |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
252 public short getFieldNameIndex(int index) { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
253 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
254 return getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET); |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
255 } |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
256 |
3938 | 257 public Symbol getFieldName(int index) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
258 int nameIndex = getFields().at(index * FIELD_SLOTS + NAME_INDEX_OFFSET); |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
259 if (index < getJavaFieldsCount()) { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
260 return getConstants().getSymbolAt(nameIndex); |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
261 } else { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
262 return vmSymbols.symbolAt(nameIndex); |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
263 } |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
264 } |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
265 |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
266 public short getFieldSignatureIndex(int index) { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
267 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
268 return getFields().at(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); |
3938 | 269 } |
270 | |
271 public Symbol getFieldSignature(int index) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
272 int signatureIndex = getFields().at(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET); |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
273 if (index < getJavaFieldsCount()) { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
274 return getConstants().getSymbolAt(signatureIndex); |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
275 } else { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
276 return vmSymbols.symbolAt(signatureIndex); |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
277 } |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
278 } |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
279 |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
280 public short getFieldGenericSignatureIndex(int index) { |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
281 // int len = getFields().length(); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
282 int allFieldsCount = getAllFieldsCount(); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
283 int generic_signature_slot = allFieldsCount * FIELD_SLOTS; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
284 for (int i = 0; i < allFieldsCount; i++) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
285 short flags = getFieldAccessFlags(i); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
286 AccessFlags access = new AccessFlags(flags); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
287 if (i == index) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
288 if (access.fieldHasGenericSignature()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
289 return getFields().at(generic_signature_slot); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
290 } else { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
291 return 0; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
292 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
293 } else { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
294 if (access.fieldHasGenericSignature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
295 generic_signature_slot ++; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
296 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
297 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
298 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
299 return 0; |
3938 | 300 } |
301 | |
302 public Symbol getFieldGenericSignature(int index) { | |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
303 short genericSignatureIndex = getFieldGenericSignatureIndex(index); |
3938 | 304 if (genericSignatureIndex != 0) { |
305 return getConstants().getSymbolAt(genericSignatureIndex); | |
306 } | |
307 return null; | |
308 } | |
309 | |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
310 public short getFieldInitialValueIndex(int index) { |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
311 if (index >= getJavaFieldsCount()) throw new IndexOutOfBoundsException("not a Java field;"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
312 return getFields().at(index * FIELD_SLOTS + INITVAL_INDEX_OFFSET); |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
313 } |
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
314 |
3938 | 315 public int getFieldOffset(int index) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
316 U2Array fields = getFields(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
317 return VM.getVM().buildIntFromShorts(fields.at(index * FIELD_SLOTS + LOW_OFFSET), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
318 fields.at(index * FIELD_SLOTS + HIGH_OFFSET)); |
3938 | 319 } |
320 | |
0 | 321 // Accessors for declared fields |
322 public Klass getArrayKlasses() { return (Klass) arrayKlasses.getValue(this); } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
323 public MethodArray getMethods() { return new MethodArray(methods.getValue(getAddress())); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
324 public KlassArray getLocalInterfaces() { return new KlassArray(localInterfaces.getValue(getAddress())); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
325 public KlassArray getTransitiveInterfaces() { return new KlassArray(transitiveInterfaces.getValue(getAddress())); } |
3938 | 326 public int getJavaFieldsCount() { return (int) javaFieldsCount.getValue(this); } |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
327 public int getAllFieldsCount() { |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
328 int len = getFields().length(); |
6100
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
329 int allFieldsCount = 0; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
330 for (; allFieldsCount*FIELD_SLOTS < len; allFieldsCount++) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
331 short flags = getFieldAccessFlags(allFieldsCount); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
332 AccessFlags access = new AccessFlags(flags); |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
333 if (access.fieldHasGenericSignature()) { |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
334 len --; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
335 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
336 } |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
337 return allFieldsCount; |
71afdabfd05b
7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents:
5998
diff
changeset
|
338 } |
0 | 339 public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
340 public ClassLoaderData getClassLoaderData() { return ClassLoaderData.instantiateWrapperFor(classLoaderData.getValue(getAddress())); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
341 public Oop getClassLoader() { return getClassLoaderData().getClassLoader(); } |
0 | 342 public Oop getProtectionDomain() { return protectionDomain.getValue(this); } |
343 public ObjArray getSigners() { return (ObjArray) signers.getValue(this); } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
344 public Symbol getSourceFileName() { return getSymbol(sourceFileName); } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
345 public String getSourceDebugExtension(){ return CStringUtilities.getString(sourceDebugExtension.getValue(getAddress())); } |
0 | 346 public long getNonstaticFieldSize() { return nonstaticFieldSize.getValue(this); } |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
347 public long getStaticOopFieldCount() { return staticOopFieldCount.getValue(this); } |
0 | 348 public long getNonstaticOopMapSize() { return nonstaticOopMapSize.getValue(this); } |
4772
8f8b94305aff
7129240: backout fix for 7102776 until 7128770 is resolved
dcubed
parents:
4737
diff
changeset
|
349 public boolean getIsMarkedDependent() { return isMarkedDependent.getValue(this) != 0; } |
0 | 350 public long getVtableLen() { return vtableLen.getValue(this); } |
351 public long getItableLen() { return itableLen.getValue(this); } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
352 public Symbol getGenericSignature() { return getSymbol(genericSignature); } |
0 | 353 public long majorVersion() { return majorVersion.getValue(this); } |
354 public long minorVersion() { return minorVersion.getValue(this); } | |
355 | |
356 // "size helper" == instance size in words | |
357 public long getSizeHelper() { | |
358 int lh = getLayoutHelper(); | |
359 if (Assert.ASSERTS_ENABLED) { | |
360 Assert.that(lh > 0, "layout helper initialized for instance class"); | |
361 } | |
362 return lh / VM.getVM().getAddressSize(); | |
363 } | |
364 | |
365 // same as enum InnerClassAttributeOffset in VM code. | |
366 public static interface InnerClassAttributeOffset { | |
367 // from JVM spec. "InnerClasses" attribute | |
368 public static final int innerClassInnerClassInfoOffset = 0; | |
369 public static final int innerClassOuterClassInfoOffset = 1; | |
370 public static final int innerClassInnerNameOffset = 2; | |
371 public static final int innerClassAccessFlagsOffset = 3; | |
372 public static final int innerClassNextOffset = 4; | |
373 }; | |
374 | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
375 public static interface EnclosingMethodAttributeOffset { |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
376 public static final int enclosing_method_class_index_offset = 0; |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
377 public static final int enclosing_method_method_index_offset = 1; |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
378 public static final int enclosing_method_attribute_size = 2; |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
379 }; |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
380 |
0 | 381 // refer to compute_modifier_flags in VM code. |
382 public long computeModifierFlags() { | |
383 long access = getAccessFlags(); | |
384 // But check if it happens to be member class. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
385 U2Array innerClassList = getInnerClasses(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
386 int length = (innerClassList == null)? 0 : (int) innerClassList.length(); |
0 | 387 if (length > 0) { |
388 if (Assert.ASSERTS_ENABLED) { | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
389 Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 || |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
390 length % InnerClassAttributeOffset.innerClassNextOffset == EnclosingMethodAttributeOffset.enclosing_method_attribute_size, |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
391 "just checking"); |
0 | 392 } |
393 for (int i = 0; i < length; i += InnerClassAttributeOffset.innerClassNextOffset) { | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
394 if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) { |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
395 break; |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
396 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
397 int ioff = innerClassList.at(i + |
0 | 398 InnerClassAttributeOffset.innerClassInnerClassInfoOffset); |
399 // 'ioff' can be zero. | |
400 // refer to JVM spec. section 4.7.5. | |
401 if (ioff != 0) { | |
402 // only look at classes that are already loaded | |
403 // since we are looking for the flags for our self. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
404 ConstantPool.CPSlot classInfo = getConstants().getSlotAt(ioff); |
0 | 405 Symbol name = null; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
406 if (classInfo.isResolved()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
407 name = classInfo.getKlass().getName(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
408 } else if (classInfo.isUnresolved()) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
409 name = classInfo.getSymbol(); |
0 | 410 } else { |
411 throw new RuntimeException("should not reach here"); | |
412 } | |
413 | |
414 if (name.equals(getName())) { | |
415 // This is really a member class | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
416 access = innerClassList.at(i + |
0 | 417 InnerClassAttributeOffset.innerClassAccessFlagsOffset); |
418 break; | |
419 } | |
420 } | |
421 } // for inner classes | |
422 } | |
423 | |
424 // Remember to strip ACC_SUPER bit | |
425 return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS; | |
426 } | |
427 | |
428 | |
429 // whether given Symbol is name of an inner/nested Klass of this Klass? | |
430 // anonymous and local classes are excluded. | |
431 public boolean isInnerClassName(Symbol sym) { | |
432 return isInInnerClasses(sym, false); | |
433 } | |
434 | |
435 // whether given Symbol is name of an inner/nested Klass of this Klass? | |
436 // anonymous classes excluded, but local classes are included. | |
437 public boolean isInnerOrLocalClassName(Symbol sym) { | |
438 return isInInnerClasses(sym, true); | |
439 } | |
440 | |
441 private boolean isInInnerClasses(Symbol sym, boolean includeLocals) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
442 U2Array innerClassList = getInnerClasses(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
443 int length = ( innerClassList == null)? 0 : (int) innerClassList.length(); |
0 | 444 if (length > 0) { |
445 if (Assert.ASSERTS_ENABLED) { | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
446 Assert.that(length % InnerClassAttributeOffset.innerClassNextOffset == 0 || |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
447 length % InnerClassAttributeOffset.innerClassNextOffset == EnclosingMethodAttributeOffset.enclosing_method_attribute_size, |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
448 "just checking"); |
0 | 449 } |
450 for (int i = 0; i < length; i += InnerClassAttributeOffset.innerClassNextOffset) { | |
5967
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
451 if (i == length - EnclosingMethodAttributeOffset.enclosing_method_attribute_size) { |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
452 break; |
f7c4174b33ba
7109878: The instanceKlass EnclosingMethhod attribute fields can be folded into the _inner_class field.
jiangli
parents:
4772
diff
changeset
|
453 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
454 int ioff = innerClassList.at(i + |
0 | 455 InnerClassAttributeOffset.innerClassInnerClassInfoOffset); |
456 // 'ioff' can be zero. | |
457 // refer to JVM spec. section 4.7.5. | |
458 if (ioff != 0) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
459 ConstantPool.CPSlot iclassInfo = getConstants().getSlotAt(ioff); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
460 Symbol innerName = getConstants().getKlassNameAt(ioff); |
0 | 461 Symbol myname = getName(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
462 int ooff = innerClassList.at(i + |
0 | 463 InnerClassAttributeOffset.innerClassOuterClassInfoOffset); |
464 // for anonymous classes inner_name_index of InnerClasses | |
465 // attribute is zero. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
466 int innerNameIndex = innerClassList.at(i + |
0 | 467 InnerClassAttributeOffset.innerClassInnerNameOffset); |
468 // if this is not a member (anonymous, local etc.), 'ooff' will be zero | |
469 // refer to JVM spec. section 4.7.5. | |
470 if (ooff == 0) { | |
471 if (includeLocals) { | |
472 // does it looks like my local class? | |
473 if (innerName.equals(sym) && | |
474 innerName.asString().startsWith(myname.asString())) { | |
475 // exclude anonymous classes. | |
476 return (innerNameIndex != 0); | |
477 } | |
478 } | |
479 } else { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
480 ConstantPool.CPSlot oclassInfo = getConstants().getSlotAt(ooff); |
0 | 481 Symbol outerName = null; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
482 if (oclassInfo.isResolved()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
483 outerName = oclassInfo.getKlass().getName(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
484 } else if (oclassInfo.isUnresolved()) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1552
diff
changeset
|
485 outerName = oclassInfo.getSymbol(); |
0 | 486 } else { |
487 throw new RuntimeException("should not reach here"); | |
488 } | |
489 | |
490 // include only if current class is outer class. | |
491 if (outerName.equals(myname) && innerName.equals(sym)) { | |
492 return true; | |
493 } | |
494 } | |
495 } | |
496 } // for inner classes | |
497 return false; | |
498 } else { | |
499 return false; | |
500 } | |
501 } | |
502 | |
503 public boolean implementsInterface(Klass k) { | |
504 if (Assert.ASSERTS_ENABLED) { | |
505 Assert.that(k.isInterface(), "should not reach here"); | |
506 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
507 KlassArray interfaces = getTransitiveInterfaces(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
508 final int len = interfaces.length(); |
0 | 509 for (int i = 0; i < len; i++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
510 if (interfaces.getAt(i).equals(k)) return true; |
0 | 511 } |
512 return false; | |
513 } | |
514 | |
515 boolean computeSubtypeOf(Klass k) { | |
516 if (k.isInterface()) { | |
517 return implementsInterface(k); | |
518 } else { | |
519 return super.computeSubtypeOf(k); | |
520 } | |
521 } | |
522 | |
523 public void printValueOn(PrintStream tty) { | |
524 tty.print("InstanceKlass for " + getName().asString()); | |
525 } | |
526 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
527 public void iterateFields(MetadataVisitor visitor) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
528 super.iterateFields(visitor); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
529 visitor.doMetadata(arrayKlasses, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
530 // visitor.doOop(methods, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
531 // visitor.doOop(localInterfaces, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
532 // visitor.doOop(transitiveInterfaces, true); |
0 | 533 visitor.doOop(protectionDomain, true); |
534 visitor.doOop(signers, true); | |
535 visitor.doCInt(nonstaticFieldSize, true); | |
536 visitor.doCInt(staticFieldSize, true); | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
537 visitor.doCInt(staticOopFieldCount, true); |
0 | 538 visitor.doCInt(nonstaticOopMapSize, true); |
4772
8f8b94305aff
7129240: backout fix for 7102776 until 7128770 is resolved
dcubed
parents:
4737
diff
changeset
|
539 visitor.doCInt(isMarkedDependent, true); |
0 | 540 visitor.doCInt(initState, true); |
541 visitor.doCInt(vtableLen, true); | |
542 visitor.doCInt(itableLen, true); | |
543 } | |
544 | |
2411
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
545 /* |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
546 * Visit the static fields of this InstanceKlass with the obj of |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
547 * the visitor set to the oop holding the fields, which is |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
548 * currently the java mirror. |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
549 */ |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
550 public void iterateStaticFields(OopVisitor visitor) { |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
551 visitor.setObj(getJavaMirror()); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
552 visitor.prologue(); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
553 iterateStaticFieldsInternal(visitor); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
554 visitor.epilogue(); |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
555 |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
556 } |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
557 |
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
558 void iterateStaticFieldsInternal(OopVisitor visitor) { |
3938 | 559 int length = getJavaFieldsCount(); |
3944 | 560 for (int index = 0; index < length; index++) { |
561 short accessFlags = getFieldAccessFlags(index); | |
562 FieldType type = new FieldType(getFieldSignature(index)); | |
0 | 563 AccessFlags access = new AccessFlags(accessFlags); |
564 if (access.isStatic()) { | |
565 visitField(visitor, type, index); | |
566 } | |
567 } | |
568 } | |
569 | |
570 public Klass getJavaSuper() { | |
571 return getSuper(); | |
572 } | |
573 | |
3939 | 574 public static class StaticField { |
575 public AccessFlags flags; | |
576 public Field field; | |
577 | |
578 StaticField(Field field, AccessFlags flags) { | |
579 this.field = field; | |
580 this.flags = flags; | |
581 } | |
582 } | |
583 | |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
584 public Field[] getStaticFields() { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
585 U2Array fields = getFields(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
586 int length = getJavaFieldsCount(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
587 ArrayList result = new ArrayList(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
588 for (int index = 0; index < length; index++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
589 Field f = newField(index); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
590 if (f.isStatic()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
591 result.add(f); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
592 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
593 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
594 return (Field[])result.toArray(new Field[result.size()]); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
595 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
596 |
2411
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
597 public void iterateNonStaticFields(OopVisitor visitor, Oop obj) { |
0 | 598 if (getSuper() != null) { |
2411
63997f575155
7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents:
2376
diff
changeset
|
599 ((InstanceKlass) getSuper()).iterateNonStaticFields(visitor, obj); |
0 | 600 } |
3938 | 601 int length = getJavaFieldsCount(); |
3944 | 602 for (int index = 0; index < length; index++) { |
603 short accessFlags = getFieldAccessFlags(index); | |
604 FieldType type = new FieldType(getFieldSignature(index)); | |
0 | 605 AccessFlags access = new AccessFlags(accessFlags); |
606 if (!access.isStatic()) { | |
607 visitField(visitor, type, index); | |
608 } | |
609 } | |
610 } | |
611 | |
612 /** Field access by name. */ | |
613 public Field findLocalField(Symbol name, Symbol sig) { | |
3962
cb315dc80374
7092278: "jmap -finalizerinfo" throws "sun.jvm.hotspot.utilities.AssertionFailure: invalid cp index 0 137"
never
parents:
3944
diff
changeset
|
614 int length = getJavaFieldsCount(); |
3944 | 615 for (int i = 0; i < length; i++) { |
616 Symbol f_name = getFieldName(i); | |
617 Symbol f_sig = getFieldSignature(i); | |
0 | 618 if (name.equals(f_name) && sig.equals(f_sig)) { |
619 return newField(i); | |
620 } | |
621 } | |
622 | |
623 return null; | |
624 } | |
625 | |
626 /** Find field in direct superinterfaces. */ | |
627 public Field findInterfaceField(Symbol name, Symbol sig) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
628 KlassArray interfaces = getLocalInterfaces(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
629 int n = interfaces.length(); |
0 | 630 for (int i = 0; i < n; i++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
631 InstanceKlass intf1 = (InstanceKlass) interfaces.getAt(i); |
0 | 632 if (Assert.ASSERTS_ENABLED) { |
633 Assert.that(intf1.isInterface(), "just checking type"); | |
634 } | |
635 // search for field in current interface | |
636 Field f = intf1.findLocalField(name, sig); | |
637 if (f != null) { | |
638 if (Assert.ASSERTS_ENABLED) { | |
639 Assert.that(f.getAccessFlagsObj().isStatic(), "interface field must be static"); | |
640 } | |
641 return f; | |
642 } | |
643 // search for field in direct superinterfaces | |
644 f = intf1.findInterfaceField(name, sig); | |
645 if (f != null) return f; | |
646 } | |
647 // otherwise field lookup fails | |
648 return null; | |
649 } | |
650 | |
651 /** Find field according to JVM spec 5.4.3.2, returns the klass in | |
652 which the field is defined. */ | |
653 public Field findField(Symbol name, Symbol sig) { | |
654 // search order according to newest JVM spec (5.4.3.2, p.167). | |
655 // 1) search for field in current klass | |
656 Field f = findLocalField(name, sig); | |
657 if (f != null) return f; | |
658 | |
659 // 2) search for field recursively in direct superinterfaces | |
660 f = findInterfaceField(name, sig); | |
661 if (f != null) return f; | |
662 | |
663 // 3) apply field lookup recursively if superclass exists | |
664 InstanceKlass supr = (InstanceKlass) getSuper(); | |
665 if (supr != null) return supr.findField(name, sig); | |
666 | |
667 // 4) otherwise field lookup fails | |
668 return null; | |
669 } | |
670 | |
671 /** Find field according to JVM spec 5.4.3.2, returns the klass in | |
672 which the field is defined (convenience routine) */ | |
673 public Field findField(String name, String sig) { | |
674 SymbolTable symbols = VM.getVM().getSymbolTable(); | |
675 Symbol nameSym = symbols.probe(name); | |
676 Symbol sigSym = symbols.probe(sig); | |
677 if (nameSym == null || sigSym == null) { | |
678 return null; | |
679 } | |
680 return findField(nameSym, sigSym); | |
681 } | |
682 | |
683 /** Find field according to JVM spec 5.4.3.2, returns the klass in | |
684 which the field is defined (retained only for backward | |
685 compatibility with jdbx) */ | |
686 public Field findFieldDbg(String name, String sig) { | |
687 return findField(name, sig); | |
688 } | |
689 | |
690 /** Get field by its index in the fields array. Only designed for | |
691 use in a debugging system. */ | |
3944 | 692 public Field getFieldByIndex(int fieldIndex) { |
693 return newField(fieldIndex); | |
0 | 694 } |
695 | |
696 | |
697 /** Return a List of SA Fields for the fields declared in this class. | |
698 Inherited fields are not included. | |
699 Return an empty list if there are no fields declared in this class. | |
700 Only designed for use in a debugging system. */ | |
701 public List getImmediateFields() { | |
702 // A list of Fields for each field declared in this class/interface, | |
703 // not including inherited fields. | |
3938 | 704 int length = getJavaFieldsCount(); |
705 List immediateFields = new ArrayList(length); | |
3944 | 706 for (int index = 0; index < length; index++) { |
0 | 707 immediateFields.add(getFieldByIndex(index)); |
708 } | |
709 | |
710 return immediateFields; | |
711 } | |
712 | |
713 /** Return a List of SA Fields for all the java fields in this class, | |
714 including all inherited fields. This includes hidden | |
715 fields. Thus the returned list can contain fields with | |
716 the same name. | |
717 Return an empty list if there are no fields. | |
718 Only designed for use in a debugging system. */ | |
719 public List getAllFields() { | |
720 // Contains a Field for each field in this class, including immediate | |
721 // fields and inherited fields. | |
722 List allFields = getImmediateFields(); | |
723 | |
724 // transitiveInterfaces contains all interfaces implemented | |
725 // by this class and its superclass chain with no duplicates. | |
726 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
727 KlassArray interfaces = getTransitiveInterfaces(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
728 int n = interfaces.length(); |
0 | 729 for (int i = 0; i < n; i++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
730 InstanceKlass intf1 = (InstanceKlass) interfaces.getAt(i); |
0 | 731 if (Assert.ASSERTS_ENABLED) { |
732 Assert.that(intf1.isInterface(), "just checking type"); | |
733 } | |
734 allFields.addAll(intf1.getImmediateFields()); | |
735 } | |
736 | |
737 // Get all fields in the superclass, recursively. But, don't | |
738 // include fields in interfaces implemented by superclasses; | |
739 // we already have all those. | |
740 if (!isInterface()) { | |
741 InstanceKlass supr; | |
742 if ( (supr = (InstanceKlass) getSuper()) != null) { | |
743 allFields.addAll(supr.getImmediateFields()); | |
744 } | |
745 } | |
746 | |
747 return allFields; | |
748 } | |
749 | |
750 | |
751 /** Return a List of SA Methods declared directly in this class/interface. | |
752 Return an empty list if there are none, or if this isn't a class/ | |
753 interface. | |
754 */ | |
755 public List getImmediateMethods() { | |
756 // Contains a Method for each method declared in this class/interface | |
757 // not including inherited methods. | |
758 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
759 MethodArray methods = getMethods(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
760 int length = methods.length(); |
0 | 761 Object[] tmp = new Object[length]; |
762 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
763 IntArray methodOrdering = getMethodOrdering(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
764 if (methodOrdering.length() != length) { |
0 | 765 // no ordering info present |
766 for (int index = 0; index < length; index++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
767 tmp[index] = methods.at(index); |
0 | 768 } |
769 } else { | |
770 for (int index = 0; index < length; index++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
771 int originalIndex = methodOrdering.at(index); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
772 tmp[originalIndex] = methods.at(index); |
0 | 773 } |
774 } | |
775 | |
776 return Arrays.asList(tmp); | |
777 } | |
778 | |
779 /** Return a List containing an SA InstanceKlass for each | |
780 interface named in this class's 'implements' clause. | |
781 */ | |
782 public List getDirectImplementedInterfaces() { | |
783 // Contains an InstanceKlass for each interface in this classes | |
784 // 'implements' clause. | |
785 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
786 KlassArray interfaces = getLocalInterfaces(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
787 int length = interfaces.length(); |
0 | 788 List directImplementedInterfaces = new ArrayList(length); |
789 | |
790 for (int index = 0; index < length; index ++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
791 directImplementedInterfaces.add(interfaces.getAt(index)); |
0 | 792 } |
793 | |
794 return directImplementedInterfaces; | |
795 } | |
796 | |
797 public Klass arrayKlassImpl(boolean orNull, int n) { | |
798 // FIXME: in reflective system this would need to change to | |
799 // actually allocate | |
800 if (getArrayKlasses() == null) { return null; } | |
801 ObjArrayKlass oak = (ObjArrayKlass) getArrayKlasses(); | |
802 if (orNull) { | |
803 return oak.arrayKlassOrNull(n); | |
804 } | |
805 return oak.arrayKlass(n); | |
806 } | |
807 | |
808 public Klass arrayKlassImpl(boolean orNull) { | |
809 return arrayKlassImpl(orNull, 1); | |
810 } | |
811 | |
812 public String signature() { | |
813 return "L" + super.signature() + ";"; | |
814 } | |
815 | |
816 /** Convenience routine taking Strings; lookup is done in | |
817 SymbolTable. */ | |
818 public Method findMethod(String name, String sig) { | |
819 SymbolTable syms = VM.getVM().getSymbolTable(); | |
820 Symbol nameSym = syms.probe(name); | |
821 Symbol sigSym = syms.probe(sig); | |
822 if (nameSym == null || sigSym == null) { | |
823 return null; | |
824 } | |
825 return findMethod(nameSym, sigSym); | |
826 } | |
827 | |
828 /** Find method in vtable. */ | |
829 public Method findMethod(Symbol name, Symbol sig) { | |
830 return findMethod(getMethods(), name, sig); | |
831 } | |
832 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
833 /** Breakpoint support (see methods on Method* for details) */ |
0 | 834 public BreakpointInfo getBreakpoints() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
835 Address addr = getAddress().getAddressAt(breakpoints.getOffset()); |
0 | 836 return (BreakpointInfo) VMObjectFactory.newObject(BreakpointInfo.class, addr); |
837 } | |
838 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
839 public IntArray getMethodOrdering() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
840 Address addr = getAddress().getAddressAt(methodOrdering.getOffset()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
841 return (IntArray) VMObjectFactory.newObject(IntArray.class, addr); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
842 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
843 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
844 public U2Array getFields() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
845 Address addr = getAddress().getAddressAt(fields.getOffset()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
846 return (U2Array) VMObjectFactory.newObject(U2Array.class, addr); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
847 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
848 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
849 public U2Array getInnerClasses() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
850 Address addr = getAddress().getAddressAt(innerClasses.getOffset()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
851 return (U2Array) VMObjectFactory.newObject(U2Array.class, addr); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
852 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
853 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
854 |
0 | 855 //---------------------------------------------------------------------- |
856 // Internals only below this point | |
857 // | |
858 | |
859 private void visitField(OopVisitor visitor, FieldType type, int index) { | |
860 Field f = newField(index); | |
861 if (type.isOop()) { | |
862 visitor.doOop((OopField) f, false); | |
863 return; | |
864 } | |
865 if (type.isByte()) { | |
866 visitor.doByte((ByteField) f, false); | |
867 return; | |
868 } | |
869 if (type.isChar()) { | |
870 visitor.doChar((CharField) f, false); | |
871 return; | |
872 } | |
873 if (type.isDouble()) { | |
874 visitor.doDouble((DoubleField) f, false); | |
875 return; | |
876 } | |
877 if (type.isFloat()) { | |
878 visitor.doFloat((FloatField) f, false); | |
879 return; | |
880 } | |
881 if (type.isInt()) { | |
882 visitor.doInt((IntField) f, false); | |
883 return; | |
884 } | |
885 if (type.isLong()) { | |
886 visitor.doLong((LongField) f, false); | |
887 return; | |
888 } | |
889 if (type.isShort()) { | |
890 visitor.doShort((ShortField) f, false); | |
891 return; | |
892 } | |
893 if (type.isBoolean()) { | |
894 visitor.doBoolean((BooleanField) f, false); | |
895 return; | |
896 } | |
897 } | |
898 | |
899 // Creates new field from index in fields TypeArray | |
900 private Field newField(int index) { | |
3944 | 901 FieldType type = new FieldType(getFieldSignature(index)); |
0 | 902 if (type.isOop()) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
903 if (VM.getVM().isCompressedOopsEnabled()) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
904 return new NarrowOopField(this, index); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
905 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
906 return new OopField(this, index); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
907 } |
0 | 908 } |
909 if (type.isByte()) { | |
910 return new ByteField(this, index); | |
911 } | |
912 if (type.isChar()) { | |
913 return new CharField(this, index); | |
914 } | |
915 if (type.isDouble()) { | |
916 return new DoubleField(this, index); | |
917 } | |
918 if (type.isFloat()) { | |
919 return new FloatField(this, index); | |
920 } | |
921 if (type.isInt()) { | |
922 return new IntField(this, index); | |
923 } | |
924 if (type.isLong()) { | |
925 return new LongField(this, index); | |
926 } | |
927 if (type.isShort()) { | |
928 return new ShortField(this, index); | |
929 } | |
930 if (type.isBoolean()) { | |
931 return new BooleanField(this, index); | |
932 } | |
933 throw new RuntimeException("Illegal field type at index " + index); | |
934 } | |
935 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
936 private static Method findMethod(MethodArray methods, Symbol name, Symbol signature) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
937 int len = methods.length(); |
0 | 938 // methods are sorted, so do binary search |
939 int l = 0; | |
940 int h = len - 1; | |
941 while (l <= h) { | |
942 int mid = (l + h) >> 1; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
943 Method m = methods.at(mid); |
0 | 944 int res = m.getName().fastCompare(name); |
945 if (res == 0) { | |
946 // found matching name; do linear search to find matching signature | |
947 // first, quick check for common case | |
948 if (m.getSignature().equals(signature)) return m; | |
949 // search downwards through overloaded methods | |
950 int i; | |
951 for (i = mid - 1; i >= l; i--) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
952 Method m1 = methods.at(i); |
0 | 953 if (!m1.getName().equals(name)) break; |
954 if (m1.getSignature().equals(signature)) return m1; | |
955 } | |
956 // search upwards | |
957 for (i = mid + 1; i <= h; i++) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
958 Method m1 = methods.at(i); |
0 | 959 if (!m1.getName().equals(name)) break; |
960 if (m1.getSignature().equals(signature)) return m1; | |
961 } | |
962 // not found | |
963 if (Assert.ASSERTS_ENABLED) { | |
964 int index = linearSearch(methods, name, signature); | |
965 if (index != -1) { | |
966 throw new DebuggerException("binary search bug: should have found entry " + index); | |
967 } | |
968 } | |
969 return null; | |
970 } else if (res < 0) { | |
971 l = mid + 1; | |
972 } else { | |
973 h = mid - 1; | |
974 } | |
975 } | |
976 if (Assert.ASSERTS_ENABLED) { | |
977 int index = linearSearch(methods, name, signature); | |
978 if (index != -1) { | |
979 throw new DebuggerException("binary search bug: should have found entry " + index); | |
980 } | |
981 } | |
982 return null; | |
983 } | |
984 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
985 private static int linearSearch(MethodArray methods, Symbol name, Symbol signature) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
986 int len = (int) methods.length(); |
0 | 987 for (int index = 0; index < len; index++) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6203
diff
changeset
|
988 Method m = methods.at(index); |
0 | 989 if (m.getSignature().equals(signature) && m.getName().equals(name)) { |
990 return index; | |
991 } | |
992 } | |
993 return -1; | |
994 } | |
6972
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
995 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
996 public void dumpReplayData(PrintStream out) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
997 ConstantPool cp = getConstants(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
998 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
999 // Try to record related loaded classes |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1000 Klass sub = getSubklassKlass(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1001 while (sub != null) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1002 if (sub instanceof InstanceKlass) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1003 out.println("instanceKlass " + sub.getName().asString()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1004 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1005 sub = sub.getNextSiblingKlass(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1006 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1007 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1008 final int length = (int) cp.getLength(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1009 out.print("ciInstanceKlass " + getName().asString() + " " + (isLinked() ? 1 : 0) + " " + (isInitialized() ? 1 : 0) + " " + length); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1010 for (int index = 1; index < length; index++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1011 out.print(" " + cp.getTags().at(index)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1012 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1013 out.println(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1014 if (isInitialized()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1015 Field[] staticFields = getStaticFields(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1016 for (int i = 0; i < staticFields.length; i++) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1017 Field f = staticFields[i]; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1018 Oop mirror = getJavaMirror(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1019 if (f.isFinal() && !f.hasInitialValue()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1020 out.print("staticfield " + getName().asString() + " " + |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1021 OopUtilities.escapeString(f.getID().getName()) + " " + |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1022 f.getFieldType().getSignature().asString() + " "); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1023 if (f instanceof ByteField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1024 ByteField bf = (ByteField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1025 out.println(bf.getValue(mirror)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1026 } else if (f instanceof BooleanField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1027 BooleanField bf = (BooleanField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1028 out.println(bf.getValue(mirror) ? 1 : 0); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1029 } else if (f instanceof ShortField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1030 ShortField bf = (ShortField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1031 out.println(bf.getValue(mirror)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1032 } else if (f instanceof CharField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1033 CharField bf = (CharField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1034 out.println(bf.getValue(mirror) & 0xffff); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1035 } else if (f instanceof IntField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1036 IntField bf = (IntField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1037 out.println(bf.getValue(mirror)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1038 } else if (f instanceof LongField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1039 LongField bf = (LongField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1040 out.println(bf.getValue(mirror)); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1041 } else if (f instanceof FloatField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1042 FloatField bf = (FloatField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1043 out.println(Float.floatToRawIntBits(bf.getValue(mirror))); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1044 } else if (f instanceof DoubleField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1045 DoubleField bf = (DoubleField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1046 out.println(Double.doubleToRawLongBits(bf.getValue(mirror))); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1047 } else if (f instanceof OopField) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1048 OopField bf = (OopField)f; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1049 |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1050 Oop value = bf.getValue(mirror); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1051 if (value == null) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1052 out.println("null"); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1053 } else if (value.isInstance()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1054 Instance inst = (Instance)value; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1055 if (inst.isA(SystemDictionary.getStringKlass())) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1056 out.println("\"" + OopUtilities.stringOopToEscapedString(inst) + "\""); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1057 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1058 out.println(inst.getKlass().getName().asString()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1059 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1060 } else if (value.isObjArray()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1061 ObjArray oa = (ObjArray)value; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1062 Klass ek = (ObjArrayKlass)oa.getKlass(); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1063 out.println(oa.getLength() + " " + ek.getName().asString()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1064 } else if (value.isTypeArray()) { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1065 TypeArray ta = (TypeArray)value; |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1066 out.println(ta.getLength()); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1067 } else { |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1068 out.println(value); |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1069 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1070 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1071 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1072 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1073 } |
bd7a7ce2e264
6830717: replay of compilations would help with debugging
minqi
parents:
6725
diff
changeset
|
1074 } |
0 | 1075 } |