183 default: ShouldNotReachHere(); |
183 default: ShouldNotReachHere(); |
184 } |
184 } |
185 return s; |
185 return s; |
186 } |
186 } |
187 |
187 |
188 volatile intptr_t MetaspaceGC::_capacity_until_GC = 0; |
188 volatile size_t MetaspaceGC::_capacity_until_GC = 0; |
189 uint MetaspaceGC::_shrink_factor = 0; |
189 uint MetaspaceGC::_shrink_factor = 0; |
190 bool MetaspaceGC::_should_concurrent_collect = false; |
190 bool MetaspaceGC::_should_concurrent_collect = false; |
191 |
191 |
192 |
192 |
193 typedef class FreeList<Metachunk> ChunkList; |
193 typedef class FreeList<Metachunk> ChunkList; |
2415 } |
2415 } |
2416 |
2416 |
2417 bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC) { |
2417 bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC) { |
2418 assert_is_aligned(v, Metaspace::commit_alignment()); |
2418 assert_is_aligned(v, Metaspace::commit_alignment()); |
2419 |
2419 |
2420 intptr_t capacity_until_GC = _capacity_until_GC; |
2420 size_t capacity_until_GC = _capacity_until_GC; |
2421 intptr_t new_value = capacity_until_GC + v; |
2421 size_t new_value = capacity_until_GC + v; |
2422 |
2422 |
2423 if (new_value < capacity_until_GC) { |
2423 if (new_value < capacity_until_GC) { |
2424 // The addition wrapped around, set new_value to aligned max value. |
2424 // The addition wrapped around, set new_value to aligned max value. |
2425 new_value = align_down(max_uintx, Metaspace::commit_alignment()); |
2425 new_value = align_down(max_uintx, Metaspace::commit_alignment()); |
2426 } |
2426 } |
2427 |
2427 |
2428 intptr_t expected = _capacity_until_GC; |
2428 size_t expected = _capacity_until_GC; |
2429 intptr_t actual = Atomic::cmpxchg(new_value, &_capacity_until_GC, expected); |
2429 size_t actual = Atomic::cmpxchg(new_value, &_capacity_until_GC, expected); |
2430 |
2430 |
2431 if (expected != actual) { |
2431 if (expected != actual) { |
2432 return false; |
2432 return false; |
2433 } |
2433 } |
2434 |
2434 |
2442 } |
2442 } |
2443 |
2443 |
2444 size_t MetaspaceGC::dec_capacity_until_GC(size_t v) { |
2444 size_t MetaspaceGC::dec_capacity_until_GC(size_t v) { |
2445 assert_is_aligned(v, Metaspace::commit_alignment()); |
2445 assert_is_aligned(v, Metaspace::commit_alignment()); |
2446 |
2446 |
2447 return (size_t)Atomic::sub((intptr_t)v, &_capacity_until_GC); |
2447 return Atomic::sub(v, &_capacity_until_GC); |
2448 } |
2448 } |
2449 |
2449 |
2450 void MetaspaceGC::initialize() { |
2450 void MetaspaceGC::initialize() { |
2451 // Set the high-water mark to MaxMetapaceSize during VM initializaton since |
2451 // Set the high-water mark to MaxMetapaceSize during VM initializaton since |
2452 // we can't do a GC during initialization. |
2452 // we can't do a GC during initialization. |