hotspot/src/share/vm/oops/oop.inline.hpp
changeset 593 803947e176bd
parent 382 02c0a63f30d6
child 670 ddf3e9583f2f
child 1376 f7fc7a708b63
equal deleted inserted replaced
592:dbf1a1c172d6 593:803947e176bd
    34 }
    34 }
    35 
    35 
    36 inline klassOop oopDesc::klass() const {
    36 inline klassOop oopDesc::klass() const {
    37   if (UseCompressedOops) {
    37   if (UseCompressedOops) {
    38     return (klassOop)decode_heap_oop_not_null(_metadata._compressed_klass);
    38     return (klassOop)decode_heap_oop_not_null(_metadata._compressed_klass);
    39       // can be NULL in CMS, but isn't supported on CMS yet.
    39   } else {
       
    40     return _metadata._klass;
       
    41   }
       
    42 }
       
    43 
       
    44 inline klassOop oopDesc::klass_or_null() const volatile {
       
    45   // can be NULL in CMS
       
    46   if (UseCompressedOops) {
       
    47     return (klassOop)decode_heap_oop(_metadata._compressed_klass);
    40   } else {
    48   } else {
    41     return _metadata._klass;
    49     return _metadata._klass;
    42   }
    50   }
    43 }
    51 }
    44 
    52 
    62 inline void oopDesc::set_klass(klassOop k) {
    70 inline void oopDesc::set_klass(klassOop k) {
    63   // since klasses are promoted no store check is needed
    71   // since klasses are promoted no store check is needed
    64   assert(Universe::is_bootstrapping() || k != NULL, "must be a real klassOop");
    72   assert(Universe::is_bootstrapping() || k != NULL, "must be a real klassOop");
    65   assert(Universe::is_bootstrapping() || k->is_klass(), "not a klassOop");
    73   assert(Universe::is_bootstrapping() || k->is_klass(), "not a klassOop");
    66   if (UseCompressedOops) {
    74   if (UseCompressedOops) {
    67     // zero the gap when the klass is set, by zeroing the pointer sized
       
    68     // part of the union.
       
    69     _metadata._klass = NULL;
       
    70     oop_store_without_check(compressed_klass_addr(), (oop)k);
    75     oop_store_without_check(compressed_klass_addr(), (oop)k);
    71   } else {
    76   } else {
    72     oop_store_without_check(klass_addr(), (oop) k);
    77     oop_store_without_check(klass_addr(), (oop) k);
       
    78   }
       
    79 }
       
    80 
       
    81 inline int oopDesc::klass_gap() const {
       
    82   return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes());
       
    83 }
       
    84 
       
    85 inline void oopDesc::set_klass_gap(int v) {
       
    86   if (UseCompressedOops) {
       
    87     *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes()) = v;
    73   }
    88   }
    74 }
    89 }
    75 
    90 
    76 inline void oopDesc::set_klass_to_list_ptr(oop k) {
    91 inline void oopDesc::set_klass_to_list_ptr(oop k) {
    77   // This is only to be used during GC, for from-space objects, so no
    92   // This is only to be used during GC, for from-space objects, so no
   503   if (!Universe::heap()->is_in_reserved(obj)) return false;
   518   if (!Universe::heap()->is_in_reserved(obj)) return false;
   504   // obj is aligned and accessible in heap
   519   // obj is aligned and accessible in heap
   505   // try to find metaclass cycle safely without seg faulting on bad input
   520   // try to find metaclass cycle safely without seg faulting on bad input
   506   // we should reach klassKlassObj by following klass link at most 3 times
   521   // we should reach klassKlassObj by following klass link at most 3 times
   507   for (int i = 0; i < 3; i++) {
   522   for (int i = 0; i < 3; i++) {
   508     obj = obj->klass();
   523     obj = obj->klass_or_null();
   509     // klass should be aligned and in permspace
   524     // klass should be aligned and in permspace
   510     if (!check_obj_alignment(obj)) return false;
   525     if (!check_obj_alignment(obj)) return false;
   511     if (!Universe::heap()->is_in_permanent(obj)) return false;
   526     if (!Universe::heap()->is_in_permanent(obj)) return false;
   512   }
   527   }
   513   if (obj != Universe::klassKlassObj()) {
   528   if (obj != Universe::klassKlassObj()) {