< prev index next >
src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
Print this page
@@ -2425,18 +2425,22 @@
// Mark from roots one level into CMS
MarkRefsIntoClosure notOlder(_span, verification_mark_bm());
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
- gch->gen_process_roots(_cmsGen->level(),
+ {
+ StrongRootsScope srs(1);
+
+ gch->gen_process_roots(&srs,
+ _cmsGen->level(),
true, // younger gens are roots
- true, // activate StrongRootsScope
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
NULL,
- NULL); // SSS: Provide correct closure
+ NULL);
+ }
// Now mark from the roots
MarkFromRootsClosure markFromRootsClosure(this, _span,
verification_mark_bm(), verification_mark_stack(),
false /* don't yield */, true /* verifying */);
@@ -2493,18 +2497,22 @@
markBitMap());
CLDToOopClosure cld_closure(¬Older, true);
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
- gch->gen_process_roots(_cmsGen->level(),
+ {
+ StrongRootsScope srs(1);
+
+ gch->gen_process_roots(&srs,
+ _cmsGen->level(),
true, // younger gens are roots
- true, // activate StrongRootsScope
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
NULL,
&cld_closure);
+ }
// Now mark from the roots
MarkFromRootsVerifyClosure markFromRootsClosure(this, _span,
verification_mark_bm(), markBitMap(), verification_mark_stack());
assert(_restart_addr == NULL, "Expected pre-condition");
@@ -2910,14 +2918,15 @@
void work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl);
};
// Parallel initial mark task
class CMSParInitialMarkTask: public CMSParMarkTask {
+ StrongRootsScope* _strong_roots_scope;
public:
- CMSParInitialMarkTask(CMSCollector* collector, uint n_workers) :
- CMSParMarkTask("Scan roots and young gen for initial mark in parallel",
- collector, n_workers) {}
+ CMSParInitialMarkTask(CMSCollector* collector, StrongRootsScope* strong_roots_scope, uint n_workers) :
+ CMSParMarkTask("Scan roots and young gen for initial mark in parallel", collector, n_workers),
+ _strong_roots_scope(strong_roots_scope) {}
void work(uint worker_id);
};
// Checkpoint the roots into this generation from outside
// this generation. [Note this initial checkpoint need only
@@ -3001,28 +3010,32 @@
if (CMSParallelInitialMarkEnabled) {
// The parallel version.
FlexibleWorkGang* workers = gch->workers();
assert(workers != NULL, "Need parallel worker threads.");
uint n_workers = workers->active_workers();
- CMSParInitialMarkTask tsk(this, n_workers);
+
+ StrongRootsScope srs(n_workers);
+
+ CMSParInitialMarkTask tsk(this, &srs, n_workers);
gch->set_par_threads(n_workers);
initialize_sequential_subtasks_for_young_gen_rescan(n_workers);
if (n_workers > 1) {
- StrongRootsScope srs;
workers->run_task(&tsk);
} else {
- StrongRootsScope srs;
tsk.work(0);
}
gch->set_par_threads(0);
} else {
// The serial version.
CLDToOopClosure cld_closure(¬Older, true);
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
- gch->gen_process_roots(_cmsGen->level(),
+
+ StrongRootsScope srs(1);
+
+ gch->gen_process_roots(&srs,
+ _cmsGen->level(),
true, // younger gens are roots
- true, // activate StrongRootsScope
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
NULL,
&cld_closure);
@@ -4449,13 +4462,13 @@
_timer.reset();
_timer.start();
CLDToOopClosure cld_closure(&par_mri_cl, true);
- gch->gen_process_roots(_collector->_cmsGen->level(),
+ gch->gen_process_roots(_strong_roots_scope,
+ _collector->_cmsGen->level(),
false, // yg was scanned above
- false, // this is parallel code
GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(),
&par_mri_cl,
NULL,
&cld_closure);
@@ -4475,23 +4488,26 @@
CompactibleFreeListSpace* _cms_space;
// The per-thread work queues, available here for stealing.
OopTaskQueueSet* _task_queues;
ParallelTaskTerminator _term;
+ StrongRootsScope* _strong_roots_scope;
public:
// A value of 0 passed to n_workers will cause the number of
// workers to be taken from the active workers in the work gang.
CMSParRemarkTask(CMSCollector* collector,
CompactibleFreeListSpace* cms_space,
uint n_workers, FlexibleWorkGang* workers,
- OopTaskQueueSet* task_queues):
+ OopTaskQueueSet* task_queues,
+ StrongRootsScope* strong_roots_scope):
CMSParMarkTask("Rescan roots and grey objects in parallel",
collector, n_workers),
_cms_space(cms_space),
_task_queues(task_queues),
- _term(n_workers, task_queues) { }
+ _term(n_workers, task_queues),
+ _strong_roots_scope(strong_roots_scope) { }
OopTaskQueueSet* task_queues() { return _task_queues; }
OopTaskQueue* work_queue(int i) { return task_queues()->queue(i); }
@@ -4585,13 +4601,13 @@
}
// ---------- remaining roots --------------
_timer.reset();
_timer.start();
- gch->gen_process_roots(_collector->_cmsGen->level(),
+ gch->gen_process_roots(_strong_roots_scope,
+ _collector->_cmsGen->level(),
false, // yg was scanned above
- false, // this is parallel code
GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(),
&par_mrias_cl,
NULL,
NULL); // The dirty klasses will be handled below
@@ -5065,13 +5081,13 @@
n_workers = ParallelGCThreads;
workers->set_active_workers(n_workers);
}
CompactibleFreeListSpace* cms_space = _cmsGen->cmsSpace();
- CMSParRemarkTask tsk(this,
- cms_space,
- n_workers, workers, task_queues());
+ StrongRootsScope srs(n_workers);
+
+ CMSParRemarkTask tsk(this, cms_space, n_workers, workers, task_queues(), &srs);
// Set up for parallel process_roots work.
gch->set_par_threads(n_workers);
// We won't be iterating over the cards in the card table updating
// the younger_gen cards, so we shouldn't call the following else
@@ -5102,15 +5118,13 @@
if (n_workers > 1) {
// Make refs discovery MT-safe, if it isn't already: it may not
// necessarily be so, since it's possible that we are doing
// ST marking.
ReferenceProcessorMTDiscoveryMutator mt(ref_processor(), true);
- StrongRootsScope srs;
workers->run_task(&tsk);
} else {
ReferenceProcessorMTDiscoveryMutator mt(ref_processor(), false);
- StrongRootsScope srs;
tsk.work(0);
}
gch->set_par_threads(0); // 0 ==> non-parallel.
// restore, single-threaded for now, any preserved marks
@@ -5174,15 +5188,15 @@
GCTraceTime t("root rescan", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());
verify_work_stacks_empty();
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
- StrongRootsScope srs;
+ StrongRootsScope srs(1);
- gch->gen_process_roots(_cmsGen->level(),
+ gch->gen_process_roots(&srs,
+ _cmsGen->level(),
true, // younger gens as roots
- false, // use the local StrongRootsScope
GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
&mrias_cl,
NULL,
NULL); // The dirty klasses will be handled below
< prev index next >