mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
Create a G1RootProcessor and move SharedHeap root processing to GenCollectedHeap Reviewed-by: brutisso, tschatzl, ehelin
This commit is contained in:
parent
68b1e61637
commit
f5292016ee
15 changed files with 645 additions and 596 deletions
|
@ -61,18 +61,18 @@ class KlassClosure;
|
|||
// counts the number of tasks that have been done and then reset
|
||||
// the SubTasksDone so that it can be used again. When the number of
|
||||
// tasks is set to the number of GC workers, then _n_threads must
|
||||
// be set to the number of active GC workers. G1CollectedHeap,
|
||||
// HRInto_G1RemSet, GenCollectedHeap and SharedHeap have SubTasksDone.
|
||||
// This seems too many.
|
||||
// be set to the number of active GC workers. G1RootProcessor and
|
||||
// GenCollectedHeap have SubTasksDone.
|
||||
// 3) SequentialSubTasksDone has an _n_threads that is used in
|
||||
// a way similar to SubTasksDone and has the same dependency on the
|
||||
// number of active GC workers. CompactibleFreeListSpace and Space
|
||||
// have SequentialSubTasksDone's.
|
||||
// Example of using SubTasksDone and SequentialSubTasksDone
|
||||
// G1CollectedHeap::g1_process_roots()
|
||||
// to SharedHeap::process_roots() and uses
|
||||
// SubTasksDone* _process_strong_tasks to claim tasks.
|
||||
// process_roots() calls
|
||||
//
|
||||
// Examples of using SubTasksDone and SequentialSubTasksDone:
|
||||
// G1RootProcessor and GenCollectedHeap::process_roots() use
|
||||
// SubTasksDone* _process_strong_tasks to claim tasks for workers
|
||||
//
|
||||
// GenCollectedHeap::gen_process_roots() calls
|
||||
// rem_set()->younger_refs_iterate()
|
||||
// to scan the card table and which eventually calls down into
|
||||
// CardTableModRefBS::par_non_clean_card_iterate_work(). This method
|
||||
|
@ -104,10 +104,6 @@ class SharedHeap : public CollectedHeap {
|
|||
friend class VM_GC_Operation;
|
||||
friend class VM_CGC_Operation;
|
||||
|
||||
private:
|
||||
// For claiming strong_roots tasks.
|
||||
SubTasksDone* _process_strong_tasks;
|
||||
|
||||
protected:
|
||||
// There should be only a single instance of "SharedHeap" in a program.
|
||||
// This is enforced with the protected constructor below, which will also
|
||||
|
@ -140,7 +136,6 @@ public:
|
|||
static SharedHeap* heap() { return _sh; }
|
||||
|
||||
void set_barrier_set(BarrierSet* bs);
|
||||
SubTasksDone* process_strong_tasks() { return _process_strong_tasks; }
|
||||
|
||||
// Does operations required after initialization has been done.
|
||||
virtual void post_initialize();
|
||||
|
@ -193,69 +188,19 @@ public:
|
|||
// strong_roots_prologue calls change_strong_roots_parity, if
|
||||
// parallel tasks are enabled.
|
||||
class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
|
||||
// Used to implement the Thread work barrier.
|
||||
static Monitor* _lock;
|
||||
|
||||
SharedHeap* _sh;
|
||||
volatile jint _n_workers_done_with_threads;
|
||||
|
||||
public:
|
||||
StrongRootsScope(SharedHeap* heap, bool activate = true);
|
||||
~StrongRootsScope();
|
||||
|
||||
// Mark that this thread is done with the Threads work.
|
||||
void mark_worker_done_with_threads(uint n_workers);
|
||||
// Wait until all n_workers are done with the Threads work.
|
||||
void wait_until_all_workers_done_with_threads(uint n_workers);
|
||||
};
|
||||
friend class StrongRootsScope;
|
||||
|
||||
// The current active StrongRootScope
|
||||
StrongRootsScope* _strong_roots_scope;
|
||||
|
||||
StrongRootsScope* active_strong_roots_scope() const;
|
||||
|
||||
private:
|
||||
void register_strong_roots_scope(StrongRootsScope* scope);
|
||||
void unregister_strong_roots_scope(StrongRootsScope* scope);
|
||||
void change_strong_roots_parity();
|
||||
|
||||
public:
|
||||
enum ScanningOption {
|
||||
SO_None = 0x0,
|
||||
SO_AllCodeCache = 0x8,
|
||||
SO_ScavengeCodeCache = 0x10
|
||||
};
|
||||
|
||||
FlexibleWorkGang* workers() const { return _workers; }
|
||||
|
||||
// Invoke the "do_oop" method the closure "roots" on all root locations.
|
||||
// The "so" argument determines which roots the closure is applied to:
|
||||
// "SO_None" does none;
|
||||
// "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
|
||||
// "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
|
||||
void process_roots(bool activate_scope,
|
||||
ScanningOption so,
|
||||
OopClosure* strong_roots,
|
||||
OopClosure* weak_roots,
|
||||
CLDClosure* strong_cld_closure,
|
||||
CLDClosure* weak_cld_closure,
|
||||
CodeBlobClosure* code_roots);
|
||||
void process_all_roots(bool activate_scope,
|
||||
ScanningOption so,
|
||||
OopClosure* roots,
|
||||
CLDClosure* cld_closure,
|
||||
CodeBlobClosure* code_roots);
|
||||
void process_strong_roots(bool activate_scope,
|
||||
ScanningOption so,
|
||||
OopClosure* roots,
|
||||
CLDClosure* cld_closure,
|
||||
CodeBlobClosure* code_roots);
|
||||
|
||||
|
||||
// Apply "root_closure" to the JNI weak roots..
|
||||
void process_weak_roots(OopClosure* root_closure);
|
||||
|
||||
// The functions below are helper functions that a subclass of
|
||||
// "SharedHeap" can use in the implementation of its virtual
|
||||
// functions.
|
||||
|
@ -270,9 +215,6 @@ public:
|
|||
// (such as process roots) subsequently.
|
||||
virtual void set_par_threads(uint t);
|
||||
|
||||
int n_termination();
|
||||
void set_n_termination(int t);
|
||||
|
||||
//
|
||||
// New methods from CollectedHeap
|
||||
//
|
||||
|
@ -284,8 +226,4 @@ public:
|
|||
size_t capacity);
|
||||
};
|
||||
|
||||
inline SharedHeap::ScanningOption operator|(SharedHeap::ScanningOption so0, SharedHeap::ScanningOption so1) {
|
||||
return static_cast<SharedHeap::ScanningOption>(static_cast<int>(so0) | static_cast<int>(so1));
|
||||
}
|
||||
|
||||
#endif // SHARE_VM_MEMORY_SHAREDHEAP_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue