mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8209189: Make CompiledMethod::do_unloading more concurrent
Reviewed-by: kvn, coleenp
This commit is contained in:
parent
97d3dc7902
commit
25f14cd757
15 changed files with 309 additions and 447 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "classfile/stringTable.hpp"
|
||||
#include "code/codeCache.hpp"
|
||||
#include "gc/shared/parallelCleaning.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "logging/log.hpp"
|
||||
|
||||
|
@ -67,14 +68,11 @@ void StringCleaningTask::work(uint worker_id) {
|
|||
}
|
||||
|
||||
CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, BoolObjectClosure* is_alive, bool unloading_occurred) :
|
||||
_is_alive(is_alive),
|
||||
_unloading_scope(is_alive),
|
||||
_unloading_occurred(unloading_occurred),
|
||||
_num_workers(num_workers),
|
||||
_first_nmethod(NULL),
|
||||
_claimed_nmethod(NULL),
|
||||
_postponed_list(NULL),
|
||||
_num_entered_barrier(0) {
|
||||
CompiledMethod::increase_unloading_clock();
|
||||
_claimed_nmethod(NULL) {
|
||||
// Get first alive nmethod
|
||||
CompiledMethodIterator iter = CompiledMethodIterator();
|
||||
if(iter.next_alive()) {
|
||||
|
@ -86,7 +84,6 @@ CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, BoolObjectClosu
|
|||
CodeCacheUnloadingTask::~CodeCacheUnloadingTask() {
|
||||
CodeCache::verify_clean_inline_caches();
|
||||
|
||||
CodeCache::set_needs_cache_clean(false);
|
||||
guarantee(CodeCache::scavenge_root_nmethods() == NULL, "Must be");
|
||||
|
||||
CodeCache::verify_icholder_relocations();
|
||||
|
@ -94,31 +91,6 @@ CodeCacheUnloadingTask::~CodeCacheUnloadingTask() {
|
|||
|
||||
Monitor* CodeCacheUnloadingTask::_lock = new Monitor(Mutex::leaf, "Code Cache Unload lock", false, Monitor::_safepoint_check_never);
|
||||
|
||||
void CodeCacheUnloadingTask::add_to_postponed_list(CompiledMethod* nm) {
|
||||
CompiledMethod* old;
|
||||
do {
|
||||
old = _postponed_list;
|
||||
nm->set_unloading_next(old);
|
||||
} while (Atomic::cmpxchg(nm, &_postponed_list, old) != old);
|
||||
}
|
||||
|
||||
void CodeCacheUnloadingTask::clean_nmethod(CompiledMethod* nm) {
|
||||
bool postponed = nm->do_unloading_parallel(_is_alive, _unloading_occurred);
|
||||
|
||||
if (postponed) {
|
||||
// This nmethod referred to an nmethod that has not been cleaned/unloaded yet.
|
||||
add_to_postponed_list(nm);
|
||||
}
|
||||
|
||||
// Mark that this nmethod has been cleaned/unloaded.
|
||||
// After this call, it will be safe to ask if this nmethod was unloaded or not.
|
||||
nm->set_unloading_clock(CompiledMethod::global_unloading_clock());
|
||||
}
|
||||
|
||||
void CodeCacheUnloadingTask::clean_nmethod_postponed(CompiledMethod* nm) {
|
||||
nm->do_unloading_parallel_postponed();
|
||||
}
|
||||
|
||||
void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, int *num_claimed_nmethods) {
|
||||
CompiledMethod* first;
|
||||
CompiledMethodIterator last;
|
||||
|
@ -143,44 +115,10 @@ void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, i
|
|||
} while (Atomic::cmpxchg(last.method(), &_claimed_nmethod, first) != first);
|
||||
}
|
||||
|
||||
CompiledMethod* CodeCacheUnloadingTask::claim_postponed_nmethod() {
|
||||
CompiledMethod* claim;
|
||||
CompiledMethod* next;
|
||||
|
||||
do {
|
||||
claim = _postponed_list;
|
||||
if (claim == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
next = claim->unloading_next();
|
||||
|
||||
} while (Atomic::cmpxchg(next, &_postponed_list, claim) != claim);
|
||||
|
||||
return claim;
|
||||
}
|
||||
|
||||
void CodeCacheUnloadingTask::barrier_mark(uint worker_id) {
|
||||
MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag);
|
||||
_num_entered_barrier++;
|
||||
if (_num_entered_barrier == _num_workers) {
|
||||
ml.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
void CodeCacheUnloadingTask::barrier_wait(uint worker_id) {
|
||||
if (_num_entered_barrier < _num_workers) {
|
||||
MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag);
|
||||
while (_num_entered_barrier < _num_workers) {
|
||||
ml.wait(Mutex::_no_safepoint_check_flag, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CodeCacheUnloadingTask::work_first_pass(uint worker_id) {
|
||||
void CodeCacheUnloadingTask::work(uint worker_id) {
|
||||
// The first nmethods is claimed by the first worker.
|
||||
if (worker_id == 0 && _first_nmethod != NULL) {
|
||||
clean_nmethod(_first_nmethod);
|
||||
_first_nmethod->do_unloading(_unloading_occurred);
|
||||
_first_nmethod = NULL;
|
||||
}
|
||||
|
||||
|
@ -195,19 +133,11 @@ void CodeCacheUnloadingTask::work_first_pass(uint worker_id) {
|
|||
}
|
||||
|
||||
for (int i = 0; i < num_claimed_nmethods; i++) {
|
||||
clean_nmethod(claimed_nmethods[i]);
|
||||
claimed_nmethods[i]->do_unloading(_unloading_occurred);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CodeCacheUnloadingTask::work_second_pass(uint worker_id) {
|
||||
CompiledMethod* nm;
|
||||
// Take care of postponed nmethods.
|
||||
while ((nm = claim_postponed_nmethod()) != NULL) {
|
||||
clean_nmethod_postponed(nm);
|
||||
}
|
||||
}
|
||||
|
||||
KlassCleaningTask::KlassCleaningTask() :
|
||||
_clean_klass_tree_claimed(0),
|
||||
_klass_iterator() {
|
||||
|
@ -257,21 +187,11 @@ ParallelCleaningTask::ParallelCleaningTask(BoolObjectClosure* is_alive,
|
|||
|
||||
// The parallel work done by all worker threads.
|
||||
void ParallelCleaningTask::work(uint worker_id) {
|
||||
// Do first pass of code cache cleaning.
|
||||
_code_cache_task.work_first_pass(worker_id);
|
||||
// Do first pass of code cache cleaning.
|
||||
_code_cache_task.work(worker_id);
|
||||
|
||||
// Let the threads mark that the first pass is done.
|
||||
_code_cache_task.barrier_mark(worker_id);
|
||||
|
||||
// Clean the Strings and Symbols.
|
||||
_string_task.work(worker_id);
|
||||
|
||||
// Wait for all workers to finish the first code cache cleaning pass.
|
||||
_code_cache_task.barrier_wait(worker_id);
|
||||
|
||||
// Do the second code cache cleaning work, which realize on
|
||||
// the liveness information gathered during the first pass.
|
||||
_code_cache_task.work_second_pass(worker_id);
|
||||
// Clean the Strings and Symbols.
|
||||
_string_task.work(worker_id);
|
||||
|
||||
// Clean all klasses that were not unloaded.
|
||||
// The weak metadata in klass doesn't need to be
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue