Print this page
rev 2896 : 6484965: G1: piggy-back liveness accounting phase on marking
Summary: Remove the separate counting phase of concurrent marking by tracking the amount of marked bytes and the cards spanned by marked objects in marking task/worker thread local data structures, which are updated as individual objects are marked.
Reviewed-by: brutisso

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
          +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
↓ open down ↓ 854 lines elided ↑ open up ↑
 855  855    // Do any necessary initialization for evacuation-failure handling.
 856  856    // "cl" is the closure that will be used to process evac-failure
 857  857    // objects.
 858  858    void init_for_evac_failure(OopsInHeapRegionClosure* cl);
 859  859    // Do any necessary cleanup for evacuation-failure handling data
 860  860    // structures.
 861  861    void finalize_for_evac_failure();
 862  862  
 863  863    // An attempt to evacuate "obj" has failed; take necessary steps.
 864  864    oop handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, oop obj,
 865      -                                    bool should_mark_root);
      865 +                                    bool should_mark_root,
      866 +                                    int worker_i);
 866  867    void handle_evacuation_failure_common(oop obj, markOop m);
 867  868  
 868  869    // ("Weak") Reference processing support.
 869  870    //
 870  871    // G1 has 2 instances of the referece processor class. One
 871  872    // (_ref_processor_cm) handles reference object discovery
 872  873    // and subsequent processing during concurrent marking cycles.
 873  874    //
 874  875    // The other (_ref_processor_stw) handles reference object
 875  876    // discovery and processing during full GCs and incremental
↓ open down ↓ 847 lines elided ↑ open up ↑
1723 1724    static size_t bitmap_size_in_bits(size_t gclab_word_size) {
1724 1725      size_t bits_in_bitmap = gclab_word_size >> shifter();
1725 1726      // We are going to ensure that the beginning of a word in this
1726 1727      // bitmap also corresponds to the beginning of a word in the
1727 1728      // global marking bitmap. To handle the case where a GCLab
1728 1729      // starts from the middle of the bitmap, we need to add enough
1729 1730      // space (i.e. up to a bitmap word) to ensure that we have
1730 1731      // enough bits in the bitmap.
1731 1732      return bits_in_bitmap + BitsPerWord - 1;
1732 1733    }
     1734 +
1733 1735  public:
1734 1736    GCLabBitMap(HeapWord* heap_start, size_t gclab_word_size)
1735 1737      : BitMap(bitmap_size_in_bits(gclab_word_size)),
1736 1738        _cm(G1CollectedHeap::heap()->concurrent_mark()),
1737 1739        _shifter(shifter()),
1738 1740        _bitmap_word_covers_words(bitmap_word_covers_words()),
1739 1741        _heap_start(heap_start),
1740 1742        _gclab_word_size(gclab_word_size),
1741 1743        _real_start_word(NULL),
1742 1744        _real_end_word(NULL),
↓ open down ↓ 69 lines elided ↑ open up ↑
1812 1814    }
1813 1815  
1814 1816  #ifndef PRODUCT
1815 1817    void verify() {
1816 1818      // verify that the marks have been propagated
1817 1819      GCLabBitMapClosure cl(_cm, this);
1818 1820      iterate(&cl);
1819 1821    }
1820 1822  #endif // PRODUCT
1821 1823  
1822      -  void retire() {
1823      -    guarantee(use_local_bitmaps, "invariant");
1824      -    assert(fields_well_formed(), "invariant");
1825      -
1826      -    if (_start_word != NULL) {
1827      -      CMBitMap*       mark_bitmap = _cm->nextMarkBitMap();
1828      -
1829      -      // this means that the bitmap was set up for the GCLab
1830      -      assert(_real_start_word != NULL && _real_end_word != NULL, "invariant");
1831      -
1832      -      mark_bitmap->mostly_disjoint_range_union(this,
1833      -                                0, // always start from the start of the bitmap
1834      -                                _start_word,
1835      -                                gclab_real_word_size());
1836      -      _cm->grayRegionIfNecessary(MemRegion(_real_start_word, _real_end_word));
1837      -
1838      -#ifndef PRODUCT
1839      -      if (use_local_bitmaps && verify_local_bitmaps)
1840      -        verify();
1841      -#endif // PRODUCT
1842      -    } else {
1843      -      assert(_real_start_word == NULL && _real_end_word == NULL, "invariant");
1844      -    }
1845      -  }
     1824 +  void retire(int worker_i);
1846 1825  
1847 1826    size_t bitmap_size_in_words() const {
1848 1827      return (bitmap_size_in_bits(gclab_word_size()) + BitsPerWord - 1) / BitsPerWord;
1849 1828    }
1850 1829  
1851 1830  };
1852 1831  
1853 1832  class G1ParGCAllocBuffer: public ParGCAllocBuffer {
1854 1833  private:
1855 1834    bool        _retired;
1856 1835    bool        _should_mark_objects;
1857 1836    GCLabBitMap _bitmap;
     1837 +  int         _worker_i;
1858 1838  
1859 1839  public:
1860      -  G1ParGCAllocBuffer(size_t gclab_word_size);
     1840 +  G1ParGCAllocBuffer(size_t gclab_word_size, int worker_i);
1861 1841  
1862 1842    inline bool mark(HeapWord* addr) {
1863 1843      guarantee(use_local_bitmaps, "invariant");
1864 1844      assert(_should_mark_objects, "invariant");
1865 1845      return _bitmap.mark(addr);
1866 1846    }
1867 1847  
1868 1848    inline void set_buf(HeapWord* buf) {
1869 1849      if (use_local_bitmaps && _should_mark_objects) {
1870 1850        _bitmap.set_buffer(buf);
1871 1851      }
1872 1852      ParGCAllocBuffer::set_buf(buf);
1873 1853      _retired = false;
1874 1854    }
1875 1855  
1876 1856    inline void retire(bool end_of_gc, bool retain) {
1877 1857      if (_retired)
1878 1858        return;
1879 1859      if (use_local_bitmaps && _should_mark_objects) {
1880      -      _bitmap.retire();
     1860 +      _bitmap.retire(_worker_i);
1881 1861      }
1882 1862      ParGCAllocBuffer::retire(end_of_gc, retain);
1883 1863      _retired = true;
1884 1864    }
1885 1865  };
1886 1866  
1887 1867  class G1ParScanThreadState : public StackObj {
1888 1868  protected:
1889 1869    G1CollectedHeap* _g1h;
1890 1870    RefToScanQueue*  _refs;
↓ open down ↓ 225 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX