mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com> Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com> Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com> Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
This commit is contained in:
parent
36eee7c8c8
commit
5c58d27aac
853 changed files with 26124 additions and 82956 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/metaspace.hpp"
|
||||
|
||||
// correct linkage required to compile w/o warnings
|
||||
// (must be on file level - cannot be local)
|
||||
|
@ -97,6 +98,10 @@ template <MEMFLAGS F>class CHeapArray: public CHeapObj<F> {
|
|||
_data = (void*) NEW_C_HEAP_ARRAY(char *, esize * length, F);
|
||||
}
|
||||
|
||||
void initialize(size_t esize, int length) {
|
||||
// In debug set array to 0?
|
||||
}
|
||||
|
||||
#ifdef ASSERT
|
||||
void init_nesting();
|
||||
#endif
|
||||
|
@ -123,7 +128,7 @@ template <MEMFLAGS F>class CHeapArray: public CHeapObj<F> {
|
|||
public: \
|
||||
/* creation */ \
|
||||
array_name() : base_class() {} \
|
||||
array_name(const int length) : base_class(esize, length) {} \
|
||||
explicit array_name(const int length) : base_class(esize, length) {} \
|
||||
array_name(const int length, const etype fx) { initialize(length, fx); } \
|
||||
void initialize(const int length) { base_class::initialize(esize, length); } \
|
||||
void initialize(const int length, const etype fx) { \
|
||||
|
@ -292,4 +297,96 @@ template <MEMFLAGS F>class CHeapArray: public CHeapObj<F> {
|
|||
define_array(boolArray, bool) define_stack(boolStack, boolArray)
|
||||
define_array(intArray , int ) define_stack(intStack , intArray )
|
||||
|
||||
// Array for metadata allocation
|
||||
|
||||
template <typename T>
|
||||
class Array: public MetaspaceObj {
|
||||
friend class MetadataFactory;
|
||||
friend class VMStructs;
|
||||
friend class MethodHandleCompiler; // special case
|
||||
protected:
|
||||
int _length; // the number of array elements
|
||||
T _data[1]; // the array memory
|
||||
|
||||
void initialize(int length) {
|
||||
_length = length;
|
||||
}
|
||||
|
||||
private:
|
||||
// Turn off copy constructor and assignment operator.
|
||||
Array(const Array<T>&);
|
||||
void operator=(const Array<T>&);
|
||||
|
||||
void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) {
|
||||
size_t word_size = Array::size(length);
|
||||
return (void*) Metaspace::allocate(loader_data, word_size, read_only,
|
||||
Metaspace::NonClassType, CHECK_NULL);
|
||||
}
|
||||
|
||||
static size_t byte_sizeof(int length) { return sizeof(Array<T>) + MAX2(length - 1, 0) * sizeof(T); }
|
||||
|
||||
explicit Array(int length) : _length(length) {
|
||||
assert(length >= 0, "illegal length");
|
||||
}
|
||||
|
||||
Array(int length, T init) : _length(length) {
|
||||
assert(length >= 0, "illegal length");
|
||||
for (int i = 0; i < length; i++) {
|
||||
_data[i] = init;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// standard operations
|
||||
int length() const { return _length; }
|
||||
T* data() { return _data; }
|
||||
bool is_empty() const { return length() == 0; }
|
||||
|
||||
int index_of(const T& x) const {
|
||||
int i = length();
|
||||
while (i-- > 0 && _data[i] != x) ;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// sort the array.
|
||||
bool contains(const T& x) const { return index_of(x) >= 0; }
|
||||
|
||||
T at(int i) const { return _data[i]; }
|
||||
void at_put(const int i, const T& x) { _data[i] = x; }
|
||||
T* adr_at(const int i) { return &_data[i]; }
|
||||
int find(const T& x) { return index_of(x); }
|
||||
|
||||
T at_acquire(const int which) { return OrderAccess::load_acquire(adr_at(which)); }
|
||||
void release_at_put(int which, T contents) { OrderAccess::release_store(adr_at(which), contents); }
|
||||
|
||||
static int size(int length) {
|
||||
return align_size_up(byte_sizeof(length), BytesPerWord) / BytesPerWord;
|
||||
}
|
||||
|
||||
int size() {
|
||||
return size(_length);
|
||||
}
|
||||
|
||||
static int length_offset_in_bytes() { return (int) (offset_of(Array<T>, _length)); }
|
||||
// Note, this offset don't have to be wordSize aligned.
|
||||
static int base_offset_in_bytes() { return (int) (offset_of(Array<T>, _data)); };
|
||||
|
||||
// FIXME: How to handle this?
|
||||
void print_value_on(outputStream* st) const {
|
||||
st->print("Array<T>(" INTPTR_FORMAT ")", this);
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void print(outputStream* st) {
|
||||
for (int i = 0; i< _length; i++) {
|
||||
st->print_cr("%d: " INTPTR_FORMAT, i, (intptr_t)at(i));
|
||||
}
|
||||
}
|
||||
void print() { print(tty); }
|
||||
#endif // PRODUCT
|
||||
};
|
||||
|
||||
|
||||
#endif // SHARE_VM_UTILITIES_ARRAY_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue