hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java

Print this page
rev 611 : Merge
   1 /*
   2  * Copyright 2001-2005 Sun Microsystems, Inc.  All Rights Reserved.
   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  *
  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  *  


  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);


   1 /*
   2  * Copyright 2001-2008 Sun Microsystems, Inc.  All Rights Reserved.
   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  *
  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  *


  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(WK_KLASS("object_klass"));
  67     classLoaderKlassField = type.getOopField(WK_KLASS("classloader_klass"));
  68     stringKlassField = type.getOopField(WK_KLASS("string_klass"));
  69     systemKlassField = type.getOopField(WK_KLASS("system_klass"));
  70     threadKlassField = type.getOopField(WK_KLASS("thread_klass"));
  71     threadGroupKlassField = type.getOopField(WK_KLASS("threadGroup_klass"));
  72   }
  73 
  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");
  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);