Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8278139

G1: Refactor G1BlockOffsetTablePart::block_at_or_preceding

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 18
    • 18
    • hotspot
    • gc
    • b27

    Description

      ```
        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.

      Attachments

        Issue Links

          Activity

            People

              ayang Albert Yang
              ayang Albert Yang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: