8072498: Multi-thread JNI weak reference processing

Add parallel processing support to WeakProcessor.

Reviewed-by: tschatzl, sjohanss
This commit is contained in:
Kim Barrett 2018-08-28 12:57:40 -04:00
parent 49b859b9d3
commit 1b02e70184
17 changed files with 863 additions and 58 deletions

View file

@ -25,8 +25,12 @@
#ifndef SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
#define SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
#include "gc/shared/oopStorageParState.hpp"
#include "gc/shared/workgroup.hpp"
#include "memory/allocation.hpp"
#include "memory/iterator.hpp"
class WeakProcessorPhaseTimes;
class WorkGang;
// Helper class to aid in root scanning and cleaning of weak oops in the VM.
//
@ -41,6 +45,51 @@ public:
// Visit all oop*s and apply the given closure.
static void oops_do(OopClosure* closure);
// Parallel version. Uses ergo_workers(), active workers, and
// phase_time's max_threads to determine the number of threads to use.
// IsAlive must be derived from BoolObjectClosure.
// KeepAlive must be derived from OopClosure.
template<typename IsAlive, typename KeepAlive>
static void weak_oops_do(WorkGang* workers,
IsAlive* is_alive,
KeepAlive* keep_alive,
WeakProcessorPhaseTimes* phase_times);
// Convenience parallel version. Uses ergo_workers() and active workers
// to determine the number of threads to run. Implicitly logs phase times.
// IsAlive must be derived from BoolObjectClosure.
// KeepAlive must be derived from OopClosure.
template<typename IsAlive, typename KeepAlive>
static void weak_oops_do(WorkGang* workers,
IsAlive* is_alive,
KeepAlive* keep_alive,
uint indent_log);
static uint ergo_workers(uint max_workers);
class Task;
private:
class GangTask;
};
class WeakProcessor::Task {
typedef OopStorage::ParState<false, false> StorageState;
WeakProcessorPhaseTimes* _phase_times;
uint _nworkers;
SubTasksDone _serial_phases_done;
StorageState* _storage_states;
void initialize();
public:
Task(uint nworkers); // No time tracking.
Task(WeakProcessorPhaseTimes* phase_times, uint nworkers);
~Task();
template<typename IsAlive, typename KeepAlive>
void work(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
};
#endif // SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP