8254878: Move last piece of ZArray to GrowableArray
Reviewed-by: stefank, eosterlund
This commit is contained in:
parent
294e0705fa
commit
cdc8c401b5
src/hotspot/share
test/hotspot/gtest/gc/z
@ -25,16 +25,9 @@
|
||||
#define SHARE_GC_Z_ZARRAY_HPP
|
||||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
|
||||
template <typename T>
|
||||
class ZArray : public GrowableArrayCHeap<T, mtGC> {
|
||||
public:
|
||||
ZArray();
|
||||
|
||||
void transfer(ZArray<T>* from);
|
||||
};
|
||||
template <typename T> using ZArray = GrowableArrayCHeap<T, mtGC>;
|
||||
|
||||
template <typename T, bool parallel>
|
||||
class ZArrayIteratorImpl : public StackObj {
|
||||
|
@ -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 <typename T>
|
||||
inline ZArray<T>::ZArray() :
|
||||
GrowableArrayCHeap<T, mtGC>(0) {}
|
||||
|
||||
template <typename T>
|
||||
inline void ZArray<T>::transfer(ZArray<T>* 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 <typename T, bool parallel>
|
||||
inline ZArrayIteratorImpl<T, parallel>::ZArrayIteratorImpl(ZArray<T>* array) :
|
||||
_array(array),
|
||||
|
@ -69,7 +69,7 @@ void ZSafeDeleteImpl<T>::disable_deferred_delete() {
|
||||
ZLocker<ZLock> locker(_lock);
|
||||
assert(_enabled > 0, "Invalid state");
|
||||
if (--_enabled == 0) {
|
||||
deferred.transfer(&_deferred);
|
||||
deferred.swap(&_deferred);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,6 +435,12 @@ public:
|
||||
return this->at(location);
|
||||
}
|
||||
|
||||
void swap(GrowableArrayWithAllocator<E, Derived>* 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<E, GrowableArrayCHe
|
||||
}
|
||||
|
||||
public:
|
||||
GrowableArrayCHeap(int initial_max) :
|
||||
GrowableArrayCHeap(int initial_max = 0) :
|
||||
GrowableArrayWithAllocator<E, GrowableArrayCHeap<E, F> >(
|
||||
allocate(initial_max, F),
|
||||
initial_max) {}
|
||||
|
@ -35,7 +35,7 @@ TEST(ZArray, sanity) {
|
||||
|
||||
ZArray<int> b;
|
||||
|
||||
b.transfer(&a);
|
||||
b.swap(&a);
|
||||
|
||||
// Check size
|
||||
ASSERT_EQ(a.length(), 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user