< prev index next >

src/hotspot/share/oops/array.hpp

Print this page

 38   friend class ArchiveBuilder;
 39   friend class MetadataFactory;
 40   friend class VMStructs;
 41   friend class JVMCIVMStructs;
 42   friend class MethodHandleCompiler;           // special case
 43   friend class WhiteBox;
 44   friend class FieldInfoStream;
 45 protected:
 46   int _length;                                 // the number of array elements
 47   T   _data[1];                                // the array memory
 48 
 49   void initialize(int length) {
 50     _length = length;
 51   }
 52 
 53  private:
 54   NONCOPYABLE(Array);
 55 
 56   inline void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw();
 57 


 58   static size_t byte_sizeof(int length, size_t elm_byte_size) {
 59     return sizeof(Array<T>) + MAX2(length - 1, 0) * elm_byte_size;
 60   }
 61   static size_t byte_sizeof(int length) { return byte_sizeof(length, sizeof(T)); }
 62 
 63   // WhiteBox API helper.
 64   // Can't distinguish between array of length 0 and length 1,
 65   // will always return 0 in those cases.
 66   static int bytes_to_length(size_t bytes)       {
 67     assert(is_aligned(bytes, BytesPerWord), "Must be, for now");
 68 
 69     if (sizeof(Array<T>) >= bytes) {
 70       return 0;
 71     }
 72 
 73     size_t left = bytes - sizeof(Array<T>);
 74     assert(is_aligned(left, sizeof(T)), "Must be");
 75 
 76     size_t elements = left / sizeof(T);
 77     assert(elements <= (size_t)INT_MAX, "number of elements " SIZE_FORMAT "doesn't fit into an int.", elements);

 38   friend class ArchiveBuilder;
 39   friend class MetadataFactory;
 40   friend class VMStructs;
 41   friend class JVMCIVMStructs;
 42   friend class MethodHandleCompiler;           // special case
 43   friend class WhiteBox;
 44   friend class FieldInfoStream;
 45 protected:
 46   int _length;                                 // the number of array elements
 47   T   _data[1];                                // the array memory
 48 
 49   void initialize(int length) {
 50     _length = length;
 51   }
 52 
 53  private:
 54   NONCOPYABLE(Array);
 55 
 56   inline void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw();
 57 
 58   inline void* operator new(size_t size, ClassLoaderData* loader_data, int length) throw();
 59 
 60   static size_t byte_sizeof(int length, size_t elm_byte_size) {
 61     return sizeof(Array<T>) + MAX2(length - 1, 0) * elm_byte_size;
 62   }
 63   static size_t byte_sizeof(int length) { return byte_sizeof(length, sizeof(T)); }
 64 
 65   // WhiteBox API helper.
 66   // Can't distinguish between array of length 0 and length 1,
 67   // will always return 0 in those cases.
 68   static int bytes_to_length(size_t bytes)       {
 69     assert(is_aligned(bytes, BytesPerWord), "Must be, for now");
 70 
 71     if (sizeof(Array<T>) >= bytes) {
 72       return 0;
 73     }
 74 
 75     size_t left = bytes - sizeof(Array<T>);
 76     assert(is_aligned(left, sizeof(T)), "Must be");
 77 
 78     size_t elements = left / sizeof(T);
 79     assert(elements <= (size_t)INT_MAX, "number of elements " SIZE_FORMAT "doesn't fit into an int.", elements);
< prev index next >