8209189: Make CompiledMethod::do_unloading more concurrent

Reviewed-by: kvn, coleenp
This commit is contained in:
Erik Österlund 2018-11-02 08:33:59 +01:00
parent 97d3dc7902
commit 25f14cd757
15 changed files with 309 additions and 447 deletions

View file

@ -144,7 +144,6 @@ class CodeBlob_sizes {
address CodeCache::_low_bound = 0;
address CodeCache::_high_bound = 0;
int CodeCache::_number_of_nmethods_with_dependencies = 0;
bool CodeCache::_needs_cache_clean = false;
nmethod* CodeCache::_scavenge_root_nmethods = NULL;
// Initialize arrays of CodeHeap subsets
@ -683,17 +682,11 @@ int CodeCache::alignment_offset() {
// Mark nmethods for unloading if they contain otherwise unreachable oops.
void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) {
assert_locked_or_safepoint(CodeCache_lock);
UnloadingScope scope(is_alive);
CompiledMethodIterator iter;
while(iter.next_alive()) {
iter.method()->do_unloading(is_alive);
iter.method()->do_unloading(unloading_occurred);
}
// Now that all the unloaded nmethods are known, cleanup caches
// before CLDG is purged.
// This is another code cache walk but it is moved from gc_epilogue.
// G1 does a parallel walk of the nmethods so cleans them up
// as it goes and doesn't call this.
do_unloading_nmethod_caches(unloading_occurred);
}
void CodeCache::blobs_do(CodeBlobClosure* f) {
@ -908,28 +901,14 @@ void CodeCache::gc_epilogue() {
prune_scavenge_root_nmethods();
}
uint8_t CodeCache::_unloading_cycle = 1;
void CodeCache::do_unloading_nmethod_caches(bool class_unloading_occurred) {
assert_locked_or_safepoint(CodeCache_lock);
// Even if classes are not unloaded, there may have been some nmethods that are
// unloaded because oops in them are no longer reachable.
NOT_DEBUG(if (needs_cache_clean() || class_unloading_occurred)) {
CompiledMethodIterator iter;
while(iter.next_alive()) {
CompiledMethod* cm = iter.method();
assert(!cm->is_unloaded(), "Tautology");
DEBUG_ONLY(if (needs_cache_clean() || class_unloading_occurred)) {
// Clean up both unloaded klasses from nmethods and unloaded nmethods
// from inline caches.
cm->unload_nmethod_caches(/*parallel*/false, class_unloading_occurred);
}
DEBUG_ONLY(cm->verify());
DEBUG_ONLY(cm->verify_oop_relocations());
}
void CodeCache::increment_unloading_cycle() {
if (_unloading_cycle == 1) {
_unloading_cycle = 2;
} else {
_unloading_cycle = 1;
}
set_needs_cache_clean(false);
verify_icholder_relocations();
}
void CodeCache::verify_oops() {