--- old/src/hotspot/share/memory/metaspace.cpp 2017-10-11 09:35:13.448298149 -0400 +++ new/src/hotspot/share/memory/metaspace.cpp 2017-10-11 09:35:12.924250230 -0400 @@ -1499,7 +1499,7 @@ } size_t MetaspaceGC::capacity_until_GC() { - size_t value = (size_t)OrderAccess::load_ptr_acquire(&_capacity_until_GC); + size_t value = OrderAccess::load_acquire(&_capacity_until_GC); assert(value >= MetaspaceSize, "Not initialized properly?"); return value; } @@ -1507,16 +1507,16 @@ 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 = (size_t) _capacity_until_GC; - size_t new_value = capacity_until_GC + v; + intptr_t capacity_until_GC = _capacity_until_GC; + intptr_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()); } - intptr_t expected = (intptr_t) capacity_until_GC; - intptr_t actual = Atomic::cmpxchg_ptr((intptr_t) new_value, &_capacity_until_GC, expected); + intptr_t expected = _capacity_until_GC; + intptr_t actual = Atomic::cmpxchg(new_value, &_capacity_until_GC, expected); if (expected != actual) { return false; @@ -1534,7 +1534,7 @@ size_t MetaspaceGC::dec_capacity_until_GC(size_t v) { assert_is_aligned(v, Metaspace::commit_alignment()); - return (size_t)Atomic::add_ptr(-(intptr_t)v, &_capacity_until_GC); + return (size_t)Atomic::sub((intptr_t)v, &_capacity_until_GC); } void MetaspaceGC::initialize() { @@ -2398,7 +2398,7 @@ void SpaceManager::inc_used_metrics(size_t words) { // Add to the per SpaceManager total - Atomic::add_ptr(words, &_allocated_blocks_words); + Atomic::add(words, &_allocated_blocks_words); // Add to the global total MetaspaceAux::inc_used(mdtype(), words); } @@ -2753,8 +2753,7 @@ // sweep which is a concurrent phase. Protection by the expand_lock() // is not enough since allocation is on a per Metaspace basis // and protected by the Metaspace lock. - jlong minus_words = (jlong) - (jlong) words; - Atomic::add_ptr(minus_words, &_used_words[mdtype]); + Atomic::sub(words, &_used_words[mdtype]); } void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) { @@ -2762,7 +2761,7 @@ // each piece of metadata. Those allocations are // generally done concurrently by different application // threads so must be done atomically. - Atomic::add_ptr(words, &_used_words[mdtype]); + Atomic::add(words, &_used_words[mdtype]); } size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) {