< prev index next >
src/share/vm/oops/array.hpp
Print this page
@@ -33,10 +33,11 @@
// Array for metadata allocation
template <typename T>
class Array: public MetaspaceObj {
friend class MetadataFactory;
+ friend class MetaspaceShared;
friend class VMStructs;
friend class JVMCIVMStructs;
friend class MethodHandleCompiler; // special case
friend class WhiteBox;
protected:
@@ -50,17 +51,20 @@
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) throw() {
+ void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() {
size_t word_size = Array::size(length);
- return (void*) Metaspace::allocate(loader_data, word_size, read_only,
+ return (void*) Metaspace::allocate(loader_data, word_size,
MetaspaceObj::array_type(sizeof(T)), THREAD);
}
- static size_t byte_sizeof(int length) { return sizeof(Array<T>) + MAX2(length - 1, 0) * sizeof(T); }
+ static size_t byte_sizeof(int length, size_t elm_byte_size) {
+ return sizeof(Array<T>) + MAX2(length - 1, 0) * elm_byte_size;
+ }
+ static size_t byte_sizeof(int length) { return byte_sizeof(length, sizeof(T)); }
// WhiteBox API helper.
// Can't distinguish between array of length 0 and length 1,
// will always return 0 in those cases.
static int bytes_to_length(size_t bytes) {
@@ -122,10 +126,13 @@
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;
}
+ static int size(int length, int elm_byte_size) {
+ return align_size_up(byte_sizeof(length, elm_byte_size), BytesPerWord) / BytesPerWord;
+ }
int size() {
return size(_length);
}
< prev index next >