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

G1 concurrent marking checks mark bit twice

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 9
    • hotspot
    • gc
    • generic
    • generic

      In deal_with_reference we have code that looks something like

        if (!_nextMarkBitMap->isMarked(objAddr)) {
          HeapRegion* hr= _g1h->heap_region_containing_raw(obj);
          if (!hr->obj_allocated_since_next_marking(obj)) {
            if (_cm->par_mark_and_count(obj, ...)) {
              ...

      Similarly, in grayRoot we have

        if (!_nextMarkBitMap->isMarked(addr)) {
          par_mark_and_count(obj, ...);
        }

      But par_mark_and_count calls _nextBitMap->parMark(addr), which calls par_set_bit on the underlying BitMap. And par_set_bit first tests whether the mark bit is already set, avoiding the CAS operation if so.

      So the outer tests of the mark bit appear to be unnecessary and just waste time.

            Unassigned Unassigned
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: