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 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
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;
38 private static sun.jvm.hotspot.types.OopField javaSystemLoaderField;
39 private static int nofBuckets;
40
41 private static sun.jvm.hotspot.types.OopField objectKlassField;
42 private static sun.jvm.hotspot.types.OopField classLoaderKlassField;
43 private static sun.jvm.hotspot.types.OopField stringKlassField;
44 private static sun.jvm.hotspot.types.OopField systemKlassField;
45 private static sun.jvm.hotspot.types.OopField threadKlassField;
46 private static sun.jvm.hotspot.types.OopField threadGroupKlassField;
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 nofBuckets = db.lookupIntConstant("SystemDictionary::_nof_buckets").intValue();
65
66 objectKlassField = type.getOopField("_object_klass");
67 classLoaderKlassField = type.getOopField("_classloader_klass");
68 stringKlassField = type.getOopField("_string_klass");
69 systemKlassField = type.getOopField("_system_klass");
70 threadKlassField = type.getOopField("_thread_klass");
71 threadGroupKlassField = type.getOopField("_threadGroup_klass");
72 }
73
74 public Dictionary dictionary() {
75 Address tmp = dictionaryField.getValue();
76 return (Dictionary) VMObjectFactory.newObject(Dictionary.class, tmp);
77 }
78
79 public Dictionary sharedDictionary() {
80 Address tmp = sharedDictionaryField.getValue();
81 return (Dictionary) VMObjectFactory.newObject(Dictionary.class, tmp);
82 }
83
84 public PlaceholderTable placeholders() {
85 Address tmp = placeholdersField.getValue();
86 return (PlaceholderTable) VMObjectFactory.newObject(PlaceholderTable.class, tmp);
87 }
88
89 public LoaderConstraintTable constraints() {
90 Address tmp = placeholdersField.getValue();
91 return (LoaderConstraintTable) VMObjectFactory.newObject(LoaderConstraintTable.class, tmp);
92 }
93
|
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 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
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 import sun.jvm.hotspot.types.OopField; // resolve ambiguity with oops.OopField
33
34 // following needed for on-the-fly field construction:
35 import sun.jvm.hotspot.types.basic.BasicOopField;
36 import sun.jvm.hotspot.types.basic.BasicTypeDataBase;
37
38 public class SystemDictionary {
39 private static AddressField dictionaryField;
40 private static AddressField sharedDictionaryField;
41 private static AddressField placeholdersField;
42 private static AddressField loaderConstraintTableField;
43 private static OopField javaSystemLoaderField;
44 private static int nofBuckets;
45
46 private static OopField wellKnownKlasses;
47 private static OopField objectKlassField;
48 private static OopField classLoaderKlassField;
49 private static OopField stringKlassField;
50 private static OopField systemKlassField;
51 private static OopField threadKlassField;
52 private static OopField threadGroupKlassField;
53
54 static {
55 VM.registerVMInitializedObserver(new Observer() {
56 public void update(Observable o, Object data) {
57 initialize(VM.getVM().getTypeDataBase());
58 }
59 });
60 }
61
62 private static synchronized void initialize(TypeDataBase db) {
63 Type type = db.lookupType("SystemDictionary");
64
65 dictionaryField = type.getAddressField("_dictionary");
66 sharedDictionaryField = type.getAddressField("_shared_dictionary");
67 placeholdersField = type.getAddressField("_placeholders");
68 loaderConstraintTableField = type.getAddressField("_loader_constraints");
69 javaSystemLoaderField = type.getOopField("_java_system_loader");
70 nofBuckets = db.lookupIntConstant("SystemDictionary::_nof_buckets").intValue();
71
72 wellKnownKlasses = type.getOopField("_well_known_klasses[0]");
73 objectKlassField = findWellKnownKlass("object_klass", type, db);
74 classLoaderKlassField = findWellKnownKlass("classloader_klass", type, db);
75 stringKlassField = findWellKnownKlass("string_klass", type, db);
76 systemKlassField = findWellKnownKlass("system_klass", type, db);
77 threadKlassField = findWellKnownKlass("thread_klass", type, db);
78 threadGroupKlassField = findWellKnownKlass("threadGroup_klass", type, db);
79 }
80
81 private static OopField findWellKnownKlass(String indexName, Type type, TypeDataBase db) {
82 Address wkk = wellKnownKlasses.getStaticFieldAddress();
83 int index = db.lookupIntConstant("SystemDictionary::#"+indexName).intValue();
84 return new BasicOopField((BasicTypeDataBase)db, type, indexName, type,
85 true, index * db.getAddressSize(), wkk);
86 }
87
88 public Dictionary dictionary() {
89 Address tmp = dictionaryField.getValue();
90 return (Dictionary) VMObjectFactory.newObject(Dictionary.class, tmp);
91 }
92
93 public Dictionary sharedDictionary() {
94 Address tmp = sharedDictionaryField.getValue();
95 return (Dictionary) VMObjectFactory.newObject(Dictionary.class, tmp);
96 }
97
98 public PlaceholderTable placeholders() {
99 Address tmp = placeholdersField.getValue();
100 return (PlaceholderTable) VMObjectFactory.newObject(PlaceholderTable.class, tmp);
101 }
102
103 public LoaderConstraintTable constraints() {
104 Address tmp = placeholdersField.getValue();
105 return (LoaderConstraintTable) VMObjectFactory.newObject(LoaderConstraintTable.class, tmp);
106 }
107
|