src/share/vm/gc_implementation/g1/concurrentMark.cpp
Print this page
rev 3463 : 7114678: G1: various small fixes, code cleanup, and refactoring
Summary: Various cleanups as a prelude to introducing iterators for HeapRegions.
Reviewed-by: johnc
Contributed-by: tonyp
*** 1221,1233 ****
// Normal (non-humongous) case: just set the bit.
_region_bm->par_at_put(index, true);
} else {
// Starts humongous case: calculate how many regions are part of
// this humongous region and then set the bit range.
! G1CollectedHeap* g1h = G1CollectedHeap::heap();
! HeapRegion *last_hr = g1h->heap_region_containing_raw(hr->end() - 1);
! BitMap::idx_t end_index = (BitMap::idx_t) last_hr->hrs_index() + 1;
_region_bm->par_at_put_range(index, end_index, true);
}
}
public:
--- 1221,1231 ----
// Normal (non-humongous) case: just set the bit.
_region_bm->par_at_put(index, true);
} else {
// Starts humongous case: calculate how many regions are part of
// this humongous region and then set the bit range.
! BitMap::idx_t end_index = (BitMap::idx_t) hr->last_hc_index();
_region_bm->par_at_put_range(index, end_index, true);
}
}
public:
*** 1640,1653 ****
_hrrs_cleanup_task(hrrs_cleanup_task) { }
size_t freed_bytes() { return _freed_bytes; }
bool doHeapRegion(HeapRegion *hr) {
// We use a claim value of zero here because all regions
// were claimed with value 1 in the FinalCount task.
! hr->reset_gc_time_stamp();
! if (!hr->continuesHumongous()) {
double start = os::elapsedTime();
_regions_claimed++;
hr->note_end_of_marking();
_max_live_bytes += hr->max_live_bytes();
_g1->free_region_if_empty(hr,
--- 1638,1653 ----
_hrrs_cleanup_task(hrrs_cleanup_task) { }
size_t freed_bytes() { return _freed_bytes; }
bool doHeapRegion(HeapRegion *hr) {
+ if (hr->continuesHumongous()) {
+ return false;
+ }
// We use a claim value of zero here because all regions
// were claimed with value 1 in the FinalCount task.
! _g1->reset_gc_time_stamps(hr);
double start = os::elapsedTime();
_regions_claimed++;
hr->note_end_of_marking();
_max_live_bytes += hr->max_live_bytes();
_g1->free_region_if_empty(hr,
*** 1660,1670 ****
double region_time = (os::elapsedTime() - start);
_claimed_region_time += region_time;
if (region_time > _max_region_time) {
_max_region_time = region_time;
}
- }
return false;
}
size_t max_live_bytes() { return _max_live_bytes; }
uint regions_claimed() { return _regions_claimed; }
--- 1660,1669 ----
*** 1876,1885 ****
--- 1875,1885 ----
assert(g1h->check_heap_region_claim_values(HeapRegion::NoteEndClaimValue),
"sanity check");
} else {
g1_par_note_end_task.work(0);
}
+ g1h->check_gc_time_stamps();
if (!cleanup_list_is_empty()) {
// The cleanup list is not empty, so we'll have to process it
// concurrently. Notify anyone else that might be wanting free
// regions that there will be more free regions coming soon.
*** 2444,2471 ****
} else if (!_g1h->is_in_g1_reserved(obj)) {
str = " O";
} else {
HeapRegion* hr = _g1h->heap_region_containing(obj);
guarantee(hr != NULL, "invariant");
! bool over_tams = false;
! bool marked = false;
!
! switch (_vo) {
! case VerifyOption_G1UsePrevMarking:
! over_tams = hr->obj_allocated_since_prev_marking(obj);
! marked = _g1h->isMarkedPrev(obj);
! break;
! case VerifyOption_G1UseNextMarking:
! over_tams = hr->obj_allocated_since_next_marking(obj);
! marked = _g1h->isMarkedNext(obj);
! break;
! case VerifyOption_G1UseMarkWord:
! marked = obj->is_gc_marked();
! break;
! default:
! ShouldNotReachHere();
! }
if (over_tams) {
str = " >";
if (marked) {
str2 = " AND MARKED";
--- 2444,2455 ----
} else if (!_g1h->is_in_g1_reserved(obj)) {
str = " O";
} else {
HeapRegion* hr = _g1h->heap_region_containing(obj);
guarantee(hr != NULL, "invariant");
! bool over_tams = _g1h->allocated_since_marking(obj, hr, _vo);
! bool marked = _g1h->is_marked(obj, _vo);
if (over_tams) {
str = " >";
if (marked) {
str2 = " AND MARKED";
*** 2497,2524 ****
HeapRegion* hr) :
_g1h(G1CollectedHeap::heap()),
_out(out), _vo(vo), _all(all), _hr(hr) { }
void do_object(oop o) {
! bool over_tams = false;
! bool marked = false;
!
! switch (_vo) {
! case VerifyOption_G1UsePrevMarking:
! over_tams = _hr->obj_allocated_since_prev_marking(o);
! marked = _g1h->isMarkedPrev(o);
! break;
! case VerifyOption_G1UseNextMarking:
! over_tams = _hr->obj_allocated_since_next_marking(o);
! marked = _g1h->isMarkedNext(o);
! break;
! case VerifyOption_G1UseMarkWord:
! marked = o->is_gc_marked();
! break;
! default:
! ShouldNotReachHere();
! }
bool print_it = _all || over_tams || marked;
if (print_it) {
_out->print_cr(" "PTR_FORMAT"%s",
o, (over_tams) ? " >" : (marked) ? " M" : "");
--- 2481,2492 ----
HeapRegion* hr) :
_g1h(G1CollectedHeap::heap()),
_out(out), _vo(vo), _all(all), _hr(hr) { }
void do_object(oop o) {
! bool over_tams = _g1h->allocated_since_marking(o, _hr, _vo);
! bool marked = _g1h->is_marked(o, _vo);
bool print_it = _all || over_tams || marked;
if (print_it) {
_out->print_cr(" "PTR_FORMAT"%s",
o, (over_tams) ? " >" : (marked) ? " M" : "");
*** 2528,2563 ****
}
};
class PrintReachableRegionClosure : public HeapRegionClosure {
private:
outputStream* _out;
VerifyOption _vo;
bool _all;
public:
bool doHeapRegion(HeapRegion* hr) {
HeapWord* b = hr->bottom();
HeapWord* e = hr->end();
HeapWord* t = hr->top();
! HeapWord* p = NULL;
!
! switch (_vo) {
! case VerifyOption_G1UsePrevMarking:
! p = hr->prev_top_at_mark_start();
! break;
! case VerifyOption_G1UseNextMarking:
! p = hr->next_top_at_mark_start();
! break;
! case VerifyOption_G1UseMarkWord:
! // When we are verifying marking using the mark word
! // TAMS has no relevance.
! assert(p == NULL, "post-condition");
! break;
! default:
! ShouldNotReachHere();
! }
_out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" "
"TAMS: "PTR_FORMAT, b, e, t, p);
_out->cr();
HeapWord* from = b;
--- 2496,2516 ----
}
};
class PrintReachableRegionClosure : public HeapRegionClosure {
private:
+ G1CollectedHeap* _g1h;
outputStream* _out;
VerifyOption _vo;
bool _all;
public:
bool doHeapRegion(HeapRegion* hr) {
HeapWord* b = hr->bottom();
HeapWord* e = hr->end();
HeapWord* t = hr->top();
! HeapWord* p = _g1h->top_at_mark_start(hr, _vo);
_out->print_cr("** ["PTR_FORMAT", "PTR_FORMAT"] top: "PTR_FORMAT" "
"TAMS: "PTR_FORMAT, b, e, t, p);
_out->cr();
HeapWord* from = b;
*** 2575,2598 ****
}
PrintReachableRegionClosure(outputStream* out,
VerifyOption vo,
bool all) :
! _out(out), _vo(vo), _all(all) { }
};
- static const char* verify_option_to_tams(VerifyOption vo) {
- switch (vo) {
- case VerifyOption_G1UsePrevMarking:
- return "PTAMS";
- case VerifyOption_G1UseNextMarking:
- return "NTAMS";
- default:
- return "NONE";
- }
- }
-
void ConcurrentMark::print_reachable(const char* str,
VerifyOption vo,
bool all) {
gclog_or_tty->cr();
gclog_or_tty->print_cr("== Doing heap dump... ");
--- 2528,2540 ----
}
PrintReachableRegionClosure(outputStream* out,
VerifyOption vo,
bool all) :
! _g1h(G1CollectedHeap::heap()), _out(out), _vo(vo), _all(all) { }
};
void ConcurrentMark::print_reachable(const char* str,
VerifyOption vo,
bool all) {
gclog_or_tty->cr();
gclog_or_tty->print_cr("== Doing heap dump... ");
*** 2617,2627 ****
gclog_or_tty->print_cr(" #### error: could not open file");
return;
}
outputStream* out = &fout;
! out->print_cr("-- USING %s", verify_option_to_tams(vo));
out->cr();
out->print_cr("--- ITERATING OVER REGIONS");
out->cr();
PrintReachableRegionClosure rcl(out, vo, all);
--- 2559,2569 ----
gclog_or_tty->print_cr(" #### error: could not open file");
return;
}
outputStream* out = &fout;
! out->print_cr("-- USING %s", _g1h->top_at_mark_start_str(vo));
out->cr();
out->print_cr("--- ITERATING OVER REGIONS");
out->cr();
PrintReachableRegionClosure rcl(out, vo, all);