< prev index next >

src/share/vm/gc/parallel/adjoiningGenerations.cpp

Print this page




 144 }
 145 
 146 // Make checks on the current sizes of the generations and
 147 // the constraints on the sizes of the generations.  Push
 148 // up the boundary within the constraints.  A partial
 149 // push can occur.
 150 void AdjoiningGenerations::request_old_gen_expansion(size_t expand_in_bytes) {
 151   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
 152 
 153   assert_lock_strong(ExpandHeap_lock);
 154   assert_locked_or_safepoint(Heap_lock);
 155 
 156   // These sizes limit the amount the boundaries can move.  Effectively,
 157   // the generation says how much it is willing to yield to the other
 158   // generation.
 159   const size_t young_gen_available = young_gen()->available_for_contraction();
 160   const size_t old_gen_available = old_gen()->available_for_expansion();
 161   const size_t alignment = virtual_spaces()->alignment();
 162   size_t change_in_bytes = MIN3(young_gen_available,
 163                                 old_gen_available,
 164                                 align_size_up_(expand_in_bytes, alignment));
 165 
 166   if (change_in_bytes == 0) {
 167     return;
 168   }
 169 
 170   log_before_expansion(true, expand_in_bytes, change_in_bytes, old_gen()->max_gen_size());
 171 
 172   // Move the boundary between the generations up (smaller young gen).
 173   if (virtual_spaces()->adjust_boundary_up(change_in_bytes)) {
 174     young_gen()->reset_after_change();
 175     old_gen()->reset_after_change();
 176   }
 177 
 178   // The total reserved for the generations should match the sum
 179   // of the two even if the boundary is moving.
 180   assert(reserved_byte_size() ==
 181          old_gen()->max_gen_size() + young_gen()->max_size(),
 182          "Space is missing");
 183   young_gen()->space_invariants();
 184   old_gen()->space_invariants();


 186   log_after_expansion(true, old_gen()->max_gen_size());
 187 }
 188 
 189 // See comments on request_old_gen_expansion()
 190 bool AdjoiningGenerations::request_young_gen_expansion(size_t expand_in_bytes) {
 191   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
 192 
 193   // If eden is not empty, the boundary can be moved but no advantage
 194   // can be made of the move since eden cannot be moved.
 195   if (!young_gen()->eden_space()->is_empty()) {
 196     return false;
 197   }
 198 
 199 
 200   bool result = false;
 201   const size_t young_gen_available = young_gen()->available_for_expansion();
 202   const size_t old_gen_available = old_gen()->available_for_contraction();
 203   const size_t alignment = virtual_spaces()->alignment();
 204   size_t change_in_bytes = MIN3(young_gen_available,
 205                                 old_gen_available,
 206                                 align_size_up_(expand_in_bytes, alignment));
 207 
 208   if (change_in_bytes == 0) {
 209     return false;
 210   }
 211 
 212   log_before_expansion(false, expand_in_bytes, change_in_bytes, young_gen()->max_size());
 213 
 214   // Move the boundary between the generations down (smaller old gen).
 215   MutexLocker x(ExpandHeap_lock);
 216   if (virtual_spaces()->adjust_boundary_down(change_in_bytes)) {
 217     young_gen()->reset_after_change();
 218     old_gen()->reset_after_change();
 219     result = true;
 220   }
 221 
 222   // The total reserved for the generations should match the sum
 223   // of the two even if the boundary is moving.
 224   assert(reserved_byte_size() ==
 225          old_gen()->max_gen_size() + young_gen()->max_size(),
 226          "Space is missing");




 144 }
 145 
 146 // Make checks on the current sizes of the generations and
 147 // the constraints on the sizes of the generations.  Push
 148 // up the boundary within the constraints.  A partial
 149 // push can occur.
 150 void AdjoiningGenerations::request_old_gen_expansion(size_t expand_in_bytes) {
 151   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
 152 
 153   assert_lock_strong(ExpandHeap_lock);
 154   assert_locked_or_safepoint(Heap_lock);
 155 
 156   // These sizes limit the amount the boundaries can move.  Effectively,
 157   // the generation says how much it is willing to yield to the other
 158   // generation.
 159   const size_t young_gen_available = young_gen()->available_for_contraction();
 160   const size_t old_gen_available = old_gen()->available_for_expansion();
 161   const size_t alignment = virtual_spaces()->alignment();
 162   size_t change_in_bytes = MIN3(young_gen_available,
 163                                 old_gen_available,
 164                                 align_up_(expand_in_bytes, alignment));
 165 
 166   if (change_in_bytes == 0) {
 167     return;
 168   }
 169 
 170   log_before_expansion(true, expand_in_bytes, change_in_bytes, old_gen()->max_gen_size());
 171 
 172   // Move the boundary between the generations up (smaller young gen).
 173   if (virtual_spaces()->adjust_boundary_up(change_in_bytes)) {
 174     young_gen()->reset_after_change();
 175     old_gen()->reset_after_change();
 176   }
 177 
 178   // The total reserved for the generations should match the sum
 179   // of the two even if the boundary is moving.
 180   assert(reserved_byte_size() ==
 181          old_gen()->max_gen_size() + young_gen()->max_size(),
 182          "Space is missing");
 183   young_gen()->space_invariants();
 184   old_gen()->space_invariants();


 186   log_after_expansion(true, old_gen()->max_gen_size());
 187 }
 188 
 189 // See comments on request_old_gen_expansion()
 190 bool AdjoiningGenerations::request_young_gen_expansion(size_t expand_in_bytes) {
 191   assert(UseAdaptiveSizePolicy && UseAdaptiveGCBoundary, "runtime check");
 192 
 193   // If eden is not empty, the boundary can be moved but no advantage
 194   // can be made of the move since eden cannot be moved.
 195   if (!young_gen()->eden_space()->is_empty()) {
 196     return false;
 197   }
 198 
 199 
 200   bool result = false;
 201   const size_t young_gen_available = young_gen()->available_for_expansion();
 202   const size_t old_gen_available = old_gen()->available_for_contraction();
 203   const size_t alignment = virtual_spaces()->alignment();
 204   size_t change_in_bytes = MIN3(young_gen_available,
 205                                 old_gen_available,
 206                                 align_up_(expand_in_bytes, alignment));
 207 
 208   if (change_in_bytes == 0) {
 209     return false;
 210   }
 211 
 212   log_before_expansion(false, expand_in_bytes, change_in_bytes, young_gen()->max_size());
 213 
 214   // Move the boundary between the generations down (smaller old gen).
 215   MutexLocker x(ExpandHeap_lock);
 216   if (virtual_spaces()->adjust_boundary_down(change_in_bytes)) {
 217     young_gen()->reset_after_change();
 218     old_gen()->reset_after_change();
 219     result = true;
 220   }
 221 
 222   // The total reserved for the generations should match the sum
 223   // of the two even if the boundary is moving.
 224   assert(reserved_byte_size() ==
 225          old_gen()->max_gen_size() + young_gen()->max_size(),
 226          "Space is missing");


< prev index next >