< prev index next >
src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentMark.cpp
Print this page
rev 11046 : Implement suspendible workers
@@ -32,10 +32,11 @@
#include "gc_implementation/shenandoah/shenandoahBarrierSet.inline.hpp"
#include "gc_implementation/shenandoah/shenandoahConcurrentMark.inline.hpp"
#include "gc_implementation/shenandoah/shenandoahOopClosures.inline.hpp"
#include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
#include "gc_implementation/shenandoah/shenandoahRootProcessor.hpp"
+#include "gc_implementation/shenandoah/shenandoahSuspendibleThreadSet.hpp"
#include "gc_implementation/shenandoah/shenandoahTaskqueue.hpp"
#include "gc_implementation/shenandoah/shenandoahTaskqueue.inline.hpp"
#include "gc_implementation/shenandoah/shenandoahWorkGroup.hpp"
#include "gc_implementation/shenandoah/shenandoahUtils.hpp"
#include "gc_implementation/shenandoah/shenandoah_specialized_oop_closures.hpp"
@@ -193,10 +194,11 @@
}
void work(uint worker_id) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
ShenandoahWorkerSession worker_session(worker_id);
+ ShenandoahSuspendibleThreadSetJoiner stsj(ShenandoahSuspendibleWorkers);
ShenandoahObjToScanQueue* q = _cm->get_queue(worker_id);
ReferenceProcessor* rp;
if (heap->process_references()) {
rp = ShenandoahHeap::heap()->ref_processor();
shenandoah_assert_rp_isalive_installed();
@@ -913,12 +915,13 @@
assert(queues->get_reserved() == heap->workers()->active_workers(),
"Need to reserve proper number of queues");
q = queues->claim_next();
while (q != NULL) {
- if (CANCELLABLE && heap->cancelled_gc()) {
+ if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
ShenandoahCancelledTerminatorTerminator tt;
+ ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
while (!terminator->offer_termination(&tt));
return;
}
for (uint i = 0; i < stride; i++) {
@@ -939,12 +942,13 @@
/*
* Normal marking loop:
*/
while (true) {
- if (CANCELLABLE && heap->cancelled_gc()) {
+ if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
ShenandoahCancelledTerminatorTerminator tt;
+ ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
while (!terminator->offer_termination(&tt));
return;
}
while (satb_mq_set.completed_buffers_num() > 0) {
@@ -962,10 +966,12 @@
}
}
if (work == 0) {
// No work encountered in current stride, try to terminate.
+ // 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;
}
}
}
< prev index next >