src/share/vm/classfile/systemDictionary.hpp

Print this page
rev 5685 : 8028128: Add a type safe alternative for working with counter based data
Reviewed-by:


  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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  26 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  27 
  28 #include "classfile/classFileStream.hpp"
  29 #include "classfile/classLoader.hpp"
  30 #include "oops/objArrayOop.hpp"
  31 #include "oops/symbol.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/reflectionUtils.hpp"
  34 #include "trace/traceTime.hpp"
  35 #include "utilities/hashtable.hpp"
  36 #include "utilities/hashtable.inline.hpp"
  37 
  38 
  39 // The system dictionary stores all loaded classes and maps:
  40 //
  41 //   [class name,class loader] -> class   i.e.  [Symbol*,oop] -> Klass*
  42 //
  43 // Classes are loaded lazily. The default VM class loader is
  44 // represented as NULL.
  45 
  46 // The underlying data structure is an open hash table with a fixed number
  47 // of buckets. During loading the loader object is locked, (for the VM loader
  48 // a private lock object is used). Class loading can thus be done concurrently,
  49 // but only by different loaders.
  50 //
  51 // During loading a placeholder (name, loader) is temporarily placed in
  52 // a side data structure, and is used to detect ClassCircularityErrors
  53 // and to perform verification during GC.  A GC can occur in the midst
  54 // of class loading, as we call out to Java, have to take locks, etc.


  61 // Clients of this class who are interested in finding if a class has
  62 // been completely loaded -- not classes in the process of being loaded --
  63 // can read the SystemDictionary unlocked. This is safe because
  64 //    - entries are only deleted at safepoints
  65 //    - readers cannot come to a safepoint while actively examining
  66 //         an entry  (an entry cannot be deleted from under a reader)
  67 //    - entries must be fully formed before they are available to concurrent
  68 //         readers (we must ensure write ordering)
  69 //
  70 // Note that placeholders are deleted at any time, as they are removed
  71 // when a class is completely loaded. Therefore, readers as well as writers
  72 // of placeholders must hold the SystemDictionary_lock.
  73 //
  74 
  75 class Dictionary;
  76 class PlaceholderTable;
  77 class LoaderConstraintTable;
  78 template <MEMFLAGS F> class HashtableBucket;
  79 class ResolutionErrorTable;
  80 class SymbolPropertyTable;

  81 
  82 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  83 // They are all "well-known", in the sense that no class loader is allowed
  84 // to provide a different definition.
  85 //
  86 // These klasses must all have names defined in vmSymbols.
  87 
  88 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  89 
  90 // Each well-known class has a short klass name (like object_klass),
  91 // a vmSymbol name (like java_lang_Object), and a flag word
  92 // that makes some minor distinctions, like whether the klass
  93 // is preloaded, optional, release-specific, etc.
  94 // The order of these definitions is significant; it is the order in which
  95 // preloading is actually performed by initialize_preloaded_classes.
  96 
  97 #define WK_KLASSES_DO(do_klass)                                                                                          \
  98   /* well-known classes */                                                                                               \
  99   do_klass(Object_klass,                                java_lang_Object,                          Pre                 ) \
 100   do_klass(String_klass,                                java_lang_String,                          Pre                 ) \


 620                                                Handle class_loader, TRAPS);
 621   static instanceKlassHandle load_shared_class(instanceKlassHandle ik,
 622                                                Handle class_loader, TRAPS);
 623   static void clean_up_shared_class(instanceKlassHandle ik, Handle class_loader, TRAPS);
 624   static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
 625   static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
 626   static void check_loader_lock_contention(Handle loader_lock, TRAPS);
 627   static bool is_parallelCapable(Handle class_loader);
 628   static bool is_parallelDefine(Handle class_loader);
 629 
 630 public:
 631   static bool is_ext_class_loader(Handle class_loader);
 632 
 633 private:
 634   static Klass* find_shared_class(Symbol* class_name);
 635 
 636   // Setup link to hierarchy
 637   static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
 638 
 639   // event based tracing
 640   static void post_class_load_event(TracingTime start_time, instanceKlassHandle k,
 641                                     Handle initiating_loader);
 642   // We pass in the hashtable index so we can calculate it outside of
 643   // the SystemDictionary_lock.
 644 
 645   // Basic find on loaded classes
 646   static Klass* find_class(int index, unsigned int hash,
 647                              Symbol* name, ClassLoaderData* loader_data);
 648   static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
 649 
 650   // Basic find on classes in the midst of being loaded
 651   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
 652 
 653   // Updating entry in dictionary
 654   // Add a completely loaded class
 655   static void add_klass(int index, Symbol* class_name,
 656                         ClassLoaderData* loader_data, KlassHandle obj);
 657 
 658   // Add a placeholder for a class being loaded
 659   static void add_placeholder(int index,
 660                               Symbol* class_name,




  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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  26 #define SHARE_VM_CLASSFILE_SYSTEMDICTIONARY_HPP
  27 
  28 #include "classfile/classFileStream.hpp"
  29 #include "classfile/classLoader.hpp"
  30 #include "oops/objArrayOop.hpp"
  31 #include "oops/symbol.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/reflectionUtils.hpp"

  34 #include "utilities/hashtable.hpp"
  35 #include "utilities/hashtable.inline.hpp"
  36 
  37 
  38 // The system dictionary stores all loaded classes and maps:
  39 //
  40 //   [class name,class loader] -> class   i.e.  [Symbol*,oop] -> Klass*
  41 //
  42 // Classes are loaded lazily. The default VM class loader is
  43 // represented as NULL.
  44 
  45 // The underlying data structure is an open hash table with a fixed number
  46 // of buckets. During loading the loader object is locked, (for the VM loader
  47 // a private lock object is used). Class loading can thus be done concurrently,
  48 // but only by different loaders.
  49 //
  50 // During loading a placeholder (name, loader) is temporarily placed in
  51 // a side data structure, and is used to detect ClassCircularityErrors
  52 // and to perform verification during GC.  A GC can occur in the midst
  53 // of class loading, as we call out to Java, have to take locks, etc.


  60 // Clients of this class who are interested in finding if a class has
  61 // been completely loaded -- not classes in the process of being loaded --
  62 // can read the SystemDictionary unlocked. This is safe because
  63 //    - entries are only deleted at safepoints
  64 //    - readers cannot come to a safepoint while actively examining
  65 //         an entry  (an entry cannot be deleted from under a reader)
  66 //    - entries must be fully formed before they are available to concurrent
  67 //         readers (we must ensure write ordering)
  68 //
  69 // Note that placeholders are deleted at any time, as they are removed
  70 // when a class is completely loaded. Therefore, readers as well as writers
  71 // of placeholders must hold the SystemDictionary_lock.
  72 //
  73 
  74 class Dictionary;
  75 class PlaceholderTable;
  76 class LoaderConstraintTable;
  77 template <MEMFLAGS F> class HashtableBucket;
  78 class ResolutionErrorTable;
  79 class SymbolPropertyTable;
  80 class Ticks;
  81 
  82 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  83 // They are all "well-known", in the sense that no class loader is allowed
  84 // to provide a different definition.
  85 //
  86 // These klasses must all have names defined in vmSymbols.
  87 
  88 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  89 
  90 // Each well-known class has a short klass name (like object_klass),
  91 // a vmSymbol name (like java_lang_Object), and a flag word
  92 // that makes some minor distinctions, like whether the klass
  93 // is preloaded, optional, release-specific, etc.
  94 // The order of these definitions is significant; it is the order in which
  95 // preloading is actually performed by initialize_preloaded_classes.
  96 
  97 #define WK_KLASSES_DO(do_klass)                                                                                          \
  98   /* well-known classes */                                                                                               \
  99   do_klass(Object_klass,                                java_lang_Object,                          Pre                 ) \
 100   do_klass(String_klass,                                java_lang_String,                          Pre                 ) \


 620                                                Handle class_loader, TRAPS);
 621   static instanceKlassHandle load_shared_class(instanceKlassHandle ik,
 622                                                Handle class_loader, TRAPS);
 623   static void clean_up_shared_class(instanceKlassHandle ik, Handle class_loader, TRAPS);
 624   static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
 625   static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
 626   static void check_loader_lock_contention(Handle loader_lock, TRAPS);
 627   static bool is_parallelCapable(Handle class_loader);
 628   static bool is_parallelDefine(Handle class_loader);
 629 
 630 public:
 631   static bool is_ext_class_loader(Handle class_loader);
 632 
 633 private:
 634   static Klass* find_shared_class(Symbol* class_name);
 635 
 636   // Setup link to hierarchy
 637   static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
 638 
 639   // event based tracing
 640   static void post_class_load_event(const Ticks& start_time, instanceKlassHandle k,
 641                                     Handle initiating_loader);
 642   // We pass in the hashtable index so we can calculate it outside of
 643   // the SystemDictionary_lock.
 644 
 645   // Basic find on loaded classes
 646   static Klass* find_class(int index, unsigned int hash,
 647                              Symbol* name, ClassLoaderData* loader_data);
 648   static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
 649 
 650   // Basic find on classes in the midst of being loaded
 651   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
 652 
 653   // Updating entry in dictionary
 654   // Add a completely loaded class
 655   static void add_klass(int index, Symbol* class_name,
 656                         ClassLoaderData* loader_data, KlassHandle obj);
 657 
 658   // Add a placeholder for a class being loaded
 659   static void add_placeholder(int index,
 660                               Symbol* class_name,