7777#include " utilities/growableArray.hpp"
7878#include " utilities/powerOfTwo.hpp"
7979
80+ G1CMIsAliveClosure::G1CMIsAliveClosure (G1CollectedHeap* g1h) :
81+ _g1h(g1h), _cm(g1h->concurrent_mark ()) { }
82+
83+ void G1CMIsAliveClosure::set_concurrent_mark (G1ConcurrentMark* cm) {
84+ assert (_cm == nullptr , " already set" );
85+ _cm = cm;
86+ }
87+
8088bool G1CMBitMapClosure::do_addr (HeapWord* const addr) {
8189 assert (addr < _cm->finger (), " invariant" );
8290 assert (addr >= _task->finger (), " invariant" );
@@ -501,6 +509,7 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h,
501509 _max_concurrent_workers(0 ),
502510
503511 _region_mark_stats(NEW_C_HEAP_ARRAY(G1RegionMarkStats, _g1h->max_reserved_regions (), mtGC)),
512+ _top_at_mark_starts(NEW_C_HEAP_ARRAY(HeapWord*, _g1h->max_reserved_regions (), mtGC)),
504513 _top_at_rebuild_starts(NEW_C_HEAP_ARRAY(HeapWord*, _g1h->max_reserved_regions (), mtGC)),
505514 _needs_remembered_set_rebuild(false )
506515{
@@ -558,6 +567,7 @@ void G1ConcurrentMark::reset() {
558567
559568 uint max_reserved_regions = _g1h->max_reserved_regions ();
560569 for (uint i = 0 ; i < max_reserved_regions; i++) {
570+ _top_at_mark_starts[i] = _g1h->bottom_addr_for_region (i);
561571 _top_at_rebuild_starts[i] = nullptr ;
562572 _region_mark_stats[i].clear ();
563573 }
@@ -570,6 +580,7 @@ void G1ConcurrentMark::clear_statistics(HeapRegion* r) {
570580 for (uint j = 0 ; j < _max_num_tasks; ++j) {
571581 _tasks[j]->clear_mark_stats_cache (region_idx);
572582 }
583+ _top_at_mark_starts[region_idx] = _g1h->bottom_addr_for_region (region_idx);
573584 _top_at_rebuild_starts[region_idx] = nullptr ;
574585 _region_mark_stats[region_idx].clear ();
575586}
@@ -647,6 +658,7 @@ void G1ConcurrentMark::reset_at_marking_complete() {
647658}
648659
649660G1ConcurrentMark::~G1ConcurrentMark () {
661+ FREE_C_HEAP_ARRAY (HeapWord*, _top_at_mark_starts);
650662 FREE_C_HEAP_ARRAY (HeapWord*, _top_at_rebuild_starts);
651663 FREE_C_HEAP_ARRAY (G1RegionMarkStats, _region_mark_stats);
652664 // The G1ConcurrentMark instance is never freed.
@@ -692,7 +704,7 @@ class G1ClearBitMapTask : public WorkerTask {
692704 assert (_bitmap->get_next_marked_addr (r->bottom (), r->end ()) == r->end (), " Should not have marked bits" );
693705 return r->bottom ();
694706 }
695- assert (_bitmap->get_next_marked_addr (r ->top_at_mark_start (), r->end ()) == r->end (), " Should not have marked bits above tams" );
707+ assert (_bitmap->get_next_marked_addr (_cm ->top_at_mark_start (r ), r->end ()) == r->end (), " Should not have marked bits above tams" );
696708 }
697709 return r->end ();
698710 }
@@ -844,7 +856,7 @@ class G1PreConcurrentStartTask::NoteStartOfMarkTask : public G1AbstractSubTask {
844856
845857void G1PreConcurrentStartTask::ResetMarkingStateTask::do_work (uint worker_id) {
846858 // Reset marking state.
847- _cm->reset ();
859+ // _cm->reset();
848860}
849861
850862class NoteStartOfMarkHRClosure : public HeapRegionClosure {
@@ -877,6 +889,7 @@ void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) {
877889
878890 ClassLoaderDataGraph::verify_claimed_marks_cleared (ClassLoaderData::_claim_strong);
879891
892+ reset ();
880893 G1PreConcurrentStartTask cl (cause, this );
881894 G1CollectedHeap::heap ()->run_batch_task (&cl);
882895
@@ -1014,9 +1027,9 @@ void G1ConcurrentMark::scan_root_region(const MemRegion* region, uint worker_id)
10141027#ifdef ASSERT
10151028 HeapWord* last = region->last ();
10161029 HeapRegion* hr = _g1h->heap_region_containing (last);
1017- assert (hr->is_old () || hr-> top_at_mark_start () == hr->bottom (),
1030+ assert (hr->is_old () || top_at_mark_start (hr ) == hr->bottom (),
10181031 " Root regions must be old or survivor/eden but region %u is %s" , hr->hrm_index (), hr->get_type_str ());
1019- assert (hr-> top_at_mark_start () == region->start (),
1032+ assert (top_at_mark_start (hr ) == region->start (),
10201033 " MemRegion start should be equal to TAMS" );
10211034#endif
10221035
@@ -1078,11 +1091,11 @@ bool G1ConcurrentMark::wait_until_root_region_scan_finished() {
10781091}
10791092
10801093void G1ConcurrentMark::add_root_region (HeapRegion* r) {
1081- root_regions ()->add (r-> top_at_mark_start (), r->top ());
1094+ root_regions ()->add (top_at_mark_start (r ), r->top ());
10821095}
10831096
10841097bool G1ConcurrentMark::is_root_region (HeapRegion* r) {
1085- return root_regions ()->contains (MemRegion (r-> top_at_mark_start (), r->top ()));
1098+ return root_regions ()->contains (MemRegion (top_at_mark_start (r ), r->top ()));
10861099}
10871100
10881101void G1ConcurrentMark::root_region_scan_abort_and_wait () {
@@ -1944,9 +1957,9 @@ HeapRegion* G1ConcurrentMark::claim_region(uint worker_id) {
19441957 if (res == finger && curr_region != nullptr ) {
19451958 // we succeeded
19461959 HeapWord* bottom = curr_region->bottom ();
1947- HeapWord* limit = curr_region-> top_at_mark_start ();
1960+ HeapWord* limit = top_at_mark_start (curr_region );
19481961
1949- log_trace (gc, marking)(" Claim region %u bottom " PTR_FORMAT " tams " PTR_FORMAT, curr_region->hrm_index (), p2i (curr_region->bottom ()), p2i (curr_region-> top_at_mark_start ()));
1962+ log_trace (gc, marking)(" Claim region %u bottom " PTR_FORMAT " tams " PTR_FORMAT, curr_region->hrm_index (), p2i (curr_region->bottom ()), p2i (top_at_mark_start (curr_region )));
19501963 // notice that _finger == end cannot be guaranteed here since,
19511964 // someone else might have moved the finger even further
19521965 assert (_finger >= end, " the finger should have moved forward" );
@@ -2169,7 +2182,7 @@ void G1CMTask::setup_for_region(HeapRegion* hr) {
21692182void G1CMTask::update_region_limit () {
21702183 HeapRegion* hr = _curr_region;
21712184 HeapWord* bottom = hr->bottom ();
2172- HeapWord* limit = hr ->top_at_mark_start ();
2185+ HeapWord* limit = _cm ->top_at_mark_start (hr );
21732186
21742187 if (limit == bottom) {
21752188 // The region was collected underneath our feet.
0 commit comments