src/share/vm/classfile/systemDictionary.hpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


  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 // The system dictionary stores all loaded classes and maps:
  38 //
  39 //   [class name,class loader] -> class   i.e.  [Symbol*,oop] -> Klass*
  40 //
  41 // Classes are loaded lazily. The default VM class loader is
  42 // represented as NULL.
  43 
  44 // The underlying data structure is an open hash table with a fixed number
  45 // of buckets. During loading the loader object is locked, (for the VM loader
  46 // a private lock object is used). Class loading can thus be done concurrently,
  47 // but only by different loaders.
  48 //
  49 // During loading a placeholder (name, loader) is temporarily placed in
  50 // a side data structure, and is used to detect ClassCircularityErrors
  51 // and to perform verification during GC.  A GC can occur in the midst
  52 // of class loading, as we call out to Java, have to take locks, etc.
  53 //
  54 // When class loading is finished, a new entry is added to the system
  55 // dictionary and the place holder is removed. Note that the protection
  56 // domain field of the system dictionary has not yet been filled in when


 619   static instanceKlassHandle load_shared_class(Symbol* class_name,
 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   // We pass in the hashtable index so we can calculate it outside of
 640   // the SystemDictionary_lock.
 641 
 642   // Basic find on loaded classes
 643   static Klass* find_class(int index, unsigned int hash,
 644                              Symbol* name, ClassLoaderData* loader_data);
 645   static Klass* find_class(Symbol* class_name, ClassLoaderData* loader_data);
 646 
 647   // Basic find on classes in the midst of being loaded
 648   static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
 649 
 650   // Updating entry in dictionary
 651   // Add a completely loaded class
 652   static void add_klass(int index, Symbol* class_name,
 653                         ClassLoaderData* loader_data, KlassHandle obj);
 654 
 655   // Add a placeholder for a class being loaded
 656   static void add_placeholder(int index,
 657                               Symbol* class_name,
 658                               ClassLoaderData* loader_data);




  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.
  55 //
  56 // When class loading is finished, a new entry is added to the system
  57 // dictionary and the place holder is removed. Note that the protection
  58 // domain field of the system dictionary has not yet been filled in when


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