8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled

Reviewed-by: mgerdin, tschatzl, stefank
This commit is contained in:
Stefan Johansson 2016-10-05 13:35:57 +02:00
parent 9ab6c1b05c
commit 3c1ab21ffa
4 changed files with 69 additions and 33 deletions

View file

@ -2340,7 +2340,7 @@ void CMSCollector::verify_after_remark_work_1() {
{ {
StrongRootsScope srs(1); StrongRootsScope srs(1);
gch->old_process_roots(&srs, gch->cms_process_roots(&srs,
true, // young gen as roots true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()), GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(), should_unload_classes(),
@ -2412,7 +2412,7 @@ void CMSCollector::verify_after_remark_work_2() {
{ {
StrongRootsScope srs(1); StrongRootsScope srs(1);
gch->old_process_roots(&srs, gch->cms_process_roots(&srs,
true, // young gen as roots true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()), GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(), should_unload_classes(),
@ -2899,7 +2899,7 @@ void CMSCollector::checkpointRootsInitialWork() {
StrongRootsScope srs(1); StrongRootsScope srs(1);
gch->old_process_roots(&srs, gch->cms_process_roots(&srs,
true, // young gen as roots true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()), GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(), should_unload_classes(),
@ -4284,7 +4284,7 @@ void CMSParInitialMarkTask::work(uint worker_id) {
CLDToOopClosure cld_closure(&par_mri_cl, true); CLDToOopClosure cld_closure(&par_mri_cl, true);
gch->old_process_roots(_strong_roots_scope, gch->cms_process_roots(_strong_roots_scope,
false, // yg was scanned above false, // yg was scanned above
GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(), _collector->should_unload_classes(),
@ -4413,7 +4413,7 @@ void CMSParRemarkTask::work(uint worker_id) {
// ---------- remaining roots -------------- // ---------- remaining roots --------------
_timer.reset(); _timer.reset();
_timer.start(); _timer.start();
gch->old_process_roots(_strong_roots_scope, gch->cms_process_roots(_strong_roots_scope,
false, // yg was scanned above false, // yg was scanned above
GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(), _collector->should_unload_classes(),
@ -4960,7 +4960,7 @@ void CMSCollector::do_remark_non_parallel() {
gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
StrongRootsScope srs(1); StrongRootsScope srs(1);
gch->old_process_roots(&srs, gch->cms_process_roots(&srs,
true, // young gen as roots true, // young gen as roots
GenCollectedHeap::ScanningOption(roots_scanning_options()), GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(), should_unload_classes(),

View file

@ -196,12 +196,13 @@ void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
{ {
StrongRootsScope srs(1); StrongRootsScope srs(1);
gch->old_process_roots(&srs, gch->full_process_roots(&srs,
false, // Younger gens are not roots. false, // not the adjust phase
GenCollectedHeap::SO_None, GenCollectedHeap::SO_None,
ClassUnloading, ClassUnloading, // only strong roots if ClassUnloading
&follow_root_closure, // is enabled
&follow_cld_closure); &follow_root_closure,
&follow_cld_closure);
} }
// Process reference objects found during marking // Process reference objects found during marking
@ -293,12 +294,12 @@ void GenMarkSweep::mark_sweep_phase3() {
{ {
StrongRootsScope srs(1); StrongRootsScope srs(1);
gch->old_process_roots(&srs, gch->full_process_roots(&srs,
false, // Younger gens are not roots. true, // this is the adjust phase
GenCollectedHeap::SO_AllCodeCache, GenCollectedHeap::SO_AllCodeCache,
false, false, // all roots
&adjust_pointer_closure, &adjust_pointer_closure,
&adjust_cld_closure); &adjust_cld_closure);
} }
gch->gen_process_weak_roots(&adjust_pointer_closure); gch->gen_process_weak_roots(&adjust_pointer_closure);

View file

@ -613,16 +613,6 @@ void GenCollectedHeap::process_roots(StrongRootsScope* scope,
SystemDictionary::roots_oops_do(strong_roots, weak_roots); SystemDictionary::roots_oops_do(strong_roots, weak_roots);
} }
// All threads execute the following. A specific chunk of buckets
// from the StringTable are the individual tasks.
if (weak_roots != NULL) {
if (is_par) {
StringTable::possibly_parallel_oops_do(weak_roots);
} else {
StringTable::oops_do(weak_roots);
}
}
if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) { if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) {
if (so & SO_ScavengeCodeCache) { if (so & SO_ScavengeCodeCache) {
assert(code_roots != NULL, "must supply closure for code cache"); assert(code_roots != NULL, "must supply closure for code cache");
@ -644,6 +634,18 @@ void GenCollectedHeap::process_roots(StrongRootsScope* scope,
} }
} }
void GenCollectedHeap::process_string_table_roots(StrongRootsScope* scope,
OopClosure* root_closure) {
assert(root_closure != NULL, "Must be set");
// All threads execute the following. A specific chunk of buckets
// from the StringTable are the individual tasks.
if (scope->n_threads() > 1) {
StringTable::possibly_parallel_oops_do(root_closure);
} else {
StringTable::oops_do(root_closure);
}
}
void GenCollectedHeap::young_process_roots(StrongRootsScope* scope, void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
OopsInGenClosure* root_closure, OopsInGenClosure* root_closure,
OopsInGenClosure* old_gen_closure, OopsInGenClosure* old_gen_closure,
@ -652,6 +654,7 @@ void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
process_roots(scope, SO_ScavengeCodeCache, root_closure, root_closure, process_roots(scope, SO_ScavengeCodeCache, root_closure, root_closure,
cld_closure, cld_closure, &mark_code_closure); cld_closure, cld_closure, &mark_code_closure);
process_string_table_roots(scope, root_closure);
if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
root_closure->reset_generation(); root_closure->reset_generation();
@ -666,19 +669,20 @@ void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
_process_strong_tasks->all_tasks_completed(scope->n_threads()); _process_strong_tasks->all_tasks_completed(scope->n_threads());
} }
void GenCollectedHeap::old_process_roots(StrongRootsScope* scope, void GenCollectedHeap::cms_process_roots(StrongRootsScope* scope,
bool young_gen_as_roots, bool young_gen_as_roots,
ScanningOption so, ScanningOption so,
bool only_strong_roots, bool only_strong_roots,
OopsInGenClosure* root_closure, OopsInGenClosure* root_closure,
CLDClosure* cld_closure) { CLDClosure* cld_closure) {
const bool is_moving_collection = !only_strong_roots && !young_gen_as_roots; MarkingCodeBlobClosure mark_code_closure(root_closure, !CodeBlobToOopClosure::FixRelocations);
MarkingCodeBlobClosure mark_code_closure(root_closure, is_moving_collection);
OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure; OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure; CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure); process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
if (!only_strong_roots) {
process_string_table_roots(scope, root_closure);
}
if (young_gen_as_roots && if (young_gen_as_roots &&
!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
@ -690,6 +694,27 @@ void GenCollectedHeap::old_process_roots(StrongRootsScope* scope,
_process_strong_tasks->all_tasks_completed(scope->n_threads()); _process_strong_tasks->all_tasks_completed(scope->n_threads());
} }
void GenCollectedHeap::full_process_roots(StrongRootsScope* scope,
bool is_adjust_phase,
ScanningOption so,
bool only_strong_roots,
OopsInGenClosure* root_closure,
CLDClosure* cld_closure) {
MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase);
OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
if (is_adjust_phase) {
// We never treat the string table as roots during marking
// for the full gc, so we only need to process it during
// the adjust phase.
process_string_table_roots(scope, root_closure);
}
_process_strong_tasks->all_tasks_completed(scope->n_threads());
}
void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) { void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
JNIHandles::weak_oops_do(root_closure); JNIHandles::weak_oops_do(root_closure);
_young_gen->ref_processor()->weak_oops_do(root_closure); _young_gen->ref_processor()->weak_oops_do(root_closure);

View file

@ -392,6 +392,9 @@ public:
CLDClosure* weak_cld_closure, CLDClosure* weak_cld_closure,
CodeBlobToOopClosure* code_roots); CodeBlobToOopClosure* code_roots);
void process_string_table_roots(StrongRootsScope* scope,
OopClosure* root_closure);
public: public:
void young_process_roots(StrongRootsScope* scope, void young_process_roots(StrongRootsScope* scope,
OopsInGenClosure* root_closure, OopsInGenClosure* root_closure,
@ -403,13 +406,20 @@ public:
// scan the younger generations itself. (For example, a generation might // scan the younger generations itself. (For example, a generation might
// explicitly mark reachable objects in younger generations, to avoid // explicitly mark reachable objects in younger generations, to avoid
// excess storage retention.) // excess storage retention.)
void old_process_roots(StrongRootsScope* scope, void cms_process_roots(StrongRootsScope* scope,
bool young_gen_as_roots, bool young_gen_as_roots,
ScanningOption so, ScanningOption so,
bool only_strong_roots, bool only_strong_roots,
OopsInGenClosure* root_closure, OopsInGenClosure* root_closure,
CLDClosure* cld_closure); CLDClosure* cld_closure);
void full_process_roots(StrongRootsScope* scope,
bool is_adjust_phase,
ScanningOption so,
bool only_strong_roots,
OopsInGenClosure* root_closure,
CLDClosure* cld_closure);
// Apply "root_closure" to all the weak roots of the system. // Apply "root_closure" to all the weak roots of the system.
// These include JNI weak roots, string table, // These include JNI weak roots, string table,
// and referents of reachable weak refs. // and referents of reachable weak refs.