Top


定義場所(file name)

hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp

名前(function name)

  bool doHeapRegion(HeapRegion* r) {

本体部(body)

  {- -------------------------------------------
  (1) (assert)
      ---------------------------------------- -}

        assert(r->in_collection_set(), "should only be called on elements of CS.");

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

        HeapRegionRemSet* hrrs = r->rem_set();
        if (hrrs->iter_is_complete()) return false; // All done.
        if (!_try_claimed && !hrrs->claim_iter()) return false;
        // If we ever free the collection set concurrently, we should also
        // clear the card table concurrently therefore we won't need to
        // add regions of the collection set to the dirty cards region.
        _g1h->push_dirty_cards_region(r);
        // If we didn't return above, then
        //   _try_claimed || r->claim_iter()
        // is true: either we're supposed to work on claimed-but-not-complete
        // regions, or we successfully claimed the region.
        HeapRegionRemSetIterator* iter = _g1h->rem_set_iterator(_worker_i);
        hrrs->init_iterator(iter);
        size_t card_index;

        // We claim cards in block so as to recude the contention. The block size is determined by
        // the G1RSetScanBlockSize parameter.
        size_t jump_to_card = hrrs->iter_claimed_next(_block_size);
        for (size_t current_card = 0; iter->has_next(card_index); current_card++) {
          if (current_card >= jump_to_card + _block_size) {
            jump_to_card = hrrs->iter_claimed_next(_block_size);
          }
          if (current_card < jump_to_card) continue;
          HeapWord* card_start = _g1h->bot_shared()->address_for_index(card_index);
    #if 0
          gclog_or_tty->print("Rem set iteration yielded card [" PTR_FORMAT ", " PTR_FORMAT ").\n",
                              card_start, card_start + CardTableModRefBS::card_size_in_words);
    #endif

          HeapRegion* card_region = _g1h->heap_region_containing(card_start);
          assert(card_region != NULL, "Yielding cards not in the heap?");
          _cards++;

          if (!card_region->is_on_dirty_cards_region_list()) {
            _g1h->push_dirty_cards_region(card_region);
          }

          // If the card is dirty, then we will scan it during updateRS.
          if (!card_region->in_collection_set() &&
              !_ct_bs->is_card_dirty(card_index)) {
            scanCard(card_index, card_region);
          }
        }
        if (!_try_claimed) {
          hrrs->set_iter_complete();
        }
        return false;
      }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.