< prev index next >

src/hotspot/os/windows/gc/z/zPhysicalMemoryBacking_windows.cpp

Print this page




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/z/zGlobals.hpp"
  26 #include "gc/z/zGranuleMap.inline.hpp"
  27 #include "gc/z/zMapper_windows.hpp"
  28 #include "gc/z/zPhysicalMemoryBacking_windows.hpp"
  29 #include "logging/log.hpp"
  30 #include "runtime/globals.hpp"
  31 #include "utilities/debug.hpp"
  32 
  33 // The backing commits and uncommits physical memory, that can be
  34 // multi-mapped into the virtual address space. To support fine-graned
  35 // committing and uncommitting, each ZGranuleSize'd chunk is mapped to
  36 // a separate paging file mapping.
  37 
  38 ZPhysicalMemoryBacking::ZPhysicalMemoryBacking() :
  39     _handles(MaxHeapSize),
  40     _size(0) {}
  41 
  42 bool ZPhysicalMemoryBacking::is_initialized() const {
  43   return true;
  44 }
  45 
  46 void ZPhysicalMemoryBacking::warn_commit_limits(size_t max) const {
  47   // Does nothing
  48 }
  49 
  50 size_t ZPhysicalMemoryBacking::size() const {
  51   return _size;
  52 }
  53 
  54 HANDLE ZPhysicalMemoryBacking::get_handle(uintptr_t offset) const {
  55   HANDLE const handle = _handles.get(offset);
  56   assert(handle != 0, "Should be set");
  57   return handle;
  58 }
  59 
  60 void ZPhysicalMemoryBacking::put_handle(uintptr_t offset, HANDLE handle) {
  61   assert(handle != INVALID_HANDLE_VALUE, "Invalid handle");
  62   assert(_handles.get(offset) == 0, "Should be cleared");
  63   _handles.put(offset, handle);
  64 }
  65 
  66 void ZPhysicalMemoryBacking::clear_handle(uintptr_t offset) {
  67   assert(_handles.get(offset) != 0, "Should be set");
  68   _handles.put(offset, 0);
  69 }
  70 
  71 size_t ZPhysicalMemoryBacking::commit_from_paging_file(size_t offset, size_t size) {
  72   for (size_t i = 0; i < size; i += ZGranuleSize) {
  73     HANDLE const handle = ZMapper::create_and_commit_paging_file_mapping(ZGranuleSize);


  78     put_handle(offset + i, handle);
  79   }
  80 
  81   return size;
  82 }
  83 
  84 size_t ZPhysicalMemoryBacking::uncommit_from_paging_file(size_t offset, size_t size) {
  85   for (size_t i = 0; i < size; i += ZGranuleSize) {
  86     HANDLE const handle = get_handle(offset + i);
  87     clear_handle(offset + i);
  88     ZMapper::close_paging_file_mapping(handle);
  89   }
  90 
  91   return size;
  92 }
  93 
  94 size_t ZPhysicalMemoryBacking::commit(size_t offset, size_t length) {
  95   log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
  96                       offset / M, (offset + length) / M, length / M);
  97 
  98   const size_t committed = commit_from_paging_file(offset, length);
  99 
 100   const size_t end = offset + committed;
 101   if (end > _size) {
 102     // Update size
 103     _size = end;
 104   }
 105 
 106   return committed;
 107 }
 108 
 109 size_t ZPhysicalMemoryBacking::uncommit(size_t offset, size_t length) {
 110   log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
 111                       offset / M, (offset + length) / M, length / M);
 112 
 113   return uncommit_from_paging_file(offset, length);
 114 }
 115 
 116 void ZPhysicalMemoryBacking::map(uintptr_t addr, size_t size, size_t offset) const {
 117   assert(is_aligned(offset, ZGranuleSize), "Misaligned");
 118   assert(is_aligned(addr, ZGranuleSize), "Misaligned");
 119   assert(is_aligned(size, ZGranuleSize), "Misaligned");
 120 
 121   for (size_t i = 0; i < size; i += ZGranuleSize) {
 122     HANDLE const handle = get_handle(offset + i);
 123     ZMapper::map_view_replace_placeholder(handle, 0 /* offset */, addr + i, ZGranuleSize);
 124   }
 125 }
 126 


  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/z/zGlobals.hpp"
  26 #include "gc/z/zGranuleMap.inline.hpp"
  27 #include "gc/z/zMapper_windows.hpp"
  28 #include "gc/z/zPhysicalMemoryBacking_windows.hpp"
  29 #include "logging/log.hpp"
  30 #include "runtime/globals.hpp"
  31 #include "utilities/debug.hpp"
  32 
  33 // The backing commits and uncommits physical memory, that can be
  34 // multi-mapped into the virtual address space. To support fine-graned
  35 // committing and uncommitting, each ZGranuleSize'd chunk is mapped to
  36 // a separate paging file mapping.
  37 
  38 ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity) :
  39     _handles(max_capacity) {}

  40 
  41 bool ZPhysicalMemoryBacking::is_initialized() const {
  42   return true;
  43 }
  44 
  45 void ZPhysicalMemoryBacking::warn_commit_limits(size_t max) const {
  46   // Does nothing
  47 }
  48 




  49 HANDLE ZPhysicalMemoryBacking::get_handle(uintptr_t offset) const {
  50   HANDLE const handle = _handles.get(offset);
  51   assert(handle != 0, "Should be set");
  52   return handle;
  53 }
  54 
  55 void ZPhysicalMemoryBacking::put_handle(uintptr_t offset, HANDLE handle) {
  56   assert(handle != INVALID_HANDLE_VALUE, "Invalid handle");
  57   assert(_handles.get(offset) == 0, "Should be cleared");
  58   _handles.put(offset, handle);
  59 }
  60 
  61 void ZPhysicalMemoryBacking::clear_handle(uintptr_t offset) {
  62   assert(_handles.get(offset) != 0, "Should be set");
  63   _handles.put(offset, 0);
  64 }
  65 
  66 size_t ZPhysicalMemoryBacking::commit_from_paging_file(size_t offset, size_t size) {
  67   for (size_t i = 0; i < size; i += ZGranuleSize) {
  68     HANDLE const handle = ZMapper::create_and_commit_paging_file_mapping(ZGranuleSize);


  73     put_handle(offset + i, handle);
  74   }
  75 
  76   return size;
  77 }
  78 
  79 size_t ZPhysicalMemoryBacking::uncommit_from_paging_file(size_t offset, size_t size) {
  80   for (size_t i = 0; i < size; i += ZGranuleSize) {
  81     HANDLE const handle = get_handle(offset + i);
  82     clear_handle(offset + i);
  83     ZMapper::close_paging_file_mapping(handle);
  84   }
  85 
  86   return size;
  87 }
  88 
  89 size_t ZPhysicalMemoryBacking::commit(size_t offset, size_t length) {
  90   log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
  91                       offset / M, (offset + length) / M, length / M);
  92 
  93   return commit_from_paging_file(offset, length);








  94 }
  95 
  96 size_t ZPhysicalMemoryBacking::uncommit(size_t offset, size_t length) {
  97   log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
  98                       offset / M, (offset + length) / M, length / M);
  99 
 100   return uncommit_from_paging_file(offset, length);
 101 }
 102 
 103 void ZPhysicalMemoryBacking::map(uintptr_t addr, size_t size, size_t offset) const {
 104   assert(is_aligned(offset, ZGranuleSize), "Misaligned");
 105   assert(is_aligned(addr, ZGranuleSize), "Misaligned");
 106   assert(is_aligned(size, ZGranuleSize), "Misaligned");
 107 
 108   for (size_t i = 0; i < size; i += ZGranuleSize) {
 109     HANDLE const handle = get_handle(offset + i);
 110     ZMapper::map_view_replace_placeholder(handle, 0 /* offset */, addr + i, ZGranuleSize);
 111   }
 112 }
 113 
< prev index next >