< prev index next >

src/share/vm/gc/shared/cardGeneration.cpp

Print this page




 114   if (aligned_bytes == 0){
 115     // The alignment caused the number of bytes to wrap.  An expand_by(0) will
 116     // return true with the implication that an expansion was done when it
 117     // was not.  A call to expand implies a best effort to expand by "bytes"
 118     // but not a guarantee.  Align down to give a best effort.  This is likely
 119     // the most that the generation can expand since it has some capacity to
 120     // start with.
 121     aligned_bytes = ReservedSpace::page_align_size_down(bytes);
 122   }
 123   size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
 124   bool success = false;
 125   if (aligned_expand_bytes > aligned_bytes) {
 126     success = grow_by(aligned_expand_bytes);
 127   }
 128   if (!success) {
 129     success = grow_by(aligned_bytes);
 130   }
 131   if (!success) {
 132     success = grow_to_reserved();
 133   }
 134   if (success && GC_locker::is_active_and_needs_gc()) {
 135     log_trace(gc, heap)("Garbage collection disabled, expanded heap instead");
 136   }
 137 
 138   return success;
 139 }
 140 
 141 bool CardGeneration::grow_to_reserved() {
 142   assert_correct_size_change_locking();
 143   bool success = true;
 144   const size_t remaining_bytes = _virtual_space.uncommitted_size();
 145   if (remaining_bytes > 0) {
 146     success = grow_by(remaining_bytes);
 147     DEBUG_ONLY(if (!success) warning("grow to reserved failed");)
 148   }
 149   return success;
 150 }
 151 
 152 void CardGeneration::shrink(size_t bytes) {
 153   assert_correct_size_change_locking();
 154 




 114   if (aligned_bytes == 0){
 115     // The alignment caused the number of bytes to wrap.  An expand_by(0) will
 116     // return true with the implication that an expansion was done when it
 117     // was not.  A call to expand implies a best effort to expand by "bytes"
 118     // but not a guarantee.  Align down to give a best effort.  This is likely
 119     // the most that the generation can expand since it has some capacity to
 120     // start with.
 121     aligned_bytes = ReservedSpace::page_align_size_down(bytes);
 122   }
 123   size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
 124   bool success = false;
 125   if (aligned_expand_bytes > aligned_bytes) {
 126     success = grow_by(aligned_expand_bytes);
 127   }
 128   if (!success) {
 129     success = grow_by(aligned_bytes);
 130   }
 131   if (!success) {
 132     success = grow_to_reserved();
 133   }
 134   if (success && GCLocker::is_active_and_needs_gc()) {
 135     log_trace(gc, heap)("Garbage collection disabled, expanded heap instead");
 136   }
 137 
 138   return success;
 139 }
 140 
 141 bool CardGeneration::grow_to_reserved() {
 142   assert_correct_size_change_locking();
 143   bool success = true;
 144   const size_t remaining_bytes = _virtual_space.uncommitted_size();
 145   if (remaining_bytes > 0) {
 146     success = grow_by(remaining_bytes);
 147     DEBUG_ONLY(if (!success) warning("grow to reserved failed");)
 148   }
 149   return success;
 150 }
 151 
 152 void CardGeneration::shrink(size_t bytes) {
 153   assert_correct_size_change_locking();
 154 


< prev index next >