```
HeapWord* q = _bot->address_for_index(index); <--- init of q
uint offset = _bot->offset_array(index); // Extend u_char to uint.
while (offset >= BOTConstants::N_words) {
// The excess of the offset from N_words indicates a power of Base
// to go back by.
size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
q -= (BOTConstants::N_words * n_cards_back); <--- keep q in sync
index -= n_cards_back;
offset = _bot->offset_array(index);
}
```
`G1BlockOffsetTablePart::block_at_or_preceding` identifies the value (`offset`) and the address (`q`) of the "offset card". The final result is just `q - offset`. Because the "block start" can be many cards before, it iterates backwards on the cards array to locate the "offset card". Along the way, `q` mirrors the current card. However, there's 1:1 mapping btw `q` and the current card. Therefore, one can derive `q` once the "offset card" is identified, instead of calculating `q` in the loop.
HeapWord* q = _bot->address_for_index(index); <--- init of q
uint offset = _bot->offset_array(index); // Extend u_char to uint.
while (offset >= BOTConstants::N_words) {
// The excess of the offset from N_words indicates a power of Base
// to go back by.
size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
q -= (BOTConstants::N_words * n_cards_back); <--- keep q in sync
index -= n_cards_back;
offset = _bot->offset_array(index);
}
```
`G1BlockOffsetTablePart::block_at_or_preceding` identifies the value (`offset`) and the address (`q`) of the "offset card". The final result is just `q - offset`. Because the "block start" can be many cards before, it iterates backwards on the cards array to locate the "offset card". Along the way, `q` mirrors the current card. However, there's 1:1 mapping btw `q` and the current card. Therefore, one can derive `q` once the "offset card" is identified, instead of calculating `q` in the loop.