48 // The header is considered the oop part of this type plus the length.
49 // Returns the aligned header_size_in_bytes. This is not equivalent to
50 // sizeof(arrayOopDesc) which should not appear in the code.
51 static int header_size_in_bytes() {
52 size_t hs = align_size_up(length_offset_in_bytes() + sizeof(int),
53 HeapWordSize);
54 #ifdef ASSERT
55 // make sure it isn't called before UseCompressedOops is initialized.
56 static size_t arrayoopdesc_hs = 0;
57 if (arrayoopdesc_hs == 0) arrayoopdesc_hs = hs;
58 assert(arrayoopdesc_hs == hs, "header size can't change");
59 #endif // ASSERT
60 return (int)hs;
61 }
62
63 public:
64 // The _length field is not declared in C++. It is allocated after the
65 // declared nonstatic fields in arrayOopDesc if not compressed, otherwise
66 // it occupies the second half of the _klass field in oopDesc.
67 static int length_offset_in_bytes() {
68 return UseCompressedKlassPointers ? klass_gap_offset_in_bytes() :
69 sizeof(arrayOopDesc);
70 }
71
72 // Returns the offset of the first element.
73 static int base_offset_in_bytes(BasicType type) {
74 return header_size(type) * HeapWordSize;
75 }
76
77 // Returns the address of the first element.
78 void* base(BasicType type) const {
79 return (void*) (((intptr_t) this) + base_offset_in_bytes(type));
80 }
81
82 // Tells whether index is within bounds.
83 bool is_within_bounds(int index) const { return 0 <= index && index < length(); }
84
85 // Accessors for instance variable which is not a C++ declared nonstatic
86 // field.
87 int length() const {
88 return *(int*)(((intptr_t)this) + length_offset_in_bytes());
|
48 // The header is considered the oop part of this type plus the length.
49 // Returns the aligned header_size_in_bytes. This is not equivalent to
50 // sizeof(arrayOopDesc) which should not appear in the code.
51 static int header_size_in_bytes() {
52 size_t hs = align_size_up(length_offset_in_bytes() + sizeof(int),
53 HeapWordSize);
54 #ifdef ASSERT
55 // make sure it isn't called before UseCompressedOops is initialized.
56 static size_t arrayoopdesc_hs = 0;
57 if (arrayoopdesc_hs == 0) arrayoopdesc_hs = hs;
58 assert(arrayoopdesc_hs == hs, "header size can't change");
59 #endif // ASSERT
60 return (int)hs;
61 }
62
63 public:
64 // The _length field is not declared in C++. It is allocated after the
65 // declared nonstatic fields in arrayOopDesc if not compressed, otherwise
66 // it occupies the second half of the _klass field in oopDesc.
67 static int length_offset_in_bytes() {
68 return UseCompressedClassPointers ? klass_gap_offset_in_bytes() :
69 sizeof(arrayOopDesc);
70 }
71
72 // Returns the offset of the first element.
73 static int base_offset_in_bytes(BasicType type) {
74 return header_size(type) * HeapWordSize;
75 }
76
77 // Returns the address of the first element.
78 void* base(BasicType type) const {
79 return (void*) (((intptr_t) this) + base_offset_in_bytes(type));
80 }
81
82 // Tells whether index is within bounds.
83 bool is_within_bounds(int index) const { return 0 <= index && index < length(); }
84
85 // Accessors for instance variable which is not a C++ declared nonstatic
86 // field.
87 int length() const {
88 return *(int*)(((intptr_t)this) + length_offset_in_bytes());
|