< prev index next >

share/gc/g1/g1PageBasedVirtualSpace.cpp

Print this page
rev 1 : G1GC+POGC+NVDIMM Patch with latest comments incorporated from all.
rev 2 : Removed fcntl and fixed hotspot else violation
rev 8 : Final version addressing all Thomas S concerns
rev 9 : Cleaned up virtualspace.cpp
rev 10 : Removed any AllocateOldGenAt handling in reservespace


 107 bool G1PageBasedVirtualSpace::is_area_committed(size_t start_page, size_t size_in_pages) const {
 108   size_t end_page = start_page + size_in_pages;
 109   return _committed.get_next_zero_offset(start_page, end_page) >= end_page;
 110 }
 111 
 112 bool G1PageBasedVirtualSpace::is_area_uncommitted(size_t start_page, size_t size_in_pages) const {
 113   size_t end_page = start_page + size_in_pages;
 114   return _committed.get_next_one_offset(start_page, end_page) >= end_page;
 115 }
 116 
 117 char* G1PageBasedVirtualSpace::page_start(size_t index) const {
 118   return _low_boundary + index * _page_size;
 119 }
 120 
 121 bool G1PageBasedVirtualSpace::is_after_last_page(size_t index) const {
 122   guarantee(index <= _committed.size(),
 123             "Given boundary page " SIZE_FORMAT " is beyond managed page count " SIZE_FORMAT, index, _committed.size());
 124   return index == _committed.size();
 125 }
 126 











 127 void G1PageBasedVirtualSpace::commit_preferred_pages(size_t start, size_t num_pages) {
 128   vmassert(num_pages > 0, "No full pages to commit");
 129   vmassert(start + num_pages <= _committed.size(),
 130            "Tried to commit area from page " SIZE_FORMAT " to page " SIZE_FORMAT " "
 131            "that is outside of managed space of " SIZE_FORMAT " pages",
 132            start, start + num_pages, _committed.size());
 133 
 134   char* start_addr = page_start(start);
 135   size_t size = num_pages * _page_size;
 136 


















 137   os::commit_memory_or_exit(start_addr, size, _page_size, _executable,
 138                             err_msg("Failed to commit area from " PTR_FORMAT " to " PTR_FORMAT " of length " SIZE_FORMAT ".",
 139                             p2i(start_addr), p2i(start_addr + size), size));
 140 }
 141 
 142 void G1PageBasedVirtualSpace::commit_tail() {
 143   vmassert(_tail_size > 0, "The size of the tail area must be > 0 when reaching here");
 144 
 145   char* const aligned_end_address = align_down(_high_boundary, _page_size);
 146   os::commit_memory_or_exit(aligned_end_address, _tail_size, os::vm_page_size(), _executable,
 147                             err_msg("Failed to commit tail area from " PTR_FORMAT " to " PTR_FORMAT " of length " SIZE_FORMAT ".",
 148                             p2i(aligned_end_address), p2i(_high_boundary), _tail_size));
 149 }
 150 
 151 void G1PageBasedVirtualSpace::commit_internal(size_t start_page, size_t end_page) {
 152   guarantee(start_page < end_page,
 153             "Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page);
 154   guarantee(end_page <= _committed.size(),
 155             "Given end page " SIZE_FORMAT " is beyond end of managed page amount of " SIZE_FORMAT, end_page, _committed.size());
 156 




 107 bool G1PageBasedVirtualSpace::is_area_committed(size_t start_page, size_t size_in_pages) const {
 108   size_t end_page = start_page + size_in_pages;
 109   return _committed.get_next_zero_offset(start_page, end_page) >= end_page;
 110 }
 111 
 112 bool G1PageBasedVirtualSpace::is_area_uncommitted(size_t start_page, size_t size_in_pages) const {
 113   size_t end_page = start_page + size_in_pages;
 114   return _committed.get_next_one_offset(start_page, end_page) >= end_page;
 115 }
 116 
 117 char* G1PageBasedVirtualSpace::page_start(size_t index) const {
 118   return _low_boundary + index * _page_size;
 119 }
 120 
 121 bool G1PageBasedVirtualSpace::is_after_last_page(size_t index) const {
 122   guarantee(index <= _committed.size(),
 123             "Given boundary page " SIZE_FORMAT " is beyond managed page count " SIZE_FORMAT, index, _committed.size());
 124   return index == _committed.size();
 125 }
 126 
 127 // Setsup NVDIMM to Max oldgen Size allowed.
 128 size_t G1PageBasedVirtualSpace::get_nvdimm_size() {
 129   size_t size = reserved_size();
 130   uint nvdimm_max_percent = 100 - G1MaxNewSizePercent;
 131   size_t nvdimm_size = (size_t)((size * nvdimm_max_percent)/100);
 132   size_t page_sz = os::vm_page_size() -1 ;
 133   nvdimm_size = (nvdimm_size + page_sz) & (~page_sz);
 134   nvdimm_size = align_up(nvdimm_size, HeapRegion::GrainBytes);
 135   return nvdimm_size;
 136 }
 137 
 138 void G1PageBasedVirtualSpace::commit_preferred_pages(size_t start, size_t num_pages) {
 139   vmassert(num_pages > 0, "No full pages to commit");
 140   vmassert(start + num_pages <= _committed.size(),
 141            "Tried to commit area from page " SIZE_FORMAT " to page " SIZE_FORMAT " "
 142            "that is outside of managed space of " SIZE_FORMAT " pages",
 143            start, start + num_pages, _committed.size());
 144 
 145   char* start_addr = page_start(start);
 146   size_t size = num_pages * _page_size;
 147   
 148   if ((address)start_addr == (address)os::nvdimm_heapbase()) {
 149     bool is_committed = os::commit_memory(start_addr, size, false, os::nvdimm_fd());
 150     if (!is_committed)  {
 151       vm_exit_during_initialization(
 152         err_msg("Could not map memory at %p for NVDIMM %s Fd %d", start_addr, AllocateOldGenAt, os::nvdimm_fd()));
 153     } else {
 154       log_info(gc, heap)("NVDIMM Memory successfully mapped at %p, Size %lu", start_addr, size);
 155       os::close(os::nvdimm_fd());
 156     }
 157     size_t nvdimm_size = get_nvdimm_size();
 158     char* dram_base = (char*)start_addr + nvdimm_size;
 159     size_t total_sz = reserved_size();
 160     os::set_dram_heapbase((address)dram_base);
 161     log_info(gc, heap)("Java DRAM Heap at [%p - %p] & NVDIMM Old Gen at [%p - %p] Total Heap Sz %ld \n", 
 162       start_addr+nvdimm_size, (char*)(start_addr + total_sz), start_addr, (char*)(start_addr + nvdimm_size), total_sz);
 163 
 164     return;
 165   }
 166   os::commit_memory_or_exit(start_addr, size, _page_size, _executable,
 167                             err_msg("Failed to commit area from " PTR_FORMAT " to " PTR_FORMAT " of length " SIZE_FORMAT ".",
 168                             p2i(start_addr), p2i(start_addr + size), size));
 169 }
 170 
 171 void G1PageBasedVirtualSpace::commit_tail() {
 172   vmassert(_tail_size > 0, "The size of the tail area must be > 0 when reaching here");
 173 
 174   char* const aligned_end_address = align_down(_high_boundary, _page_size);
 175   os::commit_memory_or_exit(aligned_end_address, _tail_size, os::vm_page_size(), _executable,
 176                             err_msg("Failed to commit tail area from " PTR_FORMAT " to " PTR_FORMAT " of length " SIZE_FORMAT ".",
 177                             p2i(aligned_end_address), p2i(_high_boundary), _tail_size));
 178 }
 179 
 180 void G1PageBasedVirtualSpace::commit_internal(size_t start_page, size_t end_page) {
 181   guarantee(start_page < end_page,
 182             "Given start page " SIZE_FORMAT " is larger or equal to end page " SIZE_FORMAT, start_page, end_page);
 183   guarantee(end_page <= _committed.size(),
 184             "Given end page " SIZE_FORMAT " is beyond end of managed page amount of " SIZE_FORMAT, end_page, _committed.size());
 185 


< prev index next >