8215220: Simplify Shenandoah task termination in aborted paths
Reviewed-by: shade
This commit is contained in:
parent
e7722158fd
commit
a85ad0aa18
@ -939,9 +939,6 @@ void ShenandoahConcurrentMark::mark_loop_work(T* cl, jushort* live_data, uint wo
|
|||||||
q = queues->claim_next();
|
q = queues->claim_next();
|
||||||
while (q != NULL) {
|
while (q != NULL) {
|
||||||
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
|
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
|
||||||
ShenandoahCancelledTerminatorTerminator tt;
|
|
||||||
ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
|
|
||||||
while (!terminator->offer_termination(&tt));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,9 +962,6 @@ void ShenandoahConcurrentMark::mark_loop_work(T* cl, jushort* live_data, uint wo
|
|||||||
*/
|
*/
|
||||||
while (true) {
|
while (true) {
|
||||||
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
|
if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
|
||||||
ShenandoahCancelledTerminatorTerminator tt;
|
|
||||||
ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
|
|
||||||
while (!terminator->offer_termination(&tt));
|
|
||||||
return;
|
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.
|
// Need to leave the STS here otherwise it might block safepoints.
|
||||||
ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
|
ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
|
||||||
ShenandoahTerminationTimingsTracker term_tracker(worker_id);
|
ShenandoahTerminationTimingsTracker term_tracker(worker_id);
|
||||||
if (terminator->offer_termination()) return;
|
ShenandoahTerminatorTerminator tt(heap);
|
||||||
|
if (terminator->offer_termination(&tt)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,28 +49,8 @@ bool ShenandoahObjToScanQueueSet::is_empty() {
|
|||||||
return true;
|
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) :
|
ShenandoahTaskTerminator::ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
|
||||||
_terminator(new ShenandoahOWSTTerminator(n_threads, queue_set)) { }
|
_terminator(new OWSTTaskTerminator(n_threads, queue_set)) { }
|
||||||
|
|
||||||
ShenandoahTaskTerminator::~ShenandoahTaskTerminator() {
|
ShenandoahTaskTerminator::~ShenandoahTaskTerminator() {
|
||||||
assert(_terminator != NULL, "Invariant");
|
assert(_terminator != NULL, "Invariant");
|
||||||
|
@ -306,18 +306,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ShenandoahTerminatorTerminator : public TerminatorTerminator {
|
class ShenandoahTerminatorTerminator : public TerminatorTerminator {
|
||||||
|
private:
|
||||||
|
ShenandoahHeap* _heap;
|
||||||
public:
|
public:
|
||||||
|
ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
|
||||||
// return true, terminates immediately, even if there's remaining work left
|
// return true, terminates immediately, even if there's remaining work left
|
||||||
virtual bool should_force_termination() { return false; }
|
virtual bool should_exit_termination() { return _heap->cancelled_gc(); }
|
||||||
};
|
|
||||||
|
|
||||||
class ShenandoahCancelledTerminatorTerminator : public ShenandoahTerminatorTerminator {
|
|
||||||
virtual bool should_exit_termination() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool should_force_termination() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShenandoahTaskTerminator : public StackObj {
|
class ShenandoahTaskTerminator : public StackObj {
|
||||||
|
@ -498,10 +498,6 @@ void ShenandoahTraversalGC::main_loop_work(T* cl, jushort* live_data, uint worke
|
|||||||
q = queues->claim_next();
|
q = queues->claim_next();
|
||||||
while (q != NULL) {
|
while (q != NULL) {
|
||||||
if (_heap->check_cancelled_gc_and_yield(sts_yield)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,17 +543,15 @@ void ShenandoahTraversalGC::main_loop_work(T* cl, jushort* live_data, uint worke
|
|||||||
ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
|
ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
|
||||||
ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
|
ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
|
||||||
ShenandoahTerminationTimingsTracker term_tracker(worker_id);
|
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) {
|
bool ShenandoahTraversalGC::check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield) {
|
||||||
if (_heap->cancelled_gc()) {
|
if (_heap->cancelled_gc()) {
|
||||||
ShenandoahCancelledTerminatorTerminator tt;
|
|
||||||
ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
|
|
||||||
ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
|
|
||||||
while (! terminator->offer_termination(&tt));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user