mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8048248: G1 Class Unloading after completing a concurrent mark cycle
Reviewed-by: tschatzl, ehelin, brutisso, coleenp, roland, iveresov
This commit is contained in:
parent
b0138be158
commit
8c3aced316
75 changed files with 2169 additions and 874 deletions
|
@ -305,6 +305,7 @@ class Array: public MetaspaceObj {
|
|||
friend class MetadataFactory;
|
||||
friend class VMStructs;
|
||||
friend class MethodHandleCompiler; // special case
|
||||
friend class WhiteBox;
|
||||
protected:
|
||||
int _length; // the number of array elements
|
||||
T _data[1]; // the array memory
|
||||
|
@ -326,6 +327,29 @@ protected:
|
|||
|
||||
static size_t byte_sizeof(int length) { return sizeof(Array<T>) + MAX2(length - 1, 0) * sizeof(T); }
|
||||
|
||||
// WhiteBox API helper.
|
||||
static int bytes_to_length(size_t bytes) {
|
||||
assert(is_size_aligned(bytes, BytesPerWord), "Must be, for now");
|
||||
|
||||
if (sizeof(Array<T>) >= bytes) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t left = bytes - sizeof(Array<T>);
|
||||
assert(is_size_aligned(left, sizeof(T)), "Must be");
|
||||
|
||||
size_t elements = left / sizeof(T);
|
||||
assert(elements <= (size_t)INT_MAX, err_msg("number of elements " SIZE_FORMAT "doesn't fit into an int.", elements));
|
||||
|
||||
int length = (int)elements;
|
||||
|
||||
assert((size_t)size(length) * BytesPerWord == bytes,
|
||||
err_msg("Expected: " SIZE_FORMAT " got: " SIZE_FORMAT,
|
||||
bytes, (size_t)size(length) * BytesPerWord));
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
explicit Array(int length) : _length(length) {
|
||||
assert(length >= 0, "illegal length");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue