< prev index next >
src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp
Print this page
rev 11046 : Implement suspendible workers
@@ -46,10 +46,11 @@
#include "gc_implementation/shenandoah/shenandoahMonitoringSupport.hpp"
#include "gc_implementation/shenandoah/shenandoahMetrics.hpp"
#include "gc_implementation/shenandoah/shenandoahOopClosures.inline.hpp"
#include "gc_implementation/shenandoah/shenandoahPacer.hpp"
#include "gc_implementation/shenandoah/shenandoahPacer.inline.hpp"
+#include "gc_implementation/shenandoah/shenandoahSuspendibleThreadSet.hpp"
#include "gc_implementation/shenandoah/shenandoahRootProcessor.hpp"
#include "gc_implementation/shenandoah/shenandoahUtils.hpp"
#include "gc_implementation/shenandoah/shenandoahVerifier.hpp"
#include "gc_implementation/shenandoah/shenandoahCodeRoots.hpp"
#include "gc_implementation/shenandoah/shenandoahWorkGroup.hpp"
@@ -789,21 +790,24 @@
class ShenandoahConcurrentEvacuationTask : public AbstractGangTask {
private:
ShenandoahHeap* const _sh;
ShenandoahCollectionSet* const _cs;
-
+ bool _concurrent;
public:
ShenandoahConcurrentEvacuationTask(ShenandoahHeap* sh,
- ShenandoahCollectionSet* cs) :
+ ShenandoahCollectionSet* cs,
+ bool concurrent) :
AbstractGangTask("Parallel Evacuation Task"),
_sh(sh),
- _cs(cs) {}
+ _cs(cs),
+ _concurrent(concurrent) {}
void work(uint worker_id) {
ShenandoahWorkerSession worker_session(worker_id);
ShenandoahEvacOOMScope oom_evac_scope;
+ ShenandoahSuspendibleThreadSetJoiner stsj(ShenandoahSuspendibleWorkers && _concurrent);
ShenandoahConcurrentEvacuateRegionObjectClosure cl(_sh);
ShenandoahHeapRegion* r;
while ((r =_cs->claim_next()) != NULL) {
assert(r->has_live(), "all-garbage regions are reclaimed early");
@@ -811,11 +815,11 @@
if (ShenandoahPacing) {
_sh->pacer()->report_evac(r->used() >> LogHeapWordSize);
}
- if (_sh->cancelled_gc()) {
+ if (_sh->check_cancelled_gc_and_yield(_concurrent)) {
break;
}
}
}
};
@@ -1414,12 +1418,17 @@
if (ShenandoahVerify) {
verifier()->verify_after_evacuation();
}
}
-void ShenandoahHeap::op_evac() {
- ShenandoahConcurrentEvacuationTask task(this, _collection_set);
+void ShenandoahHeap::op_conc_evac() {
+ ShenandoahConcurrentEvacuationTask task(this, _collection_set, true);
+ workers()->run_task(&task);
+}
+
+void ShenandoahHeap::op_stw_evac() {
+ ShenandoahConcurrentEvacuationTask task(this, _collection_set, false);
workers()->run_task(&task);
}
void ShenandoahHeap::op_updaterefs() {
update_heap_references(true);
@@ -1510,11 +1519,11 @@
// it would be a simple check, which is supposed to be fast. This is also
// safe to do even without degeneration, as CSet iterator is at beginning
// in preparation for evacuation anyway.
collection_set()->clear_current_index();
- op_evac();
+ op_stw_evac();
if (cancelled_gc()) {
op_degenerated_fail();
return;
}
}
@@ -1914,10 +1923,11 @@
_concurrent(concurrent) {
}
void work(uint worker_id) {
ShenandoahWorkerSession worker_session(worker_id);
+ ShenandoahSuspendibleThreadSetJoiner stsj(_concurrent && ShenandoahSuspendibleWorkers);
ShenandoahUpdateHeapRefsClosure cl;
ShenandoahHeapRegion* r = _regions->next();
ShenandoahMarkingContext* const ctx = _heap->complete_marking_context();
while (r != NULL) {
HeapWord* top_at_start_ur = r->concurrent_iteration_safe_limit();
@@ -1926,11 +1936,11 @@
_heap->marked_object_oop_iterate(r, &cl, top_at_start_ur);
}
if (ShenandoahPacing) {
_heap->pacer()->report_updaterefs(pointer_delta(top_at_start_ur, r->bottom()));
}
- if (_heap->cancelled_gc()) {
+ if (_heap->check_cancelled_gc_and_yield(_concurrent)) {
return;
}
r = _regions->next();
}
}
@@ -2272,11 +2282,11 @@
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_evac(),
"concurrent evacuation");
try_inject_alloc_failure();
- op_evac();
+ op_conc_evac();
}
void ShenandoahHeap::entry_updaterefs() {
ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_update_refs);
< prev index next >