< prev index next >

src/hotspot/share/oops/klass.hpp

Print this page

 26 #define SHARE_OOPS_KLASS_HPP
 27 
 28 #include "memory/iterator.hpp"
 29 #include "memory/memRegion.hpp"
 30 #include "oops/markWord.hpp"
 31 #include "oops/metadata.hpp"
 32 #include "oops/oop.hpp"
 33 #include "oops/oopHandle.hpp"
 34 #include "utilities/accessFlags.hpp"
 35 #include "utilities/macros.hpp"
 36 #if INCLUDE_JFR
 37 #include "jfr/support/jfrTraceIdExtension.hpp"
 38 #endif
 39 
 40 // Klass IDs for all subclasses of Klass
 41 enum KlassID {
 42   InstanceKlassID,
 43   InstanceRefKlassID,
 44   InstanceMirrorKlassID,
 45   InstanceClassLoaderKlassID,

 46   TypeArrayKlassID,
 47   ObjArrayKlassID
 48 };
 49 
 50 const uint KLASS_ID_COUNT = 6;
 51 
 52 //
 53 // A Klass provides:
 54 //  1: language level class object (method dictionary etc.)
 55 //  2: provide vm dispatch behavior for the object
 56 // Both functions are combined into one C++ class.
 57 
 58 // One reason for the oop/klass dichotomy in the implementation is
 59 // that we don't want a C++ vtbl pointer in every object.  Thus,
 60 // normal oops don't have any virtual functions.  Instead, they
 61 // forward all "virtual" functions to their klass, which does have
 62 // a vtbl and does the C++ dispatch depending on the object's
 63 // actual type.  (See oop.inline.hpp for some of the forwarding code.)
 64 // ALL FUNCTIONS IMPLEMENTING THIS DISPATCH ARE PREFIXED WITH "oop_"!
 65 
 66 // Forward declarations.
 67 template <class T> class Array;
 68 template <class T> class GrowableArray;
 69 class ClassLoaderData;
 70 class fieldDescriptor;

538 
539   bool is_unshareable_info_restored() const {
540     assert(is_shared(), "use this for shared classes only");
541     if (has_archived_mirror_index()) {
542       // _java_mirror is not a valid OopHandle but rather an encoded reference in the shared heap
543       return false;
544     } else if (_java_mirror.ptr_raw() == NULL) {
545       return false;
546     } else {
547       return true;
548     }
549   }
550 
551  public:
552   // ALL FUNCTIONS BELOW THIS POINT ARE DISPATCHED FROM AN OOP
553   // These functions describe behavior for the oop not the KLASS.
554 
555   // actual oop size of obj in memory in word size.
556   virtual size_t oop_size(oop obj) const = 0;
557 



558   // Size of klass in word size.
559   virtual int size() const = 0;
560 
561   // Returns the Java name for a class (Resource allocated)
562   // For arrays, this returns the name of the element with a leading '['.
563   // For classes, this returns the name with the package separators
564   //     turned into '.'s.
565   const char* external_name() const;
566   // Returns the name for a class (Resource allocated) as the class
567   // would appear in a signature.
568   // For arrays, this returns the name of the element with a leading '['.
569   // For classes, this returns the name with a leading 'L' and a trailing ';'
570   //     and the package separators as '/'.
571   virtual const char* signature_name() const;
572 
573   const char* joint_in_module_of_loader(const Klass* class2, bool include_parent_loader = false) const;
574   const char* class_in_module_of_loader(bool use_are = false, bool include_parent_loader = false) const;
575 
576   // Returns "interface", "abstract class" or "class".
577   const char* external_kind() const;
578 





579   // type testing operations
580 #ifdef ASSERT
581  protected:
582   virtual bool is_instance_klass_slow()     const { return false; }
583   virtual bool is_array_klass_slow()        const { return false; }
584   virtual bool is_objArray_klass_slow()     const { return false; }
585   virtual bool is_typeArray_klass_slow()    const { return false; }
586 #endif // ASSERT
587  public:
588 
589   // Fast non-virtual versions
590   #ifndef ASSERT
591   #define assert_same_query(xval, xcheck) xval
592   #else
593  private:
594   static bool assert_same_query(bool xval, bool xslow) {
595     assert(xval == xslow, "slow and fast queries agree");
596     return xval;
597   }
598  public:

 26 #define SHARE_OOPS_KLASS_HPP
 27 
 28 #include "memory/iterator.hpp"
 29 #include "memory/memRegion.hpp"
 30 #include "oops/markWord.hpp"
 31 #include "oops/metadata.hpp"
 32 #include "oops/oop.hpp"
 33 #include "oops/oopHandle.hpp"
 34 #include "utilities/accessFlags.hpp"
 35 #include "utilities/macros.hpp"
 36 #if INCLUDE_JFR
 37 #include "jfr/support/jfrTraceIdExtension.hpp"
 38 #endif
 39 
 40 // Klass IDs for all subclasses of Klass
 41 enum KlassID {
 42   InstanceKlassID,
 43   InstanceRefKlassID,
 44   InstanceMirrorKlassID,
 45   InstanceClassLoaderKlassID,
 46   InstanceStackChunkKlassID,
 47   TypeArrayKlassID,
 48   ObjArrayKlassID
 49 };
 50 
 51 const uint KLASS_ID_COUNT = 7;
 52 
 53 //
 54 // A Klass provides:
 55 //  1: language level class object (method dictionary etc.)
 56 //  2: provide vm dispatch behavior for the object
 57 // Both functions are combined into one C++ class.
 58 
 59 // One reason for the oop/klass dichotomy in the implementation is
 60 // that we don't want a C++ vtbl pointer in every object.  Thus,
 61 // normal oops don't have any virtual functions.  Instead, they
 62 // forward all "virtual" functions to their klass, which does have
 63 // a vtbl and does the C++ dispatch depending on the object's
 64 // actual type.  (See oop.inline.hpp for some of the forwarding code.)
 65 // ALL FUNCTIONS IMPLEMENTING THIS DISPATCH ARE PREFIXED WITH "oop_"!
 66 
 67 // Forward declarations.
 68 template <class T> class Array;
 69 template <class T> class GrowableArray;
 70 class ClassLoaderData;
 71 class fieldDescriptor;

539 
540   bool is_unshareable_info_restored() const {
541     assert(is_shared(), "use this for shared classes only");
542     if (has_archived_mirror_index()) {
543       // _java_mirror is not a valid OopHandle but rather an encoded reference in the shared heap
544       return false;
545     } else if (_java_mirror.ptr_raw() == NULL) {
546       return false;
547     } else {
548       return true;
549     }
550   }
551 
552  public:
553   // ALL FUNCTIONS BELOW THIS POINT ARE DISPATCHED FROM AN OOP
554   // These functions describe behavior for the oop not the KLASS.
555 
556   // actual oop size of obj in memory in word size.
557   virtual size_t oop_size(oop obj) const = 0;
558 
559   // the size of the object in memory after possible compression during GC promotion/compaction
560   virtual size_t compact_oop_size(oop obj) const { return oop_size(obj); }
561 
562   // Size of klass in word size.
563   virtual int size() const = 0;
564 
565   // Returns the Java name for a class (Resource allocated)
566   // For arrays, this returns the name of the element with a leading '['.
567   // For classes, this returns the name with the package separators
568   //     turned into '.'s.
569   const char* external_name() const;
570   // Returns the name for a class (Resource allocated) as the class
571   // would appear in a signature.
572   // For arrays, this returns the name of the element with a leading '['.
573   // For classes, this returns the name with a leading 'L' and a trailing ';'
574   //     and the package separators as '/'.
575   virtual const char* signature_name() const;
576 
577   const char* joint_in_module_of_loader(const Klass* class2, bool include_parent_loader = false) const;
578   const char* class_in_module_of_loader(bool use_are = false, bool include_parent_loader = false) const;
579 
580   // Returns "interface", "abstract class" or "class".
581   const char* external_kind() const;
582 
583   virtual size_t copy_disjoint(oop obj, HeapWord* to, size_t word_size);
584   virtual size_t copy_conjoint(oop obj, HeapWord* to, size_t word_size);
585   virtual size_t copy_disjoint_compact(oop obj, HeapWord* to);
586   virtual size_t copy_conjoint_compact(oop obj, HeapWord* to);
587 
588   // type testing operations
589 #ifdef ASSERT
590  protected:
591   virtual bool is_instance_klass_slow()     const { return false; }
592   virtual bool is_array_klass_slow()        const { return false; }
593   virtual bool is_objArray_klass_slow()     const { return false; }
594   virtual bool is_typeArray_klass_slow()    const { return false; }
595 #endif // ASSERT
596  public:
597 
598   // Fast non-virtual versions
599   #ifndef ASSERT
600   #define assert_same_query(xval, xcheck) xval
601   #else
602  private:
603   static bool assert_same_query(bool xval, bool xslow) {
604     assert(xval == xslow, "slow and fast queries agree");
605     return xval;
606   }
607  public:
< prev index next >