8280958: G1/Parallel: Unify marking code structure
Reviewed-by: ayang, kbarrett
This commit is contained in:
parent
e44d0670a6
commit
957dae02b1
@ -55,7 +55,7 @@ void G1FullGCMarker::complete_marking(OopQueueSet* oop_stacks,
|
||||
ObjArrayTaskQueueSet* array_stacks,
|
||||
TaskTerminator* terminator) {
|
||||
do {
|
||||
drain_stack();
|
||||
follow_marking_stacks();
|
||||
ObjArrayTask steal_array;
|
||||
if (array_stacks->steal(_worker_id, steal_array)) {
|
||||
follow_array_chunk(objArrayOop(steal_array.obj()), steal_array.index());
|
||||
|
@ -79,12 +79,12 @@ class G1FullGCMarker : public CHeapObj<mtGC> {
|
||||
inline void follow_array(objArrayOop array);
|
||||
inline void follow_array_chunk(objArrayOop array, int index);
|
||||
|
||||
inline void drain_oop_stack();
|
||||
// Transfer contents from the objArray task queue overflow stack to the shared
|
||||
// objArray stack.
|
||||
inline void publish_and_drain_oop_tasks();
|
||||
// Try to publish all contents from the objArray task queue overflow stack to
|
||||
// the shared objArray stack.
|
||||
// Returns true and a valid task if there has not been enough space in the shared
|
||||
// objArray stack, otherwise the task is invalid.
|
||||
inline bool transfer_objArray_overflow_stack(ObjArrayTask& task);
|
||||
// objArray stack, otherwise returns false and the task is invalid.
|
||||
inline bool publish_or_pop_objarray_tasks(ObjArrayTask& task);
|
||||
|
||||
public:
|
||||
G1FullGCMarker(G1FullCollector* collector,
|
||||
@ -103,7 +103,7 @@ public:
|
||||
inline void follow_klass(Klass* k);
|
||||
inline void follow_cld(ClassLoaderData* cld);
|
||||
|
||||
inline void drain_stack();
|
||||
inline void follow_marking_stacks();
|
||||
void complete_marking(OopQueueSet* oop_stacks,
|
||||
ObjArrayTaskQueueSet* array_stacks,
|
||||
TaskTerminator* terminator);
|
||||
|
@ -151,7 +151,7 @@ inline void G1FullGCMarker::follow_object(oop obj) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void G1FullGCMarker::drain_oop_stack() {
|
||||
inline void G1FullGCMarker::publish_and_drain_oop_tasks() {
|
||||
oop obj;
|
||||
while (_oop_stack.pop_overflow(obj)) {
|
||||
if (!_oop_stack.try_push_to_taskqueue(obj)) {
|
||||
@ -165,7 +165,7 @@ inline void G1FullGCMarker::drain_oop_stack() {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool G1FullGCMarker::transfer_objArray_overflow_stack(ObjArrayTask& task) {
|
||||
inline bool G1FullGCMarker::publish_or_pop_objarray_tasks(ObjArrayTask& task) {
|
||||
// It is desirable to move as much as possible work from the overflow queue to
|
||||
// the shared queue as quickly as possible.
|
||||
while (_objarray_stack.pop_overflow(task)) {
|
||||
@ -176,15 +176,15 @@ inline bool G1FullGCMarker::transfer_objArray_overflow_stack(ObjArrayTask& task)
|
||||
return false;
|
||||
}
|
||||
|
||||
void G1FullGCMarker::drain_stack() {
|
||||
void G1FullGCMarker::follow_marking_stacks() {
|
||||
do {
|
||||
// First, drain regular oop stack.
|
||||
drain_oop_stack();
|
||||
publish_and_drain_oop_tasks();
|
||||
|
||||
// Then process ObjArrays one at a time to avoid marking stack bloat.
|
||||
ObjArrayTask task;
|
||||
if (transfer_objArray_overflow_stack(task) ||
|
||||
_objarray_stack.pop_local(task)) {
|
||||
if (publish_or_pop_objarray_tasks(task) ||
|
||||
_objarray_stack.pop_local(task)) {
|
||||
follow_array_chunk(objArrayOop(task.obj()), task.index());
|
||||
}
|
||||
} while (!is_empty());
|
||||
|
@ -36,7 +36,7 @@
|
||||
G1IsAliveClosure::G1IsAliveClosure(G1FullCollector* collector) :
|
||||
G1IsAliveClosure(collector, collector->mark_bitmap()) { }
|
||||
|
||||
void G1FollowStackClosure::do_void() { _marker->drain_stack(); }
|
||||
void G1FollowStackClosure::do_void() { _marker->follow_marking_stacks(); }
|
||||
|
||||
void G1FullKeepAliveClosure::do_oop(oop* p) { do_oop_work(p); }
|
||||
void G1FullKeepAliveClosure::do_oop(narrowOop* p) { do_oop_work(p); }
|
||||
|
@ -113,7 +113,19 @@ ParCompactionManager::gc_thread_compaction_manager(uint index) {
|
||||
return _manager_array[index];
|
||||
}
|
||||
|
||||
bool ParCompactionManager::transfer_from_overflow_stack(ObjArrayTask& task) {
|
||||
inline void ParCompactionManager::publish_and_drain_oop_tasks() {
|
||||
oop obj;
|
||||
while (marking_stack()->pop_overflow(obj)) {
|
||||
if (!marking_stack()->try_push_to_taskqueue(obj)) {
|
||||
follow_contents(obj);
|
||||
}
|
||||
}
|
||||
while (marking_stack()->pop_local(obj)) {
|
||||
follow_contents(obj);
|
||||
}
|
||||
}
|
||||
|
||||
bool ParCompactionManager::publish_or_pop_objarray_tasks(ObjArrayTask& task) {
|
||||
while (_objarray_stack.pop_overflow(task)) {
|
||||
if (!_objarray_stack.try_push_to_taskqueue(task)) {
|
||||
return true;
|
||||
@ -126,19 +138,12 @@ void ParCompactionManager::follow_marking_stacks() {
|
||||
do {
|
||||
// First, try to move tasks from the overflow stack into the shared buffer, so
|
||||
// that other threads can steal. Otherwise process the overflow stack first.
|
||||
oop obj;
|
||||
while (marking_stack()->pop_overflow(obj)) {
|
||||
if (!marking_stack()->try_push_to_taskqueue(obj)) {
|
||||
follow_contents(obj);
|
||||
}
|
||||
}
|
||||
while (marking_stack()->pop_local(obj)) {
|
||||
follow_contents(obj);
|
||||
}
|
||||
publish_and_drain_oop_tasks();
|
||||
|
||||
// Process ObjArrays one at a time to avoid marking stack bloat.
|
||||
ObjArrayTask task;
|
||||
if (transfer_from_overflow_stack(task) || _objarray_stack.pop_local(task)) {
|
||||
if (publish_or_pop_objarray_tasks(task) ||
|
||||
_objarray_stack.pop_local(task)) {
|
||||
follow_array((objArrayOop)task.obj(), task.index());
|
||||
}
|
||||
} while (!marking_stacks_empty());
|
||||
|
@ -97,7 +97,12 @@ class ParCompactionManager : public CHeapObj<mtGC> {
|
||||
|
||||
static void initialize(ParMarkBitMap* mbm);
|
||||
|
||||
bool transfer_from_overflow_stack(ObjArrayTask& task);
|
||||
void publish_and_drain_oop_tasks();
|
||||
// Try to publish all contents from the objArray task queue overflow stack to
|
||||
// the shared objArray stack.
|
||||
// Returns true and a valid task if there has not been enough space in the shared
|
||||
// objArray stack, otherwise returns false and the task is invalid.
|
||||
bool publish_or_pop_objarray_tasks(ObjArrayTask& task);
|
||||
protected:
|
||||
// Array of task queues. Needed by the task terminator.
|
||||
static RegionTaskQueueSet* region_task_queues() { return _region_task_queues; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user