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

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



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





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

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