1394 if (delta <= min_delta) {
1395 delta = min_delta;
1396 } else if (delta <= max_delta) {
1397 // Don't want to hit the high water mark on the next
1398 // allocation so make the delta greater than just enough
1399 // for this allocation.
1400 delta = max_delta;
1401 } else {
1402 // This allocation is large but the next ones are probably not
1403 // so increase by the minimum.
1404 delta = delta + min_delta;
1405 }
1406
1407 assert_is_size_aligned(delta, Metaspace::commit_alignment());
1408
1409 return delta;
1410 }
1411
1412 size_t MetaspaceGC::capacity_until_GC() {
1413 size_t value = (size_t)OrderAccess::load_ptr_acquire(&_capacity_until_GC);
1414 assert(value >= MetaspaceSize, "Not initialied properly?");
1415 return value;
1416 }
1417
1418 bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC) {
1419 assert_is_size_aligned(v, Metaspace::commit_alignment());
1420
1421 size_t capacity_until_GC = (size_t) _capacity_until_GC;
1422 size_t new_value = capacity_until_GC + v;
1423
1424 if (new_value < capacity_until_GC) {
1425 // The addition wrapped around, set new_value to aligned max value.
1426 new_value = align_size_down(max_uintx, Metaspace::commit_alignment());
1427 }
1428
1429 intptr_t expected = (intptr_t) capacity_until_GC;
1430 intptr_t actual = Atomic::cmpxchg_ptr((intptr_t) new_value, &_capacity_until_GC, expected);
1431
1432 if (expected != actual) {
1433 return false;
1434 }
|
1394 if (delta <= min_delta) {
1395 delta = min_delta;
1396 } else if (delta <= max_delta) {
1397 // Don't want to hit the high water mark on the next
1398 // allocation so make the delta greater than just enough
1399 // for this allocation.
1400 delta = max_delta;
1401 } else {
1402 // This allocation is large but the next ones are probably not
1403 // so increase by the minimum.
1404 delta = delta + min_delta;
1405 }
1406
1407 assert_is_size_aligned(delta, Metaspace::commit_alignment());
1408
1409 return delta;
1410 }
1411
1412 size_t MetaspaceGC::capacity_until_GC() {
1413 size_t value = (size_t)OrderAccess::load_ptr_acquire(&_capacity_until_GC);
1414 assert(value >= MetaspaceSize, "Not initialized properly?");
1415 return value;
1416 }
1417
1418 bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC) {
1419 assert_is_size_aligned(v, Metaspace::commit_alignment());
1420
1421 size_t capacity_until_GC = (size_t) _capacity_until_GC;
1422 size_t new_value = capacity_until_GC + v;
1423
1424 if (new_value < capacity_until_GC) {
1425 // The addition wrapped around, set new_value to aligned max value.
1426 new_value = align_size_down(max_uintx, Metaspace::commit_alignment());
1427 }
1428
1429 intptr_t expected = (intptr_t) capacity_until_GC;
1430 intptr_t actual = Atomic::cmpxchg_ptr((intptr_t) new_value, &_capacity_until_GC, expected);
1431
1432 if (expected != actual) {
1433 return false;
1434 }
|