< prev index next >

src/hotspot/share/gc/parallel/adjoiningGenerationsForHeteroHeap.cpp

Print this page
rev 52626 : webrev.03
rev 52627 : some comments from Sangheon
rev 52628 : changes for full GC


  83   _virtual_spaces = hetero_virtual_spaces;
  84 }
  85 
  86 size_t AdjoiningGenerationsForHeteroHeap::required_reserved_memory(GenerationSizer* policy) {
  87   // This is the size that young gen can grow to, when AdaptiveGCBoundary is true.
  88   size_t max_yg_size = policy->max_heap_byte_size() - policy->min_old_size();
  89   // This is the size that old gen can grow to, when AdaptiveGCBoundary is true.
  90   size_t max_old_size = policy->max_heap_byte_size() - policy->min_young_size();
  91 
  92   return max_yg_size + max_old_size;
  93 }
  94 
  95 // We override this function since size of reservedspace here is more than heap size and
  96 // callers expect this function to return heap size.
  97 size_t AdjoiningGenerationsForHeteroHeap::reserved_byte_size() {
  98   return total_size_limit();
  99 }
 100 
 101 AdjoiningGenerationsForHeteroHeap::HeteroVirtualSpaces::HeteroVirtualSpaces(ReservedSpace rs, size_t min_old_byte_size, size_t min_yg_byte_size, size_t max_total_size, size_t alignment) : 
 102                                                                             AdjoiningVirtualSpaces(rs, min_old_byte_size, min_yg_byte_size, alignment),

 103                                                                             _min_old_byte_size(min_old_byte_size), _min_young_byte_size(min_yg_byte_size), 
 104                                                                             _max_old_byte_size(_max_total_size - _min_young_byte_size), 
 105                                                                             _max_young_byte_size(_max_total_size - _min_old_byte_size), 
 106                                                                             _max_total_size(max_total_size) {
 107 }
 108 
 109 void AdjoiningGenerationsForHeteroHeap::HeteroVirtualSpaces::initialize(size_t initial_old_reserved_size, size_t init_old_byte_size,
 110                                                                         size_t init_young_byte_size) {
 111 
 112   // This is the reserved space exclusively for old generation.
 113   ReservedSpace old_rs = _reserved_space.first_part(_max_old_byte_size, true);
 114   // Intially we only assign 'initial_old_reserved_size' of the reserved space to old virtual space.
 115   old_rs = old_rs.first_part(initial_old_reserved_size);
 116 
 117   // This is the reserved space exclusively for young generation.
 118   ReservedSpace young_rs = _reserved_space.last_part(_max_old_byte_size).first_part(_max_young_byte_size);
 119   
 120   // Carve out 'initial_young_reserved_size' of reserved space.
 121   size_t initial_young_reserved_size = _max_total_size - initial_old_reserved_size;
 122   young_rs = young_rs.last_part(_max_young_byte_size - initial_young_reserved_size);





 123 
 124   _low = new PSFileBackedVirtualSpace(old_rs, alignment(), AllocateOldGenAt);
 125   if (!_low->expand_by(init_old_byte_size)) {
 126     vm_exit_during_initialization("Could not reserve enough space for object heap");
 127   }
 128 
 129   _high = new PSVirtualSpaceHighToLow(young_rs, alignment());
 130   if (!_high->expand_by(init_young_byte_size)) {
 131     vm_exit_during_initialization("Could not reserve enough space for object heap");
 132   }
 133 }
 134 
 135 // Since the virtual spaces are non-overlapping, there is no boundary as such.
 136 // We replicate the same behavior and maintain the same invariants as base class - AdjoiningVirtualSpaces, by
 137 // increasing old generation size and decreasing young generation size by same amount.
 138 bool AdjoiningGenerationsForHeteroHeap::HeteroVirtualSpaces::adjust_boundary_up(size_t change_in_bytes) {
 139   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
 140   DEBUG_ONLY(size_t total_size_before = young_vs()->reserved_size() + old_vs()->reserved_size());
 141 
 142   size_t bytes_needed = change_in_bytes;
 143   size_t uncommitted_in_old = MIN2(old_vs()->uncommitted_size(), bytes_needed);
 144   bool old_expanded = false;
 145 
 146   // 1. Try to expand old within its reserved space.
 147   if (uncommitted_in_old != 0) {
 148     if (!old_vs()->expand_by(uncommitted_in_old)) {
 149       return false;
 150     }
 151     old_expanded = true;
 152     bytes_needed -= uncommitted_in_old;
 153     if (bytes_needed == 0) {
 154       return true;
 155     }
 156   }




  83   _virtual_spaces = hetero_virtual_spaces;
  84 }
  85 
  86 size_t AdjoiningGenerationsForHeteroHeap::required_reserved_memory(GenerationSizer* policy) {
  87   // This is the size that young gen can grow to, when AdaptiveGCBoundary is true.
  88   size_t max_yg_size = policy->max_heap_byte_size() - policy->min_old_size();
  89   // This is the size that old gen can grow to, when AdaptiveGCBoundary is true.
  90   size_t max_old_size = policy->max_heap_byte_size() - policy->min_young_size();
  91 
  92   return max_yg_size + max_old_size;
  93 }
  94 
  95 // We override this function since size of reservedspace here is more than heap size and
  96 // callers expect this function to return heap size.
  97 size_t AdjoiningGenerationsForHeteroHeap::reserved_byte_size() {
  98   return total_size_limit();
  99 }
 100 
 101 AdjoiningGenerationsForHeteroHeap::HeteroVirtualSpaces::HeteroVirtualSpaces(ReservedSpace rs, size_t min_old_byte_size, size_t min_yg_byte_size, size_t max_total_size, size_t alignment) : 
 102                                                                             AdjoiningVirtualSpaces(rs, min_old_byte_size, min_yg_byte_size, alignment),
 103                                                                             _max_total_size(max_total_size),
 104                                                                             _min_old_byte_size(min_old_byte_size), _min_young_byte_size(min_yg_byte_size), 
 105                                                                             _max_old_byte_size(_max_total_size - _min_young_byte_size), 
 106                                                                             _max_young_byte_size(_max_total_size - _min_old_byte_size) {

 107 }
 108 
 109 void AdjoiningGenerationsForHeteroHeap::HeteroVirtualSpaces::initialize(size_t initial_old_reserved_size, size_t init_old_byte_size,
 110                                                                         size_t init_young_byte_size) {
 111 
 112   // This is the reserved space exclusively for old generation.
 113   ReservedSpace low_rs = _reserved_space.first_part(_max_old_byte_size, true);
 114   // Intially we only assign 'initial_old_reserved_size' of the reserved space to old virtual space.
 115   low_rs = low_rs.first_part(initial_old_reserved_size);
 116 
 117   // This is the reserved space exclusively for young generation.
 118   ReservedSpace high_rs = _reserved_space.last_part(_max_old_byte_size).first_part(_max_young_byte_size);
 119   
 120   // Carve out 'initial_young_reserved_size' of reserved space.
 121   size_t initial_young_reserved_size = _max_total_size - initial_old_reserved_size;
 122   high_rs = high_rs.last_part(_max_young_byte_size - initial_young_reserved_size);
 123 
 124   _low = new PSFileBackedVirtualSpace(low_rs, alignment(), AllocateOldGenAt);
 125   if (!static_cast <PSFileBackedVirtualSpace*>(_low)->initialize()) {
 126     vm_exit_during_initialization("Could not map space for old generation at given AllocateOldGenAt path");
 127   }
 128 

 129   if (!_low->expand_by(init_old_byte_size)) {
 130     vm_exit_during_initialization("Could not reserve enough space for object heap");
 131   }
 132 
 133   _high = new PSVirtualSpaceHighToLow(high_rs, alignment());
 134   if (!_high->expand_by(init_young_byte_size)) {
 135     vm_exit_during_initialization("Could not reserve enough space for object heap");
 136   }
 137 }
 138 
 139 // Since the virtual spaces are non-overlapping, there is no boundary as such.
 140 // We replicate the same behavior and maintain the same invariants as base class 'AdjoiningVirtualSpaces' by
 141 // increasing old generation size and decreasing young generation size by same amount.
 142 bool AdjoiningGenerationsForHeteroHeap::HeteroVirtualSpaces::adjust_boundary_up(size_t change_in_bytes) {
 143   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
 144   DEBUG_ONLY(size_t total_size_before = young_vs()->reserved_size() + old_vs()->reserved_size());
 145 
 146   size_t bytes_needed = change_in_bytes;
 147   size_t uncommitted_in_old = MIN2(old_vs()->uncommitted_size(), bytes_needed);
 148   bool old_expanded = false;
 149 
 150   // 1. Try to expand old within its reserved space.
 151   if (uncommitted_in_old != 0) {
 152     if (!old_vs()->expand_by(uncommitted_in_old)) {
 153       return false;
 154     }
 155     old_expanded = true;
 156     bytes_needed -= uncommitted_in_old;
 157     if (bytes_needed == 0) {
 158       return true;
 159     }
 160   }


< prev index next >