hotspot/src/share/vm/oops/klass.hpp
changeset 35913 928548a43408
parent 35544 c7ec868d0923
parent 35900 d64cf9290fc4
child 36384 b0b41336a9a8
equal deleted inserted replaced
35607:d73b0b6a24e6 35913:928548a43408
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    55 class klassVtable;
    55 class klassVtable;
    56 class ParCompactionManager;
    56 class ParCompactionManager;
    57 class PSPromotionManager;
    57 class PSPromotionManager;
    58 class KlassSizeStats;
    58 class KlassSizeStats;
    59 class fieldDescriptor;
    59 class fieldDescriptor;
       
    60 class vtableEntry;
    60 
    61 
    61 class Klass : public Metadata {
    62 class Klass : public Metadata {
    62   friend class VMStructs;
    63   friend class VMStructs;
    63   friend class JVMCIVMStructs;
    64   friend class JVMCIVMStructs;
    64  protected:
    65  protected:
   129   ClassLoaderData* _class_loader_data;
   130   ClassLoaderData* _class_loader_data;
   130 
   131 
   131   jint        _modifier_flags;  // Processed access flags, for use by Class.getModifiers.
   132   jint        _modifier_flags;  // Processed access flags, for use by Class.getModifiers.
   132   AccessFlags _access_flags;    // Access flags. The class/interface distinction is stored here.
   133   AccessFlags _access_flags;    // Access flags. The class/interface distinction is stored here.
   133 
   134 
       
   135   TRACE_DEFINE_KLASS_TRACE_ID;
       
   136 
   134   // Biased locking implementation and statistics
   137   // Biased locking implementation and statistics
   135   // (the 64-bit chunk goes first, to avoid some fragmentation)
   138   // (the 64-bit chunk goes first, to avoid some fragmentation)
   136   jlong    _last_biased_lock_bulk_revocation_time;
   139   jlong    _last_biased_lock_bulk_revocation_time;
   137   markOop  _prototype_header;   // Used when biased locking is both enabled and disabled for this type
   140   markOop  _prototype_header;   // Used when biased locking is both enabled and disabled for this type
   138   jint     _biased_lock_revocation_count;
   141   jint     _biased_lock_revocation_count;
   139 
   142 
   140   TRACE_DEFINE_KLASS_TRACE_ID;
   143   // vtable length
       
   144   int _vtable_len;
   141 
   145 
   142   // Remembered sets support for the oops in the klasses.
   146   // Remembered sets support for the oops in the klasses.
   143   jbyte _modified_oops;             // Card Table Equivalent (YC/CMS support)
   147   jbyte _modified_oops;             // Card Table Equivalent (YC/CMS support)
   144   jbyte _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
   148   jbyte _accumulated_modified_oops; // Mod Union Equivalent (CMS support)
   145 
   149 
   350       |    (hsize      << _lh_header_size_shift)
   354       |    (hsize      << _lh_header_size_shift)
   351       |    ((int)etype << _lh_element_type_shift)
   355       |    ((int)etype << _lh_element_type_shift)
   352       |    (log2_esize << _lh_log2_element_size_shift);
   356       |    (log2_esize << _lh_log2_element_size_shift);
   353   }
   357   }
   354   static jint instance_layout_helper(jint size, bool slow_path_flag) {
   358   static jint instance_layout_helper(jint size, bool slow_path_flag) {
   355     return (size << LogHeapWordSize)
   359     return (size << LogBytesPerWord)
   356       |    (slow_path_flag ? _lh_instance_slow_path_bit : 0);
   360       |    (slow_path_flag ? _lh_instance_slow_path_bit : 0);
   357   }
   361   }
   358   static int layout_helper_to_size_helper(jint lh) {
   362   static int layout_helper_to_size_helper(jint lh) {
   359     assert(lh > (jint)_lh_neutral_value, "must be instance");
   363     assert(lh > (jint)_lh_neutral_value, "must be instance");
   360     // Note that the following expression discards _lh_instance_slow_path_bit.
   364     // Note that the following expression discards _lh_instance_slow_path_bit.
   361     return lh >> LogHeapWordSize;
   365     return lh >> LogBytesPerWord;
   362   }
   366   }
   363   // Out-of-line version computes everything based on the etype:
   367   // Out-of-line version computes everything based on the etype:
   364   static jint array_layout_helper(BasicType etype);
   368   static jint array_layout_helper(BasicType etype);
   365 
   369 
   366   // What is the maximum number of primary superclasses any klass can have?
   370   // What is the maximum number of primary superclasses any klass can have?
   372     return FastSuperclassLimit;
   376     return FastSuperclassLimit;
   373   }
   377   }
   374 #endif
   378 #endif
   375 
   379 
   376   // vtables
   380   // vtables
   377   virtual klassVtable* vtable() const = 0;
   381   klassVtable* vtable() const;
   378   virtual int vtable_length() const = 0;
   382   int vtable_length() const { return _vtable_len; }
   379 
   383 
   380   // subclass check
   384   // subclass check
   381   bool is_subclass_of(const Klass* k) const;
   385   bool is_subclass_of(const Klass* k) const;
   382   // subtype check: true if is_subclass_of, or if k is interface and receiver implements it
   386   // subtype check: true if is_subclass_of, or if k is interface and receiver implements it
   383   bool is_subtype_of(Klass* k) const {
   387   bool is_subtype_of(Klass* k) const {
   436 
   440 
   437  protected:
   441  protected:
   438   virtual Klass* array_klass_impl(bool or_null, int rank, TRAPS);
   442   virtual Klass* array_klass_impl(bool or_null, int rank, TRAPS);
   439   virtual Klass* array_klass_impl(bool or_null, TRAPS);
   443   virtual Klass* array_klass_impl(bool or_null, TRAPS);
   440 
   444 
   441  public:
   445   void set_vtable_length(int len) { _vtable_len= len; }
       
   446 
       
   447   vtableEntry* start_of_vtable() const;
       
   448  public:
       
   449   Method* method_at_vtable(int index);
       
   450 
       
   451   static ByteSize vtable_start_offset();
       
   452   static ByteSize vtable_length_offset() {
       
   453     return byte_offset_of(Klass, _vtable_len);
       
   454   }
       
   455 
   442   // CDS support - remove and restore oops from metadata. Oops are not shared.
   456   // CDS support - remove and restore oops from metadata. Oops are not shared.
   443   virtual void remove_unshareable_info();
   457   virtual void remove_unshareable_info();
   444   virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
   458   virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
   445 
   459 
   446  protected:
   460  protected:
   577 #if INCLUDE_ALL_GCS
   591 #if INCLUDE_ALL_GCS
   578   // Parallel Scavenge
   592   // Parallel Scavenge
   579   virtual void oop_ps_push_contents(  oop obj, PSPromotionManager* pm)   = 0;
   593   virtual void oop_ps_push_contents(  oop obj, PSPromotionManager* pm)   = 0;
   580   // Parallel Compact
   594   // Parallel Compact
   581   virtual void oop_pc_follow_contents(oop obj, ParCompactionManager* cm) = 0;
   595   virtual void oop_pc_follow_contents(oop obj, ParCompactionManager* cm) = 0;
   582   virtual void oop_pc_update_pointers(oop obj) = 0;
   596   virtual void oop_pc_update_pointers(oop obj, ParCompactionManager* cm) = 0;
   583 #endif
   597 #endif
   584 
   598 
   585   // Iterators specialized to particular subtypes
   599   // Iterators specialized to particular subtypes
   586   // of ExtendedOopClosure, to avoid closure virtual calls.
   600   // of ExtendedOopClosure, to avoid closure virtual calls.
   587 #define Klass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)                                           \
   601 #define Klass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)                                           \