< prev index next >

src/hotspot/share/memory/metaspace.cpp

Print this page




 145   assert_is_aligned(v, Metaspace::commit_alignment());
 146 
 147   size_t old_capacity_until_GC = _capacity_until_GC;
 148   size_t new_value = old_capacity_until_GC + v;
 149 
 150   if (new_value < old_capacity_until_GC) {
 151     // The addition wrapped around, set new_value to aligned max value.
 152     new_value = align_down(max_uintx, Metaspace::commit_alignment());
 153   }
 154 
 155   if (new_value > MaxMetaspaceSize) {
 156     if (can_retry != NULL) {
 157       *can_retry = false;
 158     }
 159     return false;
 160   }
 161 
 162   if (can_retry != NULL) {
 163     *can_retry = true;
 164   }
 165   size_t prev_value = Atomic::cmpxchg(new_value, &_capacity_until_GC, old_capacity_until_GC);
 166 
 167   if (old_capacity_until_GC != prev_value) {
 168     return false;
 169   }
 170 
 171   if (new_cap_until_GC != NULL) {
 172     *new_cap_until_GC = new_value;
 173   }
 174   if (old_cap_until_GC != NULL) {
 175     *old_cap_until_GC = old_capacity_until_GC;
 176   }
 177   return true;
 178 }
 179 
 180 size_t MetaspaceGC::dec_capacity_until_GC(size_t v) {
 181   assert_is_aligned(v, Metaspace::commit_alignment());
 182 
 183   return Atomic::sub(&_capacity_until_GC, v);
 184 }
 185 




 145   assert_is_aligned(v, Metaspace::commit_alignment());
 146 
 147   size_t old_capacity_until_GC = _capacity_until_GC;
 148   size_t new_value = old_capacity_until_GC + v;
 149 
 150   if (new_value < old_capacity_until_GC) {
 151     // The addition wrapped around, set new_value to aligned max value.
 152     new_value = align_down(max_uintx, Metaspace::commit_alignment());
 153   }
 154 
 155   if (new_value > MaxMetaspaceSize) {
 156     if (can_retry != NULL) {
 157       *can_retry = false;
 158     }
 159     return false;
 160   }
 161 
 162   if (can_retry != NULL) {
 163     *can_retry = true;
 164   }
 165   size_t prev_value = Atomic::cmpxchg(&_capacity_until_GC, old_capacity_until_GC, new_value);
 166 
 167   if (old_capacity_until_GC != prev_value) {
 168     return false;
 169   }
 170 
 171   if (new_cap_until_GC != NULL) {
 172     *new_cap_until_GC = new_value;
 173   }
 174   if (old_cap_until_GC != NULL) {
 175     *old_cap_until_GC = old_capacity_until_GC;
 176   }
 177   return true;
 178 }
 179 
 180 size_t MetaspaceGC::dec_capacity_until_GC(size_t v) {
 181   assert_is_aligned(v, Metaspace::commit_alignment());
 182 
 183   return Atomic::sub(&_capacity_until_GC, v);
 184 }
 185 


< prev index next >