Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java @ 20456:64156d22e49d
8032247: SA: Constantpool lookup for invokedynamic is not implemented
Summary: implement constant pool lookup for invokedynamic
Reviewed-by: sla, sspitsyn
author | dsamersoff |
---|---|
date | Thu, 11 Sep 2014 11:55:30 -0700 |
parents | da91efe96a93 |
children |
rev | line source |
---|---|
0 | 1 /* |
4864
b2cd0ee8f778
7114376: Make system dictionary hashtable bucket array size configurable
acorn
parents:
3908
diff
changeset
|
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1142
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1142
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1142
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.memory; | |
26 | |
27 import java.util.*; | |
28 import sun.jvm.hotspot.debugger.*; | |
29 import sun.jvm.hotspot.oops.*; | |
30 import sun.jvm.hotspot.runtime.*; | |
31 import sun.jvm.hotspot.types.*; | |
32 | |
33 public class SystemDictionary { | |
34 private static AddressField dictionaryField; | |
35 private static AddressField sharedDictionaryField; | |
36 private static AddressField placeholdersField; | |
37 private static AddressField loaderConstraintTableField; | |
147 | 38 private static sun.jvm.hotspot.types.OopField javaSystemLoaderField; |
0 | 39 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
40 private static AddressField objectKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
41 private static AddressField classLoaderKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
42 private static AddressField stringKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
43 private static AddressField systemKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
44 private static AddressField threadKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
45 private static AddressField threadGroupKlassField; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
46 private static AddressField methodHandleKlassField; |
0 | 47 |
48 static { | |
49 VM.registerVMInitializedObserver(new Observer() { | |
50 public void update(Observable o, Object data) { | |
51 initialize(VM.getVM().getTypeDataBase()); | |
52 } | |
53 }); | |
54 } | |
55 | |
56 private static synchronized void initialize(TypeDataBase db) { | |
57 Type type = db.lookupType("SystemDictionary"); | |
58 | |
59 dictionaryField = type.getAddressField("_dictionary"); | |
60 sharedDictionaryField = type.getAddressField("_shared_dictionary"); | |
61 placeholdersField = type.getAddressField("_placeholders"); | |
62 loaderConstraintTableField = type.getAddressField("_loader_constraints"); | |
63 javaSystemLoaderField = type.getOopField("_java_system_loader"); | |
64 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
65 objectKlassField = type.getAddressField(WK_KLASS("Object_klass")); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
66 classLoaderKlassField = type.getAddressField(WK_KLASS("ClassLoader_klass")); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
67 stringKlassField = type.getAddressField(WK_KLASS("String_klass")); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
68 systemKlassField = type.getAddressField(WK_KLASS("System_klass")); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
69 threadKlassField = type.getAddressField(WK_KLASS("Thread_klass")); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
70 threadGroupKlassField = type.getAddressField(WK_KLASS("ThreadGroup_klass")); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
71 methodHandleKlassField = type.getAddressField(WK_KLASS("MethodHandle_klass")); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
0
diff
changeset
|
72 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
0
diff
changeset
|
73 |
147 | 74 // This WK functions must follow the definitions in systemDictionary.hpp: |
75 private static String WK_KLASS(String name) { | |
76 //#define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)] | |
77 return ("_well_known_klasses[SystemDictionary::"+WK_KLASS_ENUM_NAME(name)+"]"); | |
78 } | |
79 private static String WK_KLASS_ENUM_NAME(String kname) { | |
80 //#define WK_KLASS_ENUM_NAME(kname) kname##_knum | |
81 return (kname+"_knum"); | |
0 | 82 } |
83 | |
84 public Dictionary dictionary() { | |
85 Address tmp = dictionaryField.getValue(); | |
86 return (Dictionary) VMObjectFactory.newObject(Dictionary.class, tmp); | |
87 } | |
88 | |
89 public Dictionary sharedDictionary() { | |
90 Address tmp = sharedDictionaryField.getValue(); | |
91 return (Dictionary) VMObjectFactory.newObject(Dictionary.class, tmp); | |
92 } | |
93 | |
94 public PlaceholderTable placeholders() { | |
95 Address tmp = placeholdersField.getValue(); | |
96 return (PlaceholderTable) VMObjectFactory.newObject(PlaceholderTable.class, tmp); | |
97 } | |
98 | |
99 public LoaderConstraintTable constraints() { | |
100 Address tmp = placeholdersField.getValue(); | |
101 return (LoaderConstraintTable) VMObjectFactory.newObject(LoaderConstraintTable.class, tmp); | |
102 } | |
103 | |
104 // few well known classes -- not all are added here. | |
105 // add more if needed. | |
106 public static InstanceKlass getThreadKlass() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
107 return (InstanceKlass)Metadata.instantiateWrapperFor(threadKlassField.getValue()); |
0 | 108 } |
109 | |
110 public static InstanceKlass getThreadGroupKlass() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
111 return (InstanceKlass)Metadata.instantiateWrapperFor(threadGroupKlassField.getValue()); |
0 | 112 } |
113 | |
114 public static InstanceKlass getObjectKlass() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
115 return (InstanceKlass)Metadata.instantiateWrapperFor(objectKlassField.getValue()); |
0 | 116 } |
117 | |
118 public static InstanceKlass getStringKlass() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
119 return (InstanceKlass)Metadata.instantiateWrapperFor(stringKlassField.getValue()); |
0 | 120 } |
121 | |
122 public static InstanceKlass getClassLoaderKlass() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
123 return (InstanceKlass)Metadata.instantiateWrapperFor(classLoaderKlassField.getValue()); |
0 | 124 } |
125 | |
126 public static InstanceKlass getSystemKlass() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
127 return (InstanceKlass)Metadata.instantiateWrapperFor(systemKlassField.getValue()); |
0 | 128 } |
129 | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
2042
diff
changeset
|
130 public static InstanceKlass getMethodHandleKlass() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4864
diff
changeset
|
131 return (InstanceKlass)Metadata.instantiateWrapperFor(methodHandleKlassField.getValue()); |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
2042
diff
changeset
|
132 } |
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
2042
diff
changeset
|
133 |
0 | 134 public InstanceKlass getAbstractOwnableSynchronizerKlass() { |
135 return (InstanceKlass) find("java/util/concurrent/locks/AbstractOwnableSynchronizer", | |
136 null, null); | |
137 } | |
138 | |
139 public static Oop javaSystemLoader() { | |
140 return newOop(javaSystemLoaderField.getValue()); | |
141 } | |
142 | |
143 private static Oop newOop(OopHandle handle) { | |
144 return VM.getVM().getObjectHeap().newOop(handle); | |
145 } | |
146 | |
147 /** Lookup an already loaded class. If not found null is returned. */ | |
148 public Klass find(String className, Oop classLoader, Oop protectionDomain) { | |
149 Symbol sym = VM.getVM().getSymbolTable().probe(className); | |
150 if (sym == null) return null; | |
151 return find(sym, classLoader, protectionDomain); | |
152 } | |
153 | |
154 /** Lookup an already loaded class. If not found null is returned. */ | |
155 public Klass find(Symbol className, Oop classLoader, Oop protectionDomain) { | |
156 Dictionary dict = dictionary(); | |
157 long hash = dict.computeHash(className, classLoader); | |
158 int index = dict.hashToIndex(hash); | |
159 return dict.find(index, hash, className, classLoader, protectionDomain); | |
160 } | |
161 | |
162 /** Interface for iterating through all classes in dictionary */ | |
163 public static interface ClassVisitor { | |
164 public void visit(Klass k); | |
165 } | |
166 | |
167 /** Interface for iterating through all classes and their class | |
168 loaders in dictionary */ | |
169 public static interface ClassAndLoaderVisitor { | |
170 public void visit(Klass k, Oop loader); | |
171 } | |
172 | |
173 /** Iterate over all klasses - including object, primitive | |
174 array klasses */ | |
175 public void allClassesDo(final ClassVisitor v) { | |
176 ClassVisitor visitor = new ClassVisitor() { | |
177 public void visit(Klass k) { | |
178 for (Klass l = k; l != null; l = l.arrayKlassOrNull()) { | |
179 v.visit(l); | |
180 } | |
181 } | |
182 }; | |
183 classesDo(visitor); | |
184 VM.getVM().getUniverse().basicTypeClassesDo(visitor); | |
185 } | |
186 | |
187 /** Iterate over all klasses in dictionary; just the classes from | |
188 declaring class loaders */ | |
189 public void classesDo(ClassVisitor v) { | |
190 dictionary().classesDo(v); | |
191 } | |
192 | |
193 /** All classes, and their class loaders */ | |
194 public void classesDo(ClassAndLoaderVisitor v) { | |
195 dictionary().classesDo(v); | |
196 } | |
197 | |
198 /** All array classes of primitive type, and their class loaders */ | |
199 public void primArrayClassesDo(ClassAndLoaderVisitor v) { | |
200 placeholders().primArrayClassesDo(v); | |
201 } | |
202 } |