106
107 inline HeapWord*
108 G1BlockOffsetArray::block_at_or_preceding(const void* addr,
109 bool has_max_index,
110 size_t max_index) const {
111 assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
112 size_t index = _array->index_for(addr);
113 // We must make sure that the offset table entry we use is valid. If
114 // "addr" is past the end, start at the last known one and go forward.
115 if (has_max_index) {
116 index = MIN2(index, max_index);
117 }
118 HeapWord* q = _array->address_for_index(index);
119
120 uint offset = _array->offset_array(index); // Extend u_char to uint.
121 while (offset >= N_words) {
122 // The excess of the offset from N_words indicates a power of Base
123 // to go back by.
124 size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset);
125 q -= (N_words * n_cards_back);
126 assert(q >= gsp()->bottom(), "Went below bottom!");
127 index -= n_cards_back;
128 offset = _array->offset_array(index);
129 }
130 assert(offset < N_words, "offset too large");
131 q -= offset;
132 return q;
133 }
134
135 inline HeapWord*
136 G1BlockOffsetArray::
137 forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
138 const void* addr) const {
139 if (addr >= gsp()->top()) return gsp()->top();
140 while (n <= addr) {
141 q = n;
142 oop obj = oop(q);
143 if (obj->klass_or_null() == NULL) return q;
144 n += block_size(q);
145 }
146 assert(q <= n, "wrong order for q and addr");
|
106
107 inline HeapWord*
108 G1BlockOffsetArray::block_at_or_preceding(const void* addr,
109 bool has_max_index,
110 size_t max_index) const {
111 assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
112 size_t index = _array->index_for(addr);
113 // We must make sure that the offset table entry we use is valid. If
114 // "addr" is past the end, start at the last known one and go forward.
115 if (has_max_index) {
116 index = MIN2(index, max_index);
117 }
118 HeapWord* q = _array->address_for_index(index);
119
120 uint offset = _array->offset_array(index); // Extend u_char to uint.
121 while (offset >= N_words) {
122 // The excess of the offset from N_words indicates a power of Base
123 // to go back by.
124 size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset);
125 q -= (N_words * n_cards_back);
126 index -= n_cards_back;
127 offset = _array->offset_array(index);
128 }
129 assert(offset < N_words, "offset too large");
130 q -= offset;
131 return q;
132 }
133
134 inline HeapWord*
135 G1BlockOffsetArray::
136 forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
137 const void* addr) const {
138 if (addr >= gsp()->top()) return gsp()->top();
139 while (n <= addr) {
140 q = n;
141 oop obj = oop(q);
142 if (obj->klass_or_null() == NULL) return q;
143 n += block_size(q);
144 }
145 assert(q <= n, "wrong order for q and addr");
|