Skip to content

Commit e6f3d2e

Browse files
author
Thomas Schatzl
committed
Fixes
1 parent 04597a4 commit e6f3d2e

File tree

9 files changed

+25
-41
lines changed

9 files changed

+25
-41
lines changed

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@ HeapRegion* G1CollectedHeap::new_region(size_t word_size,
190190
res = _hrm.allocate_free_region(type, node_index);
191191
}
192192
}
193-
if (res != nullptr) {
194-
concurrent_mark()->clear_statistics(res);
195-
}
196193
return res;
197194
}
198195

@@ -1177,7 +1174,7 @@ G1CollectedHeap::G1CollectedHeap() :
11771174
_is_alive_closure_stw(this),
11781175
_is_subject_to_discovery_stw(this),
11791176
_ref_processor_cm(nullptr),
1180-
_is_alive_closure_cm(this),
1177+
_is_alive_closure_cm(nullptr),
11811178
_is_subject_to_discovery_cm(this),
11821179
_region_attr() {
11831180

@@ -1509,15 +1506,15 @@ void G1CollectedHeap::ref_processing_init() {
15091506
// * Reference discovery will not need a barrier.
15101507

15111508
// Concurrent Mark ref processor
1512-
_is_alive_closure_cm.set_concurrent_mark(concurrent_mark());
1509+
_is_alive_closure_cm = new G1CMIsAliveClosure(concurrent_mark());
15131510
_ref_processor_cm =
15141511
new ReferenceProcessor(&_is_subject_to_discovery_cm,
15151512
ParallelGCThreads, // degree of mt processing
15161513
// We discover with the gc worker threads during Remark, so both
15171514
// thread counts must be considered for discovery.
15181515
MAX2(ParallelGCThreads, ConcGCThreads), // degree of mt discovery
15191516
true, // Reference discovery is concurrent
1520-
&_is_alive_closure_cm); // is alive closure
1517+
_is_alive_closure_cm); // is alive closure
15211518

15221519
// STW ref processor
15231520
_ref_processor_stw =
@@ -2638,8 +2635,6 @@ void G1CollectedHeap::free_region(HeapRegion* hr, FreeRegionList* free_list) {
26382635
if (free_list != nullptr) {
26392636
free_list->add_ordered(hr);
26402637
}
2641-
2642-
concurrent_mark()->clear_statistics(hr);
26432638
}
26442639

26452640
void G1CollectedHeap::retain_region(HeapRegion* hr) {

src/hotspot/share/gc/g1/g1CollectedHeap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ class G1CollectedHeap : public CollectedHeap {
864864
// _is_alive_non_header field is optional but doing so prevents
865865
// unnecessary additions to the discovered lists during reference
866866
// discovery.
867-
G1CMIsAliveClosure _is_alive_closure_cm;
867+
G1CMIsAliveClosure* _is_alive_closure_cm;
868868

869869
G1CMSubjectToDiscoveryClosure _is_subject_to_discovery_cm;
870870
public:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,10 @@ class G1PrintCollectionSetDetailClosure : public HeapRegionClosure {
253253

254254
virtual bool do_heap_region(HeapRegion* r) {
255255
assert(r->in_collection_set(), "Region %u should be in collection set", r->hrm_index());
256+
G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
256257
_st->print_cr(" " HR_FORMAT ", TAMS: " PTR_FORMAT " PB: " PTR_FORMAT ", age: %4d",
257258
HR_FORMAT_PARAMS(r),
258-
p2i(G1CollectedHeap::heap()->concurrent_mark()->top_at_mark_start(r)),
259+
p2i(cm->top_at_mark_start(r)),
259260
p2i(r->parsable_bottom()),
260261
r->has_surv_rate_group() ? checked_cast<int>(r->age_in_surv_rate_group()) : -1);
261262
return false;

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

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@
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;
80+
G1CMIsAliveClosure::G1CMIsAliveClosure(G1ConcurrentMark* cm) : _cm(cm) {
81+
assert(cm != nullptr, "must be");
8682
}
8783

8884
bool G1CMBitMapClosure::do_addr(HeapWord* const addr) {
@@ -857,8 +853,6 @@ class NoteStartOfMarkHRClosure : public HeapRegionClosure {
857853
bool do_heap_region(HeapRegion* r) override {
858854
if (r->is_old_or_humongous() && !r->is_collection_set_candidate()) {
859855
_cm->update_top_at_mark_start(r);
860-
} else {
861-
_cm->reset_top_at_mark_start(r);
862856
}
863857
return false;
864858
}
@@ -877,18 +871,8 @@ G1PreConcurrentStartTask::G1PreConcurrentStartTask(GCCause::Cause cause, G1Concu
877871
G1BatchedTask("Pre Concurrent Start", G1CollectedHeap::heap()->phase_times()) {
878872
add_serial_task(new ResetMarkingStateTask(cm));
879873
add_parallel_task(new NoteStartOfMarkTask());
880-
881-
//cm->invalidate_top_at_mark_starts();
882874
};
883875

884-
#ifdef ASSERT
885-
void G1ConcurrentMark::invalidate_top_at_mark_starts() {
886-
for (uint i = 0; i < G1CollectedHeap::heap()->max_reserved_regions(); i++) {
887-
_top_at_mark_starts[i] = nullptr;
888-
}
889-
}
890-
#endif
891-
892876
void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) {
893877
assert_at_safepoint_on_vm_thread();
894878

@@ -1357,7 +1341,7 @@ void G1ConcurrentMark::remark() {
13571341

13581342
// Unload Klasses, String, Code Cache, etc.
13591343
if (ClassUnloadingWithConcurrentMark) {
1360-
G1CMIsAliveClosure is_alive(_g1h);
1344+
G1CMIsAliveClosure is_alive(this);
13611345
_g1h->unload_classes_and_code("Class Unloading", &is_alive, _gc_timer_cm);
13621346
}
13631347

@@ -1704,7 +1688,7 @@ class G1CMRefProcProxyTask : public RefProcProxyTask {
17041688

17051689
void work(uint worker_id) override {
17061690
assert(worker_id < _max_workers, "sanity");
1707-
G1CMIsAliveClosure is_alive(&_g1h);
1691+
G1CMIsAliveClosure is_alive(&_cm);
17081692
uint index = (_tm == RefProcThreadModel::Single) ? 0 : worker_id;
17091693
G1CMKeepAliveAndDrainClosure keep_alive(&_cm, _cm.task(index), _tm == RefProcThreadModel::Single);
17101694
BarrierEnqueueDiscoveredFieldClosure enqueue;
@@ -1783,7 +1767,7 @@ void G1ConcurrentMark::weak_refs_work() {
17831767

17841768
{
17851769
GCTraceTime(Debug, gc, phases) debug("Weak Processing", _gc_timer_cm);
1786-
G1CMIsAliveClosure is_alive(_g1h);
1770+
G1CMIsAliveClosure is_alive(this);
17871771
WeakProcessor::weak_oops_do(_g1h->workers(), &is_alive, &do_nothing_cl, 1);
17881772
}
17891773
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
#include "utilities/numberSeq.hpp"
4242

4343
class ConcurrentGCTimer;
44-
class G1ConcurrentMarkThread;
4544
class G1CollectedHeap;
45+
class G1ConcurrentMark;
46+
class G1ConcurrentMarkThread;
4647
class G1CMOopClosure;
4748
class G1CMTask;
48-
class G1ConcurrentMark;
4949
class G1OldTracer;
5050
class G1RegionToSpaceMapper;
5151
class G1SurvivorRegions;
@@ -96,11 +96,9 @@ typedef GenericTaskQueueSet<G1CMTaskQueue, mtGC> G1CMTaskQueueSet;
9696
// are alive. An instance is also embedded into the
9797
// reference processor as the _is_alive_non_header field
9898
class G1CMIsAliveClosure : public BoolObjectClosure {
99-
G1CollectedHeap* _g1h;
10099
G1ConcurrentMark* _cm;
101100
public:
102-
G1CMIsAliveClosure(G1CollectedHeap* g1h);
103-
void set_concurrent_mark(G1ConcurrentMark* cm);
101+
G1CMIsAliveClosure(G1ConcurrentMark* cm);
104102

105103
bool do_object_b(oop obj);
106104
};
@@ -542,6 +540,8 @@ class G1ConcurrentMark : public CHeapObj<mtGC> {
542540

543541
// Region statistics gathered during marking.
544542
G1RegionMarkStats* _region_mark_stats;
543+
// Top pointer for each region at the start of marking. Must be valid for all committed
544+
// regions.
545545
HeapWord* volatile* _top_at_mark_starts;
546546
// Top pointer for each region at the start of the rebuild remembered set process
547547
// for regions which remembered sets need to be rebuilt. A null for a given region
@@ -562,14 +562,16 @@ class G1ConcurrentMark : public CHeapObj<mtGC> {
562562
// Set live bytes for concurrent marking.
563563
void set_live_bytes(uint region, size_t live_bytes) { _region_mark_stats[region]._live_words = live_bytes / HeapWordSize; }
564564

565+
// Update the TAMS for the given region to the current top.
565566
inline void update_top_at_mark_start(HeapRegion* r);
567+
// Reset the TAMS for the given region to bottom of that region.
566568
inline void reset_top_at_mark_start(HeapRegion* r);
569+
567570
inline HeapWord* top_at_mark_start(const HeapRegion* r) const;
568571
inline HeapWord* top_at_mark_start(uint region) const;
572+
// Returns whether the given object been allocated since marking start (i.e. >= TAMS in that region).
569573
inline bool obj_allocated_since_mark_start(oop obj) const;
570574

571-
void invalidate_top_at_mark_starts() NOT_DEBUG_RETURN;
572-
573575
// Sets the internal top_at_region_start for the given region to current top of the region.
574576
inline void update_top_at_rebuild_start(HeapRegion* r);
575577
// TARS for the given region during remembered set rebuilding.

src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ inline bool G1CMIsAliveClosure::do_object_b(oop obj) {
5454
}
5555

5656
// All objects that are marked are live.
57-
return _g1h->is_marked(obj);
57+
return _cm->is_marked_in_bitmap(obj);
5858
}
5959

6060
inline bool G1CMSubjectToDiscoveryClosure::do_object_b(oop obj) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ void HeapRegion::hr_clear(bool clear_space) {
124124

125125
rem_set()->clear();
126126

127+
G1CollectedHeap::heap()->concurrent_mark()->clear_statistics(this);
128+
127129
_parsable_bottom = bottom();
128130
_garbage_bytes = 0;
129131

src/hotspot/share/memory/iterator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Thread;
4141

4242
// The following classes are C++ `closures` for iterating over objects, roots and spaces
4343

44-
class Closure : public StackObj { };
44+
class Closure : public CHeapObj<mtGC> { };
4545

4646
// Thread iterator
4747
class ThreadClosure {

test/hotspot/jtreg/gc/g1/TestNoEagerReclaimOfHumongousRegions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @modules java.base/jdk.internal.misc
3535
* @build jdk.test.whitebox.WhiteBox
3636
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
37-
* @run main/othervm -Xbootclasspath/a:. -Xlog:gc,gc+humongous=debug -XX:+UseG1GC -XX:MaxTenuringThreshold=0 -XX:+UnlockExperimentalVMOptions -XX:G1RemSetArrayOfCardsEntries=32 -XX:G1HeapRegionSize=1m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.g1.TestNoEagerReclaimOfHumongousRegions
37+
* @run main/othervm -Xbootclasspath/a:. -Xlog:gc,gc+region=trace,gc+humongous=debug -XX:+UseG1GC -XX:MaxTenuringThreshold=0 -XX:+UnlockExperimentalVMOptions -XX:G1RemSetArrayOfCardsEntries=32 -XX:G1HeapRegionSize=1m -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.g1.TestNoEagerReclaimOfHumongousRegions
3838
*/
3939

4040
import java.util.LinkedList;

0 commit comments

Comments
 (0)