< prev index next >
src/hotspot/share/memory/metaspace.cpp
Print this page
rev 50191 : [mq]: 8203262-capacity-until-gc2
*** 2415,2444 ****
}
bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC) {
assert_is_aligned(v, Metaspace::commit_alignment());
! size_t capacity_until_GC = _capacity_until_GC;
! size_t new_value = capacity_until_GC + v;
! if (new_value < capacity_until_GC) {
// The addition wrapped around, set new_value to aligned max value.
new_value = align_down(max_uintx, Metaspace::commit_alignment());
}
! size_t expected = _capacity_until_GC;
! size_t actual = Atomic::cmpxchg(new_value, &_capacity_until_GC, expected);
! if (expected != actual) {
return false;
}
if (new_cap_until_GC != NULL) {
*new_cap_until_GC = new_value;
}
if (old_cap_until_GC != NULL) {
! *old_cap_until_GC = capacity_until_GC;
}
return true;
}
size_t MetaspaceGC::dec_capacity_until_GC(size_t v) {
--- 2415,2443 ----
}
bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC) {
assert_is_aligned(v, Metaspace::commit_alignment());
! size_t old_value = _capacity_until_GC;
! size_t new_value = old_value + v;
! if (new_value < old_value) {
// The addition wrapped around, set new_value to aligned max value.
new_value = align_down(max_uintx, Metaspace::commit_alignment());
}
! size_t res = Atomic::cmpxchg(new_value, &_capacity_until_GC, old_value);
! if (old_value != res) {
return false;
}
if (new_cap_until_GC != NULL) {
*new_cap_until_GC = new_value;
}
if (old_cap_until_GC != NULL) {
! *old_cap_until_GC = old_value;
}
return true;
}
size_t MetaspaceGC::dec_capacity_until_GC(size_t v) {
< prev index next >