Skip to content

Commit 957dae0

Browse files
author
Thomas Schatzl
committed
8280958: G1/Parallel: Unify marking code structure
Reviewed-by: ayang, kbarrett
1 parent e44d067 commit 957dae0

File tree

6 files changed

+36
-26
lines changed

6 files changed

+36
-26
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void G1FullGCMarker::complete_marking(OopQueueSet* oop_stacks,
5555
ObjArrayTaskQueueSet* array_stacks,
5656
TaskTerminator* terminator) {
5757
do {
58-
drain_stack();
58+
follow_marking_stacks();
5959
ObjArrayTask steal_array;
6060
if (array_stacks->steal(_worker_id, steal_array)) {
6161
follow_array_chunk(objArrayOop(steal_array.obj()), steal_array.index());

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ class G1FullGCMarker : public CHeapObj<mtGC> {
7979
inline void follow_array(objArrayOop array);
8080
inline void follow_array_chunk(objArrayOop array, int index);
8181

82-
inline void drain_oop_stack();
83-
// Transfer contents from the objArray task queue overflow stack to the shared
84-
// objArray stack.
82+
inline void publish_and_drain_oop_tasks();
83+
// Try to publish all contents from the objArray task queue overflow stack to
84+
// the shared objArray stack.
8585
// Returns true and a valid task if there has not been enough space in the shared
86-
// objArray stack, otherwise the task is invalid.
87-
inline bool transfer_objArray_overflow_stack(ObjArrayTask& task);
86+
// objArray stack, otherwise returns false and the task is invalid.
87+
inline bool publish_or_pop_objarray_tasks(ObjArrayTask& task);
8888

8989
public:
9090
G1FullGCMarker(G1FullCollector* collector,
@@ -103,7 +103,7 @@ class G1FullGCMarker : public CHeapObj<mtGC> {
103103
inline void follow_klass(Klass* k);
104104
inline void follow_cld(ClassLoaderData* cld);
105105

106-
inline void drain_stack();
106+
inline void follow_marking_stacks();
107107
void complete_marking(OopQueueSet* oop_stacks,
108108
ObjArrayTaskQueueSet* array_stacks,
109109
TaskTerminator* terminator);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ inline void G1FullGCMarker::follow_object(oop obj) {
151151
}
152152
}
153153

154-
inline void G1FullGCMarker::drain_oop_stack() {
154+
inline void G1FullGCMarker::publish_and_drain_oop_tasks() {
155155
oop obj;
156156
while (_oop_stack.pop_overflow(obj)) {
157157
if (!_oop_stack.try_push_to_taskqueue(obj)) {
@@ -165,7 +165,7 @@ inline void G1FullGCMarker::drain_oop_stack() {
165165
}
166166
}
167167

168-
inline bool G1FullGCMarker::transfer_objArray_overflow_stack(ObjArrayTask& task) {
168+
inline bool G1FullGCMarker::publish_or_pop_objarray_tasks(ObjArrayTask& task) {
169169
// It is desirable to move as much as possible work from the overflow queue to
170170
// the shared queue as quickly as possible.
171171
while (_objarray_stack.pop_overflow(task)) {
@@ -176,15 +176,15 @@ inline bool G1FullGCMarker::transfer_objArray_overflow_stack(ObjArrayTask& task)
176176
return false;
177177
}
178178

179-
void G1FullGCMarker::drain_stack() {
179+
void G1FullGCMarker::follow_marking_stacks() {
180180
do {
181181
// First, drain regular oop stack.
182-
drain_oop_stack();
182+
publish_and_drain_oop_tasks();
183183

184184
// Then process ObjArrays one at a time to avoid marking stack bloat.
185185
ObjArrayTask task;
186-
if (transfer_objArray_overflow_stack(task) ||
187-
_objarray_stack.pop_local(task)) {
186+
if (publish_or_pop_objarray_tasks(task) ||
187+
_objarray_stack.pop_local(task)) {
188188
follow_array_chunk(objArrayOop(task.obj()), task.index());
189189
}
190190
} while (!is_empty());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
G1IsAliveClosure::G1IsAliveClosure(G1FullCollector* collector) :
3737
G1IsAliveClosure(collector, collector->mark_bitmap()) { }
3838

39-
void G1FollowStackClosure::do_void() { _marker->drain_stack(); }
39+
void G1FollowStackClosure::do_void() { _marker->follow_marking_stacks(); }
4040

4141
void G1FullKeepAliveClosure::do_oop(oop* p) { do_oop_work(p); }
4242
void G1FullKeepAliveClosure::do_oop(narrowOop* p) { do_oop_work(p); }

src/hotspot/share/gc/parallel/psCompactionManager.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,19 @@ ParCompactionManager::gc_thread_compaction_manager(uint index) {
113113
return _manager_array[index];
114114
}
115115

116-
bool ParCompactionManager::transfer_from_overflow_stack(ObjArrayTask& task) {
116+
inline void ParCompactionManager::publish_and_drain_oop_tasks() {
117+
oop obj;
118+
while (marking_stack()->pop_overflow(obj)) {
119+
if (!marking_stack()->try_push_to_taskqueue(obj)) {
120+
follow_contents(obj);
121+
}
122+
}
123+
while (marking_stack()->pop_local(obj)) {
124+
follow_contents(obj);
125+
}
126+
}
127+
128+
bool ParCompactionManager::publish_or_pop_objarray_tasks(ObjArrayTask& task) {
117129
while (_objarray_stack.pop_overflow(task)) {
118130
if (!_objarray_stack.try_push_to_taskqueue(task)) {
119131
return true;
@@ -126,19 +138,12 @@ void ParCompactionManager::follow_marking_stacks() {
126138
do {
127139
// First, try to move tasks from the overflow stack into the shared buffer, so
128140
// that other threads can steal. Otherwise process the overflow stack first.
129-
oop obj;
130-
while (marking_stack()->pop_overflow(obj)) {
131-
if (!marking_stack()->try_push_to_taskqueue(obj)) {
132-
follow_contents(obj);
133-
}
134-
}
135-
while (marking_stack()->pop_local(obj)) {
136-
follow_contents(obj);
137-
}
141+
publish_and_drain_oop_tasks();
138142

139143
// Process ObjArrays one at a time to avoid marking stack bloat.
140144
ObjArrayTask task;
141-
if (transfer_from_overflow_stack(task) || _objarray_stack.pop_local(task)) {
145+
if (publish_or_pop_objarray_tasks(task) ||
146+
_objarray_stack.pop_local(task)) {
142147
follow_array((objArrayOop)task.obj(), task.index());
143148
}
144149
} while (!marking_stacks_empty());

src/hotspot/share/gc/parallel/psCompactionManager.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ class ParCompactionManager : public CHeapObj<mtGC> {
9797

9898
static void initialize(ParMarkBitMap* mbm);
9999

100-
bool transfer_from_overflow_stack(ObjArrayTask& task);
100+
void publish_and_drain_oop_tasks();
101+
// Try to publish all contents from the objArray task queue overflow stack to
102+
// the shared objArray stack.
103+
// Returns true and a valid task if there has not been enough space in the shared
104+
// objArray stack, otherwise returns false and the task is invalid.
105+
bool publish_or_pop_objarray_tasks(ObjArrayTask& task);
101106
protected:
102107
// Array of task queues. Needed by the task terminator.
103108
static RegionTaskQueueSet* region_task_queues() { return _region_task_queues; }

0 commit comments

Comments
 (0)