/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "memory/allocation.hpp"
#include "services/memPtr.hpp"
class MemPtr;
class MemRecorder;
class ArenaInfo;
class MemSnapshot;
extern "C" {
typedef int (*FN_SORT)(const void *, const void *);
}
// Memory pointer array interface. This array is used by NMT to hold
// various memory block information.
// The memory pointer arrays are usually walked with their iterators.
public:
virtual ~MemPointerArray() { }
// return true if it can not allocate storage for the data
virtual bool out_of_memory() const = 0;
virtual bool is_empty() const = 0;
virtual bool is_full() = 0;
virtual int length() const = 0;
virtual void clear() = 0;
virtual size_t instance_size() const = 0;
virtual bool shrink() = 0;
NOT_PRODUCT(virtual int capacity() const = 0;)
};
// Iterator interface
public:
// return the pointer at current position
virtual MemPointer* current() const = 0;
// return the next pointer and advance current position
virtual MemPointer* next() = 0;
// return next pointer without advancing current position
virtual MemPointer* peek_next() const = 0;
// return previous pointer without changing current position
virtual MemPointer* peek_prev() const = 0;
// remove the pointer at current position
virtual void remove() = 0;
// insert the pointer at current position
// insert specified element after current position and
// move current position to newly inserted position
};
// implementation class
protected:
int _pos;
public:
_pos = 0;
}
}
return NULL;
}
}
return NULL;
}
}
return NULL;
}
if (_pos > 0) {
}
return NULL;
}
virtual void remove() {
}
}
}
_pos ++;
return true;
}
return false;
}
};
// Memory pointer array implementation.
// This implementation implements expandable array
private:
int _max_size;
int _size;
bool _init_elements;
E* _data;
public:
if (_init_elements) {
}
}
}
virtual ~MemPointerArrayImpl() {
}
}
public:
bool out_of_memory() const {
}
return sizeof(MemPointerArrayImpl<E>) + _max_size * sizeof(E);
}
bool is_empty() const {
return _size == 0;
}
bool is_full() {
return false;
} else {
return !expand_array();
}
}
int length() const {
return _size;
}
void clear() {
_size = 0;
}
if (is_full()) {
return false;
}
return true;
}
if (is_full()) {
return false;
}
}
_size ++;
return true;
}
return false;
}
-- _size;
}
return true;
}
}
bool shrink() {
if (used < 0.40) {
return false;
} else {
return true;
}
}
return false;
}
}
private:
bool expand_array() {
return false;
} else {
if (_init_elements) {
}
}
return true;
}
}
}
}
}
};
#endif // SHARE_VM_UTILITIES_MEM_PTR_ARRAY_HPP