diff --git a/src/hotspot/share/gc/z/zArray.hpp b/src/hotspot/share/gc/z/zArray.hpp index 1ee7f6cda96..12123a05025 100644 --- a/src/hotspot/share/gc/z/zArray.hpp +++ b/src/hotspot/share/gc/z/zArray.hpp @@ -25,16 +25,9 @@ #define SHARE_GC_Z_ZARRAY_HPP #include "memory/allocation.hpp" -#include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" -template -class ZArray : public GrowableArrayCHeap { -public: - ZArray(); - - void transfer(ZArray* from); -}; +template using ZArray = GrowableArrayCHeap; template class ZArrayIteratorImpl : public StackObj { diff --git a/src/hotspot/share/gc/z/zArray.inline.hpp b/src/hotspot/share/gc/z/zArray.inline.hpp index 15a8f45ccaf..6382a638046 100644 --- a/src/hotspot/share/gc/z/zArray.inline.hpp +++ b/src/hotspot/share/gc/z/zArray.inline.hpp @@ -25,24 +25,8 @@ #define SHARE_GC_Z_ZARRAY_INLINE_HPP #include "gc/z/zArray.hpp" -#include "memory/allocation.inline.hpp" #include "runtime/atomic.hpp" -template -inline ZArray::ZArray() : - GrowableArrayCHeap(0) {} - -template -inline void ZArray::transfer(ZArray* from) { - assert(this->_data == NULL, "Should be empty"); - this->_data = from->_data; - this->_len = from->_len; - this->_max = from->_max; - from->_data = NULL; - from->_len = 0; - from->_max = 0; -} - template inline ZArrayIteratorImpl::ZArrayIteratorImpl(ZArray* array) : _array(array), diff --git a/src/hotspot/share/gc/z/zSafeDelete.inline.hpp b/src/hotspot/share/gc/z/zSafeDelete.inline.hpp index ebe102b014d..2a14eeb9387 100644 --- a/src/hotspot/share/gc/z/zSafeDelete.inline.hpp +++ b/src/hotspot/share/gc/z/zSafeDelete.inline.hpp @@ -69,7 +69,7 @@ void ZSafeDeleteImpl::disable_deferred_delete() { ZLocker locker(_lock); assert(_enabled > 0, "Invalid state"); if (--_enabled == 0) { - deferred.transfer(&_deferred); + deferred.swap(&_deferred); } } diff --git a/src/hotspot/share/utilities/growableArray.hpp b/src/hotspot/share/utilities/growableArray.hpp index e4a0acf0755..3ed31cc3652 100644 --- a/src/hotspot/share/utilities/growableArray.hpp +++ b/src/hotspot/share/utilities/growableArray.hpp @@ -435,6 +435,12 @@ public: return this->at(location); } + void swap(GrowableArrayWithAllocator* other) { + ::swap(this->_data, other->_data); + ::swap(this->_len, other->_len); + ::swap(this->_max, other->_max); + } + void clear_and_deallocate(); }; @@ -687,7 +693,7 @@ class GrowableArrayCHeap : public GrowableArrayWithAllocator >( allocate(initial_max, F), initial_max) {} diff --git a/test/hotspot/gtest/gc/z/test_zArray.cpp b/test/hotspot/gtest/gc/z/test_zArray.cpp index a8990d9ebcb..d0f352c16f4 100644 --- a/test/hotspot/gtest/gc/z/test_zArray.cpp +++ b/test/hotspot/gtest/gc/z/test_zArray.cpp @@ -35,7 +35,7 @@ TEST(ZArray, sanity) { ZArray b; - b.transfer(&a); + b.swap(&a); // Check size ASSERT_EQ(a.length(), 0);