< prev index next >

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Print this page




1889 void G1ConcurrentMark::clear_range_in_prev_bitmap(MemRegion mr) {
1890   _prev_mark_bitmap->clear_range(mr);
1891 }
1892 
1893 HeapRegion*
1894 G1ConcurrentMark::claim_region(uint worker_id) {
1895   // "checkpoint" the finger
1896   HeapWord* finger = _finger;
1897 
1898   while (finger < _heap.end()) {
1899     assert(_g1h->is_in_g1_reserved(finger), "invariant");
1900 
1901     HeapRegion* curr_region = _g1h->heap_region_containing(finger);
1902     // Make sure that the reads below do not float before loading curr_region.
1903     OrderAccess::loadload();
1904     // Above heap_region_containing may return NULL as we always scan claim
1905     // until the end of the heap. In this case, just jump to the next region.
1906     HeapWord* end = curr_region != NULL ? curr_region->end() : finger + HeapRegion::GrainWords;
1907 
1908     // Is the gap between reading the finger and doing the CAS too long?
1909     HeapWord* res = Atomic::cmpxchg(end, &_finger, finger);
1910     if (res == finger && curr_region != NULL) {
1911       // we succeeded
1912       HeapWord*   bottom        = curr_region->bottom();
1913       HeapWord*   limit         = curr_region->next_top_at_mark_start();
1914 
1915       // notice that _finger == end cannot be guaranteed here since,
1916       // someone else might have moved the finger even further
1917       assert(_finger >= end, "the finger should have moved forward");
1918 
1919       if (limit > bottom) {
1920         return curr_region;
1921       } else {
1922         assert(limit == bottom,
1923                "the region limit should be at bottom");
1924         // we return NULL and the caller should try calling
1925         // claim_region() again.
1926         return NULL;
1927       }
1928     } else {
1929       assert(_finger > finger, "the finger should have moved forward");




1889 void G1ConcurrentMark::clear_range_in_prev_bitmap(MemRegion mr) {
1890   _prev_mark_bitmap->clear_range(mr);
1891 }
1892 
1893 HeapRegion*
1894 G1ConcurrentMark::claim_region(uint worker_id) {
1895   // "checkpoint" the finger
1896   HeapWord* finger = _finger;
1897 
1898   while (finger < _heap.end()) {
1899     assert(_g1h->is_in_g1_reserved(finger), "invariant");
1900 
1901     HeapRegion* curr_region = _g1h->heap_region_containing(finger);
1902     // Make sure that the reads below do not float before loading curr_region.
1903     OrderAccess::loadload();
1904     // Above heap_region_containing may return NULL as we always scan claim
1905     // until the end of the heap. In this case, just jump to the next region.
1906     HeapWord* end = curr_region != NULL ? curr_region->end() : finger + HeapRegion::GrainWords;
1907 
1908     // Is the gap between reading the finger and doing the CAS too long?
1909     HeapWord* res = Atomic::cmpxchg(&_finger, finger, end);
1910     if (res == finger && curr_region != NULL) {
1911       // we succeeded
1912       HeapWord*   bottom        = curr_region->bottom();
1913       HeapWord*   limit         = curr_region->next_top_at_mark_start();
1914 
1915       // notice that _finger == end cannot be guaranteed here since,
1916       // someone else might have moved the finger even further
1917       assert(_finger >= end, "the finger should have moved forward");
1918 
1919       if (limit > bottom) {
1920         return curr_region;
1921       } else {
1922         assert(limit == bottom,
1923                "the region limit should be at bottom");
1924         // we return NULL and the caller should try calling
1925         // claim_region() again.
1926         return NULL;
1927       }
1928     } else {
1929       assert(_finger > finger, "the finger should have moved forward");


< prev index next >