src/share/vm/oops/klass.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7118863 Sdiff src/share/vm/oops

src/share/vm/oops/klass.hpp

Print this page




 296   void set_super_check_offset(juint o) { _super_check_offset = o; }
 297 
 298   klassOop secondary_super_cache() const     { return _secondary_super_cache; }
 299   void set_secondary_super_cache(klassOop k) { oop_store_without_check((oop*) &_secondary_super_cache, (oop) k); }
 300 
 301   objArrayOop secondary_supers() const { return _secondary_supers; }
 302   void set_secondary_supers(objArrayOop k) { oop_store_without_check((oop*) &_secondary_supers, (oop) k); }
 303 
 304   // Return the element of the _super chain of the given depth.
 305   // If there is no such element, return either NULL or this.
 306   klassOop primary_super_of_depth(juint i) const {
 307     assert(i < primary_super_limit(), "oob");
 308     klassOop super = _primary_supers[i];
 309     assert(super == NULL || super->klass_part()->super_depth() == i, "correct display");
 310     return super;
 311   }
 312 
 313   // Can this klass be a primary super?  False for interfaces and arrays of
 314   // interfaces.  False also for arrays or classes with long super chains.
 315   bool can_be_primary_super() const {
 316     const juint secondary_offset = secondary_super_cache_offset_in_bytes() + sizeof(oopDesc);
 317     return super_check_offset() != secondary_offset;
 318   }
 319   virtual bool can_be_primary_super_slow() const;
 320 
 321   // Returns number of primary supers; may be a number in the inclusive range [0, primary_super_limit].
 322   juint super_depth() const {
 323     if (!can_be_primary_super()) {
 324       return primary_super_limit();
 325     } else {
 326       juint d = (super_check_offset() - (primary_supers_offset_in_bytes() + sizeof(oopDesc))) / sizeof(klassOop);
 327       assert(d < primary_super_limit(), "oob");
 328       assert(_primary_supers[d] == as_klassOop(), "proper init");
 329       return d;
 330     }
 331   }
 332 
 333   // java mirror
 334   oop java_mirror() const              { return _java_mirror; }
 335   void set_java_mirror(oop m)          { oop_store((oop*) &_java_mirror, m); }
 336 
 337   // modifier flags
 338   jint modifier_flags() const          { return _modifier_flags; }
 339   void set_modifier_flags(jint flags)  { _modifier_flags = flags; }
 340 
 341   // size helper
 342   int layout_helper() const            { return _layout_helper; }
 343   void set_layout_helper(int lh)       { _layout_helper = lh; }
 344 
 345   // Note: for instances layout_helper() may include padding.
 346   // Use instanceKlass::contains_field_offset to classify field offsets.


 356   klassOop next_sibling_oop() const        { return _next_sibling; }
 357   void     set_subklass(klassOop s);
 358   void     set_next_sibling(klassOop s);
 359 
 360   oop* adr_super()           const { return (oop*)&_super;             }
 361   oop* adr_primary_supers()  const { return (oop*)&_primary_supers[0]; }
 362   oop* adr_secondary_super_cache() const { return (oop*)&_secondary_super_cache; }
 363   oop* adr_secondary_supers()const { return (oop*)&_secondary_supers;  }
 364   oop* adr_java_mirror()     const { return (oop*)&_java_mirror;       }
 365   oop* adr_subklass()        const { return (oop*)&_subklass;          }
 366   oop* adr_next_sibling()    const { return (oop*)&_next_sibling;      }
 367 
 368  public:
 369   // Allocation profiling support
 370   juint alloc_count() const          { return _alloc_count; }
 371   void set_alloc_count(juint n)      { _alloc_count = n; }
 372   virtual juint alloc_size() const = 0;
 373   virtual void set_alloc_size(juint n) = 0;
 374 
 375   // Compiler support
 376   static int super_offset_in_bytes()         { return offset_of(Klass, _super); }
 377   static int super_check_offset_offset_in_bytes() { return offset_of(Klass, _super_check_offset); }
 378   static int primary_supers_offset_in_bytes(){ return offset_of(Klass, _primary_supers); }
 379   static int secondary_super_cache_offset_in_bytes() { return offset_of(Klass, _secondary_super_cache); }
 380   static int secondary_supers_offset_in_bytes() { return offset_of(Klass, _secondary_supers); }
 381   static int java_mirror_offset_in_bytes()   { return offset_of(Klass, _java_mirror); }
 382   static int modifier_flags_offset_in_bytes(){ return offset_of(Klass, _modifier_flags); }
 383   static int layout_helper_offset_in_bytes() { return offset_of(Klass, _layout_helper); }
 384   static int access_flags_offset_in_bytes()  { return offset_of(Klass, _access_flags); }
 385 
 386   // Unpacking layout_helper:
 387   enum {
 388     _lh_neutral_value           = 0,  // neutral non-array non-instance value
 389     _lh_instance_slow_path_bit  = 0x01,
 390     _lh_log2_element_size_shift = BitsPerByte*0,
 391     _lh_log2_element_size_mask  = BitsPerLong-1,
 392     _lh_element_type_shift      = BitsPerByte*1,
 393     _lh_element_type_mask       = right_n_bits(BitsPerByte),  // shifted mask
 394     _lh_header_size_shift       = BitsPerByte*2,
 395     _lh_header_size_mask        = right_n_bits(BitsPerByte),  // shifted mask
 396     _lh_array_tag_bits          = 2,
 397     _lh_array_tag_shift         = BitsPerInt - _lh_array_tag_bits,
 398     _lh_array_tag_type_value    = ~0x00,  // 0xC0000000 >> 30
 399     _lh_array_tag_obj_value     = ~0x01   // 0x80000000 >> 30
 400   };
 401 
 402   static int layout_helper_size_in_bytes(jint lh) {
 403     assert(lh > (jint)_lh_neutral_value, "must be instance");
 404     return (int) lh & ~_lh_instance_slow_path_bit;


 461 #ifdef PRODUCT
 462   static juint primary_super_limit()         { return _primary_super_limit; }
 463 #else
 464   static juint primary_super_limit() {
 465     assert(FastSuperclassLimit <= _primary_super_limit, "parameter oob");
 466     return FastSuperclassLimit;
 467   }
 468 #endif
 469 
 470   // vtables
 471   virtual klassVtable* vtable() const        { return NULL; }
 472 
 473   static int klass_size_in_bytes()           { return offset_of(Klass, _alloc_count) + sizeof(juint); }  // all "visible" fields
 474 
 475   // subclass check
 476   bool is_subclass_of(klassOop k) const;
 477   // subtype check: true if is_subclass_of, or if k is interface and receiver implements it
 478   bool is_subtype_of(klassOop k) const {
 479     juint    off = k->klass_part()->super_check_offset();
 480     klassOop sup = *(klassOop*)( (address)as_klassOop() + off );
 481     const juint secondary_offset = secondary_super_cache_offset_in_bytes() + sizeof(oopDesc);
 482     if (sup == k) {
 483       return true;
 484     } else if (off != secondary_offset) {
 485       return false;
 486     } else {
 487       return search_secondary_supers(k);
 488     }
 489   }
 490   bool search_secondary_supers(klassOop k) const;
 491 
 492   // Find LCA in class hierarchy
 493   Klass *LCA( Klass *k );
 494 
 495   // Check whether reflection/jni/jvm code is allowed to instantiate this class;
 496   // if not, throw either an Error or an Exception.
 497   virtual void check_valid_for_instantiation(bool throwError, TRAPS);
 498 
 499   // Casting
 500   static Klass* cast(klassOop k) {
 501     assert(k->is_klass(), "cast to Klass");


 657   void set_is_cloneable()               { _access_flags.set_is_cloneable(); }
 658   bool has_vanilla_constructor() const  { return _access_flags.has_vanilla_constructor(); }
 659   void set_has_vanilla_constructor()    { _access_flags.set_has_vanilla_constructor(); }
 660   bool has_miranda_methods () const     { return access_flags().has_miranda_methods(); }
 661   void set_has_miranda_methods()        { _access_flags.set_has_miranda_methods(); }
 662 
 663   // Biased locking support
 664   // Note: the prototype header is always set up to be at least the
 665   // prototype markOop. If biased locking is enabled it may further be
 666   // biasable and have an epoch.
 667   markOop prototype_header() const      { return _prototype_header; }
 668   // NOTE: once instances of this klass are floating around in the
 669   // system, this header must only be updated at a safepoint.
 670   // NOTE 2: currently we only ever set the prototype header to the
 671   // biasable prototype for instanceKlasses. There is no technical
 672   // reason why it could not be done for arrayKlasses aside from
 673   // wanting to reduce the initial scope of this optimization. There
 674   // are potential problems in setting the bias pattern for
 675   // JVM-internal oops.
 676   inline void set_prototype_header(markOop header);
 677   static int prototype_header_offset_in_bytes() { return offset_of(Klass, _prototype_header); }
 678 
 679   int  biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }
 680   // Atomically increments biased_lock_revocation_count and returns updated value
 681   int atomic_incr_biased_lock_revocation_count();
 682   void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
 683   jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
 684   void  set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
 685 
 686 
 687   // garbage collection support
 688   virtual void follow_weak_klass_links(
 689     BoolObjectClosure* is_alive, OopClosure* keep_alive);
 690 
 691   // Prefetch within oop iterators.  This is a macro because we
 692   // can't guarantee that the compiler will inline it.  In 64-bit
 693   // it generally doesn't.  Signature is
 694   //
 695   // static void prefetch_beyond(oop* const start,
 696   //                             oop* const end,
 697   //                             const intx foffset,




 296   void set_super_check_offset(juint o) { _super_check_offset = o; }
 297 
 298   klassOop secondary_super_cache() const     { return _secondary_super_cache; }
 299   void set_secondary_super_cache(klassOop k) { oop_store_without_check((oop*) &_secondary_super_cache, (oop) k); }
 300 
 301   objArrayOop secondary_supers() const { return _secondary_supers; }
 302   void set_secondary_supers(objArrayOop k) { oop_store_without_check((oop*) &_secondary_supers, (oop) k); }
 303 
 304   // Return the element of the _super chain of the given depth.
 305   // If there is no such element, return either NULL or this.
 306   klassOop primary_super_of_depth(juint i) const {
 307     assert(i < primary_super_limit(), "oob");
 308     klassOop super = _primary_supers[i];
 309     assert(super == NULL || super->klass_part()->super_depth() == i, "correct display");
 310     return super;
 311   }
 312 
 313   // Can this klass be a primary super?  False for interfaces and arrays of
 314   // interfaces.  False also for arrays or classes with long super chains.
 315   bool can_be_primary_super() const {
 316     const juint secondary_offset = in_bytes(secondary_super_cache_offset());
 317     return super_check_offset() != secondary_offset;
 318   }
 319   virtual bool can_be_primary_super_slow() const;
 320 
 321   // Returns number of primary supers; may be a number in the inclusive range [0, primary_super_limit].
 322   juint super_depth() const {
 323     if (!can_be_primary_super()) {
 324       return primary_super_limit();
 325     } else {
 326       juint d = (super_check_offset() - in_bytes(primary_supers_offset())) / sizeof(klassOop);
 327       assert(d < primary_super_limit(), "oob");
 328       assert(_primary_supers[d] == as_klassOop(), "proper init");
 329       return d;
 330     }
 331   }
 332 
 333   // java mirror
 334   oop java_mirror() const              { return _java_mirror; }
 335   void set_java_mirror(oop m)          { oop_store((oop*) &_java_mirror, m); }
 336 
 337   // modifier flags
 338   jint modifier_flags() const          { return _modifier_flags; }
 339   void set_modifier_flags(jint flags)  { _modifier_flags = flags; }
 340 
 341   // size helper
 342   int layout_helper() const            { return _layout_helper; }
 343   void set_layout_helper(int lh)       { _layout_helper = lh; }
 344 
 345   // Note: for instances layout_helper() may include padding.
 346   // Use instanceKlass::contains_field_offset to classify field offsets.


 356   klassOop next_sibling_oop() const        { return _next_sibling; }
 357   void     set_subklass(klassOop s);
 358   void     set_next_sibling(klassOop s);
 359 
 360   oop* adr_super()           const { return (oop*)&_super;             }
 361   oop* adr_primary_supers()  const { return (oop*)&_primary_supers[0]; }
 362   oop* adr_secondary_super_cache() const { return (oop*)&_secondary_super_cache; }
 363   oop* adr_secondary_supers()const { return (oop*)&_secondary_supers;  }
 364   oop* adr_java_mirror()     const { return (oop*)&_java_mirror;       }
 365   oop* adr_subklass()        const { return (oop*)&_subklass;          }
 366   oop* adr_next_sibling()    const { return (oop*)&_next_sibling;      }
 367 
 368  public:
 369   // Allocation profiling support
 370   juint alloc_count() const          { return _alloc_count; }
 371   void set_alloc_count(juint n)      { _alloc_count = n; }
 372   virtual juint alloc_size() const = 0;
 373   virtual void set_alloc_size(juint n) = 0;
 374 
 375   // Compiler support
 376   static ByteSize super_offset()                 { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _super)); }
 377   static ByteSize super_check_offset_offset()    { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _super_check_offset)); }
 378   static ByteSize primary_supers_offset()        { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _primary_supers)); }
 379   static ByteSize secondary_super_cache_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _secondary_super_cache)); }
 380   static ByteSize secondary_supers_offset()      { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _secondary_supers)); }
 381   static ByteSize java_mirror_offset()           { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _java_mirror)); }
 382   static ByteSize modifier_flags_offset()        { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _modifier_flags)); }
 383   static ByteSize layout_helper_offset()         { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _layout_helper)); }
 384   static ByteSize access_flags_offset()          { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _access_flags)); }
 385 
 386   // Unpacking layout_helper:
 387   enum {
 388     _lh_neutral_value           = 0,  // neutral non-array non-instance value
 389     _lh_instance_slow_path_bit  = 0x01,
 390     _lh_log2_element_size_shift = BitsPerByte*0,
 391     _lh_log2_element_size_mask  = BitsPerLong-1,
 392     _lh_element_type_shift      = BitsPerByte*1,
 393     _lh_element_type_mask       = right_n_bits(BitsPerByte),  // shifted mask
 394     _lh_header_size_shift       = BitsPerByte*2,
 395     _lh_header_size_mask        = right_n_bits(BitsPerByte),  // shifted mask
 396     _lh_array_tag_bits          = 2,
 397     _lh_array_tag_shift         = BitsPerInt - _lh_array_tag_bits,
 398     _lh_array_tag_type_value    = ~0x00,  // 0xC0000000 >> 30
 399     _lh_array_tag_obj_value     = ~0x01   // 0x80000000 >> 30
 400   };
 401 
 402   static int layout_helper_size_in_bytes(jint lh) {
 403     assert(lh > (jint)_lh_neutral_value, "must be instance");
 404     return (int) lh & ~_lh_instance_slow_path_bit;


 461 #ifdef PRODUCT
 462   static juint primary_super_limit()         { return _primary_super_limit; }
 463 #else
 464   static juint primary_super_limit() {
 465     assert(FastSuperclassLimit <= _primary_super_limit, "parameter oob");
 466     return FastSuperclassLimit;
 467   }
 468 #endif
 469 
 470   // vtables
 471   virtual klassVtable* vtable() const        { return NULL; }
 472 
 473   static int klass_size_in_bytes()           { return offset_of(Klass, _alloc_count) + sizeof(juint); }  // all "visible" fields
 474 
 475   // subclass check
 476   bool is_subclass_of(klassOop k) const;
 477   // subtype check: true if is_subclass_of, or if k is interface and receiver implements it
 478   bool is_subtype_of(klassOop k) const {
 479     juint    off = k->klass_part()->super_check_offset();
 480     klassOop sup = *(klassOop*)( (address)as_klassOop() + off );
 481     const juint secondary_offset = in_bytes(secondary_super_cache_offset());
 482     if (sup == k) {
 483       return true;
 484     } else if (off != secondary_offset) {
 485       return false;
 486     } else {
 487       return search_secondary_supers(k);
 488     }
 489   }
 490   bool search_secondary_supers(klassOop k) const;
 491 
 492   // Find LCA in class hierarchy
 493   Klass *LCA( Klass *k );
 494 
 495   // Check whether reflection/jni/jvm code is allowed to instantiate this class;
 496   // if not, throw either an Error or an Exception.
 497   virtual void check_valid_for_instantiation(bool throwError, TRAPS);
 498 
 499   // Casting
 500   static Klass* cast(klassOop k) {
 501     assert(k->is_klass(), "cast to Klass");


 657   void set_is_cloneable()               { _access_flags.set_is_cloneable(); }
 658   bool has_vanilla_constructor() const  { return _access_flags.has_vanilla_constructor(); }
 659   void set_has_vanilla_constructor()    { _access_flags.set_has_vanilla_constructor(); }
 660   bool has_miranda_methods () const     { return access_flags().has_miranda_methods(); }
 661   void set_has_miranda_methods()        { _access_flags.set_has_miranda_methods(); }
 662 
 663   // Biased locking support
 664   // Note: the prototype header is always set up to be at least the
 665   // prototype markOop. If biased locking is enabled it may further be
 666   // biasable and have an epoch.
 667   markOop prototype_header() const      { return _prototype_header; }
 668   // NOTE: once instances of this klass are floating around in the
 669   // system, this header must only be updated at a safepoint.
 670   // NOTE 2: currently we only ever set the prototype header to the
 671   // biasable prototype for instanceKlasses. There is no technical
 672   // reason why it could not be done for arrayKlasses aside from
 673   // wanting to reduce the initial scope of this optimization. There
 674   // are potential problems in setting the bias pattern for
 675   // JVM-internal oops.
 676   inline void set_prototype_header(markOop header);
 677   static ByteSize prototype_header_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(Klass, _prototype_header)); }
 678 
 679   int  biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }
 680   // Atomically increments biased_lock_revocation_count and returns updated value
 681   int atomic_incr_biased_lock_revocation_count();
 682   void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }
 683   jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
 684   void  set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
 685 
 686 
 687   // garbage collection support
 688   virtual void follow_weak_klass_links(
 689     BoolObjectClosure* is_alive, OopClosure* keep_alive);
 690 
 691   // Prefetch within oop iterators.  This is a macro because we
 692   // can't guarantee that the compiler will inline it.  In 64-bit
 693   // it generally doesn't.  Signature is
 694   //
 695   // static void prefetch_beyond(oop* const start,
 696   //                             oop* const end,
 697   //                             const intx foffset,


src/share/vm/oops/klass.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File