8215220: Simplify Shenandoah task termination in aborted paths

Reviewed-by: shade
This commit is contained in:
Zhengyu Gu 2018-12-12 13:50:57 -05:00
parent e7722158fd
commit a85ad0aa18
4 changed files with 10 additions and 47 deletions

View File

@ -939,9 +939,6 @@ void ShenandoahConcurrentMark::mark_loop_work(T* cl, jushort* live_data, uint wo
q = queues->claim_next();
while (q != NULL) {
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
ShenandoahCancelledTerminatorTerminator tt;
ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
while (!terminator->offer_termination(&tt));
return;
}
@ -965,9 +962,6 @@ void ShenandoahConcurrentMark::mark_loop_work(T* cl, jushort* live_data, uint wo
*/
while (true) {
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
ShenandoahCancelledTerminatorTerminator tt;
ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
while (!terminator->offer_termination(&tt));
return;
}
@ -991,7 +985,8 @@ void ShenandoahConcurrentMark::mark_loop_work(T* cl, jushort* live_data, uint wo
// Need to leave the STS here otherwise it might block safepoints.
ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
ShenandoahTerminationTimingsTracker term_tracker(worker_id);
if (terminator->offer_termination()) return;
ShenandoahTerminatorTerminator tt(heap);
if (terminator->offer_termination(&tt)) return;
}
}
}

View File

@ -49,28 +49,8 @@ bool ShenandoahObjToScanQueueSet::is_empty() {
return true;
}
class ShenandoahOWSTTerminator: public OWSTTaskTerminator {
public:
ShenandoahOWSTTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
OWSTTaskTerminator(n_threads, queue_set){ }
protected:
bool exit_termination(size_t tasks, TerminatorTerminator* terminator);
};
bool ShenandoahOWSTTerminator::exit_termination(size_t tasks, TerminatorTerminator* terminator) {
ShenandoahTerminatorTerminator* t = (ShenandoahTerminatorTerminator*)terminator;
bool force = (t != NULL) && t->should_force_termination();
if (force) {
// Force termination : continue termination, even there are remaining tasks.
return false;
} else {
return OWSTTaskTerminator::exit_termination(tasks, terminator);
}
}
ShenandoahTaskTerminator::ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
_terminator(new ShenandoahOWSTTerminator(n_threads, queue_set)) { }
_terminator(new OWSTTaskTerminator(n_threads, queue_set)) { }
ShenandoahTaskTerminator::~ShenandoahTaskTerminator() {
assert(_terminator != NULL, "Invariant");

View File

@ -306,18 +306,12 @@ public:
};
class ShenandoahTerminatorTerminator : public TerminatorTerminator {
private:
ShenandoahHeap* _heap;
public:
ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
// return true, terminates immediately, even if there's remaining work left
virtual bool should_force_termination() { return false; }
};
class ShenandoahCancelledTerminatorTerminator : public ShenandoahTerminatorTerminator {
virtual bool should_exit_termination() {
return false;
}
virtual bool should_force_termination() {
return true;
}
virtual bool should_exit_termination() { return _heap->cancelled_gc(); }
};
class ShenandoahTaskTerminator : public StackObj {

View File

@ -498,10 +498,6 @@ void ShenandoahTraversalGC::main_loop_work(T* cl, jushort* live_data, uint worke
q = queues->claim_next();
while (q != NULL) {
if (_heap->check_cancelled_gc_and_yield(sts_yield)) {
ShenandoahCancelledTerminatorTerminator tt;
ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
while (!terminator->offer_termination(&tt));
return;
}
@ -547,17 +543,15 @@ void ShenandoahTraversalGC::main_loop_work(T* cl, jushort* live_data, uint worke
ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
ShenandoahTerminationTimingsTracker term_tracker(worker_id);
if (terminator->offer_termination()) return;
ShenandoahTerminatorTerminator tt(_heap);
if (terminator->offer_termination(&tt)) return;
}
}
}
bool ShenandoahTraversalGC::check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield) {
if (_heap->cancelled_gc()) {
ShenandoahCancelledTerminatorTerminator tt;
ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
while (! terminator->offer_termination(&tt));
return true;
}
return false;