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