comparison src/share/vm/oops/objArrayOop.hpp @ 1091:6aa7255741f3

6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
author ysr
date Thu, 03 Dec 2009 15:01:57 -0800
parents 89e0543e1737
children 7bfd295ec074
comparison
equal deleted inserted replaced
1090:fa357420e7d2 1091:6aa7255741f3
35 template <class T> T* obj_at_addr(int index) const { 35 template <class T> T* obj_at_addr(int index) const {
36 assert(is_within_bounds(index), "index out of bounds"); 36 assert(is_within_bounds(index), "index out of bounds");
37 return &((T*)base())[index]; 37 return &((T*)base())[index];
38 } 38 }
39 39
40 private:
41 // Give size of objArrayOop in HeapWords minus the header
42 static int array_size(int length) {
43 const int OopsPerHeapWord = HeapWordSize/heapOopSize;
44 assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0),
45 "Else the following (new) computation would be in error");
46 #ifdef ASSERT
47 // The old code is left in for sanity-checking; it'll
48 // go away pretty soon. XXX
49 // Without UseCompressedOops, this is simply:
50 // oop->length() * HeapWordsPerOop;
51 // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
52 // The oop elements are aligned up to wordSize
53 const int HeapWordsPerOop = heapOopSize/HeapWordSize;
54 int old_res;
55 if (HeapWordsPerOop > 0) {
56 old_res = length * HeapWordsPerOop;
57 } else {
58 old_res = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
59 }
60 #endif // ASSERT
61 int res = (length + OopsPerHeapWord - 1)/OopsPerHeapWord;
62 assert(res == old_res, "Inconsistency between old and new.");
63 return res;
64 }
65
40 public: 66 public:
41 // Returns the offset of the first element. 67 // Returns the offset of the first element.
42 static int base_offset_in_bytes() { 68 static int base_offset_in_bytes() {
43 return arrayOopDesc::base_offset_in_bytes(T_OBJECT); 69 return arrayOopDesc::base_offset_in_bytes(T_OBJECT);
44 } 70 }
65 } 91 }
66 } 92 }
67 // Sizing 93 // Sizing
68 static int header_size() { return arrayOopDesc::header_size(T_OBJECT); } 94 static int header_size() { return arrayOopDesc::header_size(T_OBJECT); }
69 int object_size() { return object_size(length()); } 95 int object_size() { return object_size(length()); }
70 int array_size() { return array_size(length()); }
71 96
72 static int object_size(int length) { 97 static int object_size(int length) {
73 // This returns the object size in HeapWords. 98 // This returns the object size in HeapWords.
74 return align_object_size(header_size() + array_size(length)); 99 return align_object_size(header_size() + array_size(length));
75 }
76
77 // Give size of objArrayOop in HeapWords minus the header
78 static int array_size(int length) {
79 // Without UseCompressedOops, this is simply:
80 // oop->length() * HeapWordsPerOop;
81 // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
82 // The oop elements are aligned up to wordSize
83 const int HeapWordsPerOop = heapOopSize/HeapWordSize;
84 if (HeapWordsPerOop > 0) {
85 return length * HeapWordsPerOop;
86 } else {
87 const int OopsPerHeapWord = HeapWordSize/heapOopSize;
88 int word_len = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
89 return word_len;
90 }
91 } 100 }
92 101
93 // special iterators for index ranges, returns size of object 102 // special iterators for index ranges, returns size of object
94 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ 103 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
95 int oop_iterate_range(OopClosureType* blk, int start, int end); 104 int oop_iterate_range(OopClosureType* blk, int start, int end);