--- old/src/hotspot/share/gc/z/zArray.inline.hpp 2020-06-17 15:03:20.802795526 +0200 +++ new/src/hotspot/share/gc/z/zArray.inline.hpp 2020-06-17 15:03:20.618792431 +0200 @@ -30,67 +30,17 @@ template inline ZArray::ZArray() : - _array(NULL), - _size(0), - _capacity(0) {} - -template -inline ZArray::~ZArray() { - FREE_C_HEAP_ARRAY(T, _array); -} - -template -inline size_t ZArray::size() const { - return _size; -} - -template -inline bool ZArray::is_empty() const { - return size() == 0; -} - -template -inline T ZArray::at(size_t index) const { - assert(index < _size, "Index out of bounds"); - return _array[index]; -} - -template -inline void ZArray::expand(size_t new_capacity) { - T* new_array = NEW_C_HEAP_ARRAY(T, new_capacity, mtGC); - if (_array != NULL) { - memcpy(new_array, _array, sizeof(T) * _capacity); - FREE_C_HEAP_ARRAY(T, _array); - } - - _array = new_array; - _capacity = new_capacity; -} - -template -inline void ZArray::add(T value) { - if (_size == _capacity) { - const size_t new_capacity = (_capacity > 0) ? _capacity * 2 : initial_capacity; - expand(new_capacity); - } - - _array[_size++] = value; -} + GrowableArrayCHeap(0) {} template inline void ZArray::transfer(ZArray* from) { - assert(_array == NULL, "Should be empty"); - _array = from->_array; - _size = from->_size; - _capacity = from->_capacity; - from->_array = NULL; - from->_size = 0; - from->_capacity = 0; -} - -template -inline void ZArray::clear() { - _size = 0; + 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 @@ -101,13 +51,13 @@ template inline bool ZArrayIteratorImpl::next(T* elem) { if (parallel) { - const size_t next = Atomic::fetch_and_add(&_next, 1u); - if (next < _array->size()) { + const int next = Atomic::fetch_and_add(&_next, 1); + if (next < _array->length()) { *elem = _array->at(next); return true; } } else { - if (_next < _array->size()) { + if (_next < _array->length()) { *elem = _array->at(_next++); return true; }