src/hotspot/share/gc/z/zForwarding.inline.hpp
changeset 54163 790679f86a51
parent 54162 f344a0c6e19e
child 54172 f92f1f1045ad
equal deleted inserted replaced
54162:f344a0c6e19e 54163:790679f86a51
    25 #define SHARE_GC_Z_ZFORWARDING_INLINE_HPP
    25 #define SHARE_GC_Z_ZFORWARDING_INLINE_HPP
    26 
    26 
    27 #include "gc/z/zForwarding.hpp"
    27 #include "gc/z/zForwarding.hpp"
    28 #include "gc/z/zGlobals.hpp"
    28 #include "gc/z/zGlobals.hpp"
    29 #include "gc/z/zHash.inline.hpp"
    29 #include "gc/z/zHash.inline.hpp"
       
    30 #include "gc/z/zHeap.hpp"
       
    31 #include "gc/z/zVirtualMemory.inline.hpp"
    30 #include "runtime/atomic.hpp"
    32 #include "runtime/atomic.hpp"
    31 #include "utilities/debug.hpp"
    33 #include "utilities/debug.hpp"
    32 
    34 
    33 inline uintptr_t ZForwarding::start() const {
    35 inline uintptr_t ZForwarding::start() const {
    34   return _start;
    36   return _virtual.start();
       
    37 }
       
    38 
       
    39 inline size_t ZForwarding::size() const {
       
    40   return _virtual.size();
    35 }
    41 }
    36 
    42 
    37 inline size_t ZForwarding::object_alignment_shift() const {
    43 inline size_t ZForwarding::object_alignment_shift() const {
    38   return _object_alignment_shift;
    44   return _object_alignment_shift;
       
    45 }
       
    46 
       
    47 inline ZPage* ZForwarding::page() const {
       
    48   return _page;
       
    49 }
       
    50 
       
    51 inline bool ZForwarding::is_pinned() const {
       
    52   return Atomic::load(&_pinned);
       
    53 }
       
    54 
       
    55 inline void ZForwarding::set_pinned() {
       
    56   Atomic::store(true, &_pinned);
    39 }
    57 }
    40 
    58 
    41 inline bool ZForwarding::inc_refcount() {
    59 inline bool ZForwarding::inc_refcount() {
    42   uint32_t refcount = Atomic::load(&_refcount);
    60   uint32_t refcount = Atomic::load(&_refcount);
    43 
    61 
    58 inline bool ZForwarding::dec_refcount() {
    76 inline bool ZForwarding::dec_refcount() {
    59   assert(_refcount > 0, "Invalid state");
    77   assert(_refcount > 0, "Invalid state");
    60   return Atomic::sub(1u, &_refcount) == 0u;
    78   return Atomic::sub(1u, &_refcount) == 0u;
    61 }
    79 }
    62 
    80 
    63 inline bool ZForwarding::is_pinned() const {
    81 inline bool ZForwarding::retain_page() {
    64   return Atomic::load(&_pinned);
    82   return inc_refcount();
    65 }
    83 }
    66 
    84 
    67 inline void ZForwarding::set_pinned() {
    85 inline void ZForwarding::release_page() {
    68   Atomic::store(true, &_pinned);
    86   if (dec_refcount()) {
       
    87     ZHeap::heap()->free_page(_page, true /* reclaimed */);
       
    88     _page = NULL;
       
    89   }
    69 }
    90 }
    70 
    91 
    71 inline ZForwardingEntry* ZForwarding::entries() const {
    92 inline ZForwardingEntry* ZForwarding::entries() const {
    72   return reinterpret_cast<ZForwardingEntry*>(reinterpret_cast<uintptr_t>(this) + sizeof(*this));
    93   return reinterpret_cast<ZForwardingEntry*>(reinterpret_cast<uintptr_t>(this) + sizeof(*this));
    73 }
    94 }