src/hotspot/share/gc/z/zGranuleMap.inline.hpp
changeset 58810 3aba4a42d8ad
parent 58809 44dc3d796110
equal deleted inserted replaced
58809:44dc3d796110 58810:3aba4a42d8ad
    22  */
    22  */
    23 
    23 
    24 #ifndef SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
    24 #ifndef SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
    25 #define SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
    25 #define SHARE_GC_Z_ZGRANULEMAP_INLINE_HPP
    26 
    26 
    27 #include "gc/z/zAddress.inline.hpp"
       
    28 #include "gc/z/zGlobals.hpp"
    27 #include "gc/z/zGlobals.hpp"
    29 #include "gc/z/zGranuleMap.hpp"
    28 #include "gc/z/zGranuleMap.hpp"
    30 #include "memory/allocation.inline.hpp"
    29 #include "memory/allocation.inline.hpp"
    31 #include "utilities/align.hpp"
    30 #include "utilities/align.hpp"
    32 #include "utilities/debug.hpp"
    31 #include "utilities/debug.hpp"
    42 inline ZGranuleMap<T>::~ZGranuleMap() {
    41 inline ZGranuleMap<T>::~ZGranuleMap() {
    43   MmapArrayAllocator<T>::free(_map, _size);
    42   MmapArrayAllocator<T>::free(_map, _size);
    44 }
    43 }
    45 
    44 
    46 template <typename T>
    45 template <typename T>
    47 inline size_t ZGranuleMap<T>::index_for_addr(uintptr_t addr) const {
    46 inline size_t ZGranuleMap<T>::index_for_offset(uintptr_t offset) const {
    48   assert(!ZAddress::is_null(addr), "Invalid address");
    47   const size_t index = offset >> ZGranuleSizeShift;
    49 
       
    50   const size_t index = ZAddress::offset(addr) >> ZGranuleSizeShift;
       
    51   assert(index < _size, "Invalid index");
    48   assert(index < _size, "Invalid index");
    52 
    49 
    53   return index;
    50   return index;
    54 }
    51 }
    55 
    52 
    56 template <typename T>
    53 template <typename T>
    57 inline T ZGranuleMap<T>::get(uintptr_t addr) const {
    54 inline T ZGranuleMap<T>::get(uintptr_t offset) const {
    58   const size_t index = index_for_addr(addr);
    55   const size_t index = index_for_offset(offset);
    59   return _map[index];
    56   return _map[index];
    60 }
    57 }
    61 
    58 
    62 template <typename T>
    59 template <typename T>
    63 inline void ZGranuleMap<T>::put(uintptr_t addr, T value) {
    60 inline void ZGranuleMap<T>::put(uintptr_t offset, T value) {
    64   const size_t index = index_for_addr(addr);
    61   const size_t index = index_for_offset(offset);
    65   _map[index] = value;
    62   _map[index] = value;
    66 }
    63 }
    67 
    64 
    68 template <typename T>
    65 template <typename T>
    69 inline void ZGranuleMap<T>::put(uintptr_t addr, size_t size, T value) {
    66 inline void ZGranuleMap<T>::put(uintptr_t offset, size_t size, T value) {
    70   assert(is_aligned(size, ZGranuleSize), "Misaligned");
    67   assert(is_aligned(size, ZGranuleSize), "Misaligned");
    71 
    68 
    72   const size_t start_index = index_for_addr(addr);
    69   const size_t start_index = index_for_offset(offset);
    73   const size_t end_index = start_index + (size >> ZGranuleSizeShift);
    70   const size_t end_index = start_index + (size >> ZGranuleSizeShift);
    74   for (size_t index = start_index; index < end_index; index++) {
    71   for (size_t index = start_index; index < end_index; index++) {
    75     _map[index] = value;
    72     _map[index] = value;
    76   }
    73   }
    77 }
    74 }