< prev index next >

src/share/vm/oops/klass.hpp

Print this page




  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_OOPS_KLASS_HPP
  26 #define SHARE_VM_OOPS_KLASS_HPP
  27 
  28 #include "memory/genOopClosures.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "memory/specialized_oop_closures.hpp"
  32 #include "oops/klassPS.hpp"
  33 #include "oops/metadata.hpp"
  34 #include "oops/oop.hpp"
  35 #include "trace/traceMacros.hpp"
  36 #include "utilities/accessFlags.hpp"
  37 #include "utilities/macros.hpp"
  38 #if INCLUDE_ALL_GCS
  39 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp"
  40 #include "gc_implementation/g1/g1OopClosures.hpp"
  41 #include "gc_implementation/parNew/parOopClosures.hpp"
  42 #endif // INCLUDE_ALL_GCS



  43 
  44 //
  45 // A Klass provides:
  46 //  1: language level class object (method dictionary etc.)
  47 //  2: provide vm dispatch behavior for the object
  48 // Both functions are combined into one C++ class.
  49 
  50 // One reason for the oop/klass dichotomy in the implementation is
  51 // that we don't want a C++ vtbl pointer in every object.  Thus,
  52 // normal oops don't have any virtual functions.  Instead, they
  53 // forward all "virtual" functions to their klass, which does have
  54 // a vtbl and does the C++ dispatch depending on the object's
  55 // actual type.  (See oop.inline.hpp for some of the forwarding code.)
  56 // ALL FUNCTIONS IMPLEMENTING THIS DISPATCH ARE PREFIXED WITH "oop_"!
  57 
  58 //  Klass layout:
  59 //    [C++ vtbl ptr  ] (contained in Metadata)
  60 //    [layout_helper ]
  61 //    [super_check_offset   ] for fast subtype checks
  62 //    [name          ]


 153   Klass*      _subklass;
 154   // Sibling link (or NULL); links all subklasses of a klass
 155   Klass*      _next_sibling;
 156 
 157   // All klasses loaded by a class loader are chained through these links
 158   Klass*      _next_link;
 159 
 160   // The VM's representation of the ClassLoader used to load this class.
 161   // Provide access the corresponding instance java.lang.ClassLoader.
 162   ClassLoaderData* _class_loader_data;
 163 
 164   jint        _modifier_flags;  // Processed access flags, for use by Class.getModifiers.
 165   AccessFlags _access_flags;    // Access flags. The class/interface distinction is stored here.
 166 
 167   // Biased locking implementation and statistics
 168   // (the 64-bit chunk goes first, to avoid some fragmentation)
 169   jlong    _last_biased_lock_bulk_revocation_time;
 170   markOop  _prototype_header;   // Used when biased locking is both enabled and disabled for this type
 171   jint     _biased_lock_revocation_count;
 172 
 173   TRACE_DEFINE_KLASS_TRACE_ID;
 174 
 175   // Remembered sets support for the oops in the klasses.
 176   jbyte _modified_oops;             // Card Table Equivalent (YC/CMS support)
 177   jbyte _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
 178 
 179 private:
 180   // This is an index into FileMapHeader::_classpath_entry_table[], to
 181   // associate this class with the JAR file where it's loaded from during
 182   // dump time. If a class is not loaded from the shared archive, this field is
 183   // -1.
 184   jshort _shared_class_path_index;
 185 
 186   friend class SharedClassUtil;
 187 protected:
 188 
 189   // Constructor
 190   Klass();
 191 
 192   void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
 193 


 596   // biasable and have an epoch.
 597   markOop prototype_header() const      { return _prototype_header; }
 598   // NOTE: once instances of this klass are floating around in the
 599   // system, this header must only be updated at a safepoint.
 600   // NOTE 2: currently we only ever set the prototype header to the
 601   // biasable prototype for instanceKlasses. There is no technical
 602   // reason why it could not be done for arrayKlasses aside from
 603   // wanting to reduce the initial scope of this optimization. There
 604   // are potential problems in setting the bias pattern for
 605   // JVM-internal oops.
 606   inline void set_prototype_header(markOop header);
 607   static ByteSize prototype_header_offset() { return in_ByteSize(offset_of(Klass, _prototype_header)); }
 608 
 609   int  biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }
 610   // Atomically increments biased_lock_revocation_count and returns updated value
 611   int atomic_incr_biased_lock_revocation_count();
 612   void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
 613   jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
 614   void  set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
 615 
 616   TRACE_DEFINE_KLASS_METHODS;
 617 
 618   // garbage collection support
 619   virtual void oops_do(OopClosure* cl);
 620 
 621   // Iff the class loader (or mirror for anonymous classes) is alive the
 622   // Klass is considered alive.
 623   // The is_alive closure passed in depends on the Garbage Collector used.
 624   bool is_loader_alive(BoolObjectClosure* is_alive);
 625 
 626   static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
 627   static void clean_subklass_tree(BoolObjectClosure* is_alive) {
 628     clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
 629   }
 630 
 631   // iterators
 632   virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0;
 633   virtual int oop_oop_iterate_v(oop obj, ExtendedOopClosure* blk) {
 634     return oop_oop_iterate(obj, blk);
 635   }
 636 




  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_OOPS_KLASS_HPP
  26 #define SHARE_VM_OOPS_KLASS_HPP
  27 
  28 #include "memory/genOopClosures.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "memory/specialized_oop_closures.hpp"
  32 #include "oops/klassPS.hpp"
  33 #include "oops/metadata.hpp"
  34 #include "oops/oop.hpp"

  35 #include "utilities/accessFlags.hpp"
  36 #include "utilities/macros.hpp"
  37 #if INCLUDE_ALL_GCS
  38 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp"
  39 #include "gc_implementation/g1/g1OopClosures.hpp"
  40 #include "gc_implementation/parNew/parOopClosures.hpp"
  41 #endif // INCLUDE_ALL_GCS
  42 #if INCLUDE_JFR
  43 #include "jfr/support/jfrTraceIdExtension.hpp"
  44 #endif
  45 
  46 //
  47 // A Klass provides:
  48 //  1: language level class object (method dictionary etc.)
  49 //  2: provide vm dispatch behavior for the object
  50 // Both functions are combined into one C++ class.
  51 
  52 // One reason for the oop/klass dichotomy in the implementation is
  53 // that we don't want a C++ vtbl pointer in every object.  Thus,
  54 // normal oops don't have any virtual functions.  Instead, they
  55 // forward all "virtual" functions to their klass, which does have
  56 // a vtbl and does the C++ dispatch depending on the object's
  57 // actual type.  (See oop.inline.hpp for some of the forwarding code.)
  58 // ALL FUNCTIONS IMPLEMENTING THIS DISPATCH ARE PREFIXED WITH "oop_"!
  59 
  60 //  Klass layout:
  61 //    [C++ vtbl ptr  ] (contained in Metadata)
  62 //    [layout_helper ]
  63 //    [super_check_offset   ] for fast subtype checks
  64 //    [name          ]


 155   Klass*      _subklass;
 156   // Sibling link (or NULL); links all subklasses of a klass
 157   Klass*      _next_sibling;
 158 
 159   // All klasses loaded by a class loader are chained through these links
 160   Klass*      _next_link;
 161 
 162   // The VM's representation of the ClassLoader used to load this class.
 163   // Provide access the corresponding instance java.lang.ClassLoader.
 164   ClassLoaderData* _class_loader_data;
 165 
 166   jint        _modifier_flags;  // Processed access flags, for use by Class.getModifiers.
 167   AccessFlags _access_flags;    // Access flags. The class/interface distinction is stored here.
 168 
 169   // Biased locking implementation and statistics
 170   // (the 64-bit chunk goes first, to avoid some fragmentation)
 171   jlong    _last_biased_lock_bulk_revocation_time;
 172   markOop  _prototype_header;   // Used when biased locking is both enabled and disabled for this type
 173   jint     _biased_lock_revocation_count;
 174 
 175   JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
 176 
 177   // Remembered sets support for the oops in the klasses.
 178   jbyte _modified_oops;             // Card Table Equivalent (YC/CMS support)
 179   jbyte _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
 180 
 181 private:
 182   // This is an index into FileMapHeader::_classpath_entry_table[], to
 183   // associate this class with the JAR file where it's loaded from during
 184   // dump time. If a class is not loaded from the shared archive, this field is
 185   // -1.
 186   jshort _shared_class_path_index;
 187 
 188   friend class SharedClassUtil;
 189 protected:
 190 
 191   // Constructor
 192   Klass();
 193 
 194   void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
 195 


 598   // biasable and have an epoch.
 599   markOop prototype_header() const      { return _prototype_header; }
 600   // NOTE: once instances of this klass are floating around in the
 601   // system, this header must only be updated at a safepoint.
 602   // NOTE 2: currently we only ever set the prototype header to the
 603   // biasable prototype for instanceKlasses. There is no technical
 604   // reason why it could not be done for arrayKlasses aside from
 605   // wanting to reduce the initial scope of this optimization. There
 606   // are potential problems in setting the bias pattern for
 607   // JVM-internal oops.
 608   inline void set_prototype_header(markOop header);
 609   static ByteSize prototype_header_offset() { return in_ByteSize(offset_of(Klass, _prototype_header)); }
 610 
 611   int  biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }
 612   // Atomically increments biased_lock_revocation_count and returns updated value
 613   int atomic_incr_biased_lock_revocation_count();
 614   void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
 615   jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
 616   void  set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
 617 
 618   JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
 619 
 620   // garbage collection support
 621   virtual void oops_do(OopClosure* cl);
 622 
 623   // Iff the class loader (or mirror for anonymous classes) is alive the
 624   // Klass is considered alive.
 625   // The is_alive closure passed in depends on the Garbage Collector used.
 626   bool is_loader_alive(BoolObjectClosure* is_alive);
 627 
 628   static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
 629   static void clean_subklass_tree(BoolObjectClosure* is_alive) {
 630     clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
 631   }
 632 
 633   // iterators
 634   virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0;
 635   virtual int oop_oop_iterate_v(oop obj, ExtendedOopClosure* blk) {
 636     return oop_oop_iterate(obj, blk);
 637   }
 638 


< prev index next >