src/hotspot/share/gc/cms/freeChunk.hpp
changeset 57777 90ead0febf56
parent 53244 9807daeb47c4
child 57811 947252a54b98
equal deleted inserted replaced
57774:21dccfac0ec5 57777:90ead0febf56
    54 // but are not part of the free list and should not be coalesced into larger
    54 // but are not part of the free list and should not be coalesced into larger
    55 // free blocks. These free blocks have their two LSB's set.
    55 // free blocks. These free blocks have their two LSB's set.
    56 
    56 
    57 class FreeChunk {
    57 class FreeChunk {
    58   friend class VMStructs;
    58   friend class VMStructs;
    59   // For 64 bit compressed oops, the markOop encodes both the size and the
    59   // For 64 bit compressed oops, the markWord encodes both the size and the
    60   // indication that this is a FreeChunk and not an object.
    60   // indication that this is a FreeChunk and not an object.
    61   volatile size_t   _size;
    61   volatile size_t   _size;
    62   FreeChunk* _prev;
    62   FreeChunk* _prev;
    63   FreeChunk* _next;
    63   FreeChunk* _next;
    64 
    64 
    65   markOop mark()     const volatile { return (markOop)_size; }
    65   markWord mark()     const volatile { return markWord((uintptr_t)_size); }
    66   void set_mark(markOop m)          { _size = (size_t)m; }
    66   void set_mark(markWord m)          { _size = (size_t)m.value(); }
    67 
    67 
    68  public:
    68  public:
    69   NOT_PRODUCT(static const size_t header_size();)
    69   NOT_PRODUCT(static const size_t header_size();)
    70 
    70 
    71   // Returns "true" if the address indicates that the block represents
    71   // Returns "true" if the address indicates that the block represents
    77     // compilation errors.
    77     // compilation errors.
    78     return ((volatile FreeChunk*)addr)->is_free();
    78     return ((volatile FreeChunk*)addr)->is_free();
    79   }
    79   }
    80 
    80 
    81   bool is_free() const volatile {
    81   bool is_free() const volatile {
    82     LP64_ONLY(if (UseCompressedOops) return mark()->is_cms_free_chunk(); else)
    82     LP64_ONLY(if (UseCompressedOops) return mark().is_cms_free_chunk(); else)
    83     return (((intptr_t)_prev) & 0x1) == 0x1;
    83     return (((intptr_t)_prev) & 0x1) == 0x1;
    84   }
    84   }
    85   bool cantCoalesce() const {
    85   bool cantCoalesce() const {
    86     assert(is_free(), "can't get coalesce bit on not free");
    86     assert(is_free(), "can't get coalesce bit on not free");
    87     return (((intptr_t)_prev) & 0x2) == 0x2;
    87     return (((intptr_t)_prev) & 0x2) == 0x2;
    98   debug_only(void* prev_addr() const { return (void*)&_prev; })
    98   debug_only(void* prev_addr() const { return (void*)&_prev; })
    99   debug_only(void* next_addr() const { return (void*)&_next; })
    99   debug_only(void* next_addr() const { return (void*)&_next; })
   100   debug_only(void* size_addr() const { return (void*)&_size; })
   100   debug_only(void* size_addr() const { return (void*)&_size; })
   101 
   101 
   102   size_t size() const volatile {
   102   size_t size() const volatile {
   103     LP64_ONLY(if (UseCompressedOops) return mark()->get_size(); else )
   103     LP64_ONLY(if (UseCompressedOops) return mark().get_size(); else )
   104     return _size;
   104     return _size;
   105   }
   105   }
   106   void set_size(size_t sz) {
   106   void set_size(size_t sz) {
   107     LP64_ONLY(if (UseCompressedOops) set_mark(markOopDesc::set_size_and_free(sz)); else )
   107     LP64_ONLY(if (UseCompressedOops) set_mark(markWord::set_size_and_free(sz)); else )
   108     _size = sz;
   108     _size = sz;
   109   }
   109   }
   110 
   110 
   111   FreeChunk* next()   const { return _next; }
   111   FreeChunk* next()   const { return _next; }
   112 
   112 
   124     // Set _prev (klass) to null before (if) clearing the mark word below
   124     // Set _prev (klass) to null before (if) clearing the mark word below
   125     _prev = NULL;
   125     _prev = NULL;
   126 #ifdef _LP64
   126 #ifdef _LP64
   127     if (UseCompressedOops) {
   127     if (UseCompressedOops) {
   128       OrderAccess::storestore();
   128       OrderAccess::storestore();
   129       set_mark(markOopDesc::prototype());
   129       set_mark(markWord::prototype());
   130     }
   130     }
   131 #endif
   131 #endif
   132     assert(!is_free(), "Error");
   132     assert(!is_free(), "Error");
   133   }
   133   }
   134 
   134