|
32 | 32 | #include "runtime/atomic.hpp"
|
33 | 33 | #include "oops/oop.inline.hpp"
|
34 | 34 |
|
35 |
| -inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr, HeapWord* const pb) { |
| 35 | +inline HeapWord* G1BlockOffsetTablePart::block_start_reaching_into_card(const void* addr) const { |
36 | 36 | assert(addr >= _hr->bottom() && addr < _hr->top(), "invalid address");
|
37 |
| - HeapWord* q = block_at_or_preceding(addr); |
38 |
| - HeapWord* n = q + block_size(q, pb); |
39 |
| - return forward_to_block_containing_addr(q, n, addr, pb); |
| 37 | + |
| 38 | +#ifdef ASSERT |
| 39 | + if (!_hr->is_continues_humongous()) { |
| 40 | + // For non-ContinuesHumongous regions, the first obj always starts from bottom. |
| 41 | + u_char offset = _bot->offset_array(_bot->index_for(_hr->bottom())); |
| 42 | + assert(offset == 0, "Found offset %u instead of 0 for region %u %s", |
| 43 | + offset, _hr->hrm_index(), _hr->get_short_type_str()); |
| 44 | + } |
| 45 | +#endif |
| 46 | + |
| 47 | + size_t index = _bot->index_for(addr); |
| 48 | + |
| 49 | + uint offset = _bot->offset_array(index); |
| 50 | + while (offset >= BOTConstants::card_size_in_words()) { |
| 51 | + // The excess of the offset from N_words indicates a power of Base |
| 52 | + // to go back by. |
| 53 | + size_t n_cards_back = BOTConstants::entry_to_cards_back(offset); |
| 54 | + index -= n_cards_back; |
| 55 | + offset = _bot->offset_array(index); |
| 56 | + } |
| 57 | + assert(offset < BOTConstants::card_size_in_words(), "offset too large"); |
| 58 | + |
| 59 | + HeapWord* q = _bot->address_for_index(index); |
| 60 | + return q - offset; |
40 | 61 | }
|
41 | 62 |
|
42 | 63 | u_char G1BlockOffsetTable::offset_array(size_t index) const {
|
@@ -95,59 +116,4 @@ inline HeapWord* G1BlockOffsetTable::address_for_index(size_t index) const {
|
95 | 116 | return result;
|
96 | 117 | }
|
97 | 118 |
|
98 |
| -inline size_t G1BlockOffsetTablePart::block_size(const HeapWord* p) const { |
99 |
| - return _hr->block_size(p); |
100 |
| -} |
101 |
| - |
102 |
| -inline size_t G1BlockOffsetTablePart::block_size(const HeapWord* p, HeapWord* const pb) const { |
103 |
| - return _hr->block_size(p, pb); |
104 |
| -} |
105 |
| - |
106 |
| -inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr) const { |
107 |
| -#ifdef ASSERT |
108 |
| - if (!_hr->is_continues_humongous()) { |
109 |
| - // For non-ContinuesHumongous regions, the first obj always starts from bottom. |
110 |
| - u_char offset = _bot->offset_array(_bot->index_for(_hr->bottom())); |
111 |
| - assert(offset == 0, "Found offset %u instead of 0 for region %u %s", |
112 |
| - offset, _hr->hrm_index(), _hr->get_short_type_str()); |
113 |
| - } |
114 |
| -#endif |
115 |
| - |
116 |
| - size_t index = _bot->index_for(addr); |
117 |
| - |
118 |
| - uint offset = _bot->offset_array(index); // Extend u_char to uint. |
119 |
| - while (offset >= BOTConstants::card_size_in_words()) { |
120 |
| - // The excess of the offset from N_words indicates a power of Base |
121 |
| - // to go back by. |
122 |
| - size_t n_cards_back = BOTConstants::entry_to_cards_back(offset); |
123 |
| - index -= n_cards_back; |
124 |
| - offset = _bot->offset_array(index); |
125 |
| - } |
126 |
| - assert(offset < BOTConstants::card_size_in_words(), "offset too large"); |
127 |
| - |
128 |
| - HeapWord* q = _bot->address_for_index(index); |
129 |
| - return q - offset; |
130 |
| -} |
131 |
| - |
132 |
| -inline HeapWord* G1BlockOffsetTablePart::forward_to_block_containing_addr(HeapWord* q, HeapWord* n, |
133 |
| - const void* addr, |
134 |
| - HeapWord* const pb) const { |
135 |
| - while (n <= addr) { |
136 |
| - // When addr is not covered by the block starting at q we need to |
137 |
| - // step forward until we find the correct block. With the BOT |
138 |
| - // being precise, we should never have to step through more than |
139 |
| - // a single card. |
140 |
| - assert(_bot->index_for(n) == _bot->index_for(addr), |
141 |
| - "BOT not precise. Index for n: " SIZE_FORMAT " must be equal to the index for addr: " SIZE_FORMAT, |
142 |
| - _bot->index_for(n), _bot->index_for(addr)); |
143 |
| - q = n; |
144 |
| - assert(cast_to_oop(q)->klass_or_null() != nullptr, |
145 |
| - "start of block must be an initialized object"); |
146 |
| - n += block_size(q, pb); |
147 |
| - } |
148 |
| - assert(q <= addr, "wrong order for q and addr"); |
149 |
| - assert(addr < n, "wrong order for addr and n"); |
150 |
| - return q; |
151 |
| -} |
152 |
| - |
153 | 119 | #endif // SHARE_GC_G1_G1BLOCKOFFSETTABLE_INLINE_HPP
|
0 commit comments