comparison src/share/vm/memory/sharedHeap.cpp @ 4095:bca17e38de00

6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads Summary: Select number of GC threads dynamically based on heap usage and number of Java threads Reviewed-by: johnc, ysr, jcoomes
author jmasa
date Tue, 09 Aug 2011 10:16:01 -0700
parents c2bf0120ee5d
children 441e946dc1af
comparison
equal deleted inserted replaced
4094:3a298e04d914 4095:bca17e38de00
56 CollectedHeap(), 56 CollectedHeap(),
57 _collector_policy(policy_), 57 _collector_policy(policy_),
58 _perm_gen(NULL), _rem_set(NULL), 58 _perm_gen(NULL), _rem_set(NULL),
59 _strong_roots_parity(0), 59 _strong_roots_parity(0),
60 _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)), 60 _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)),
61 _n_par_threads(0),
62 _workers(NULL) 61 _workers(NULL)
63 { 62 {
64 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) { 63 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) {
65 vm_exit_during_initialization("Failed necessary allocation."); 64 vm_exit_during_initialization("Failed necessary allocation.");
66 } 65 }
78 _workers->initialize_workers(); 77 _workers->initialize_workers();
79 } 78 }
80 } 79 }
81 } 80 }
82 81
82 int SharedHeap::n_termination() {
83 return _process_strong_tasks->n_threads();
84 }
85
86 void SharedHeap::set_n_termination(int t) {
87 _process_strong_tasks->set_n_threads(t);
88 }
89
83 bool SharedHeap::heap_lock_held_for_gc() { 90 bool SharedHeap::heap_lock_held_for_gc() {
84 Thread* t = Thread::current(); 91 Thread* t = Thread::current();
85 return Heap_lock->owned_by_self() 92 return Heap_lock->owned_by_self()
86 || ( (t->is_GC_task_thread() || t->is_VM_thread()) 93 || ( (t->is_GC_task_thread() || t->is_VM_thread())
87 && _thread_holds_heap_lock_for_gc); 94 && _thread_holds_heap_lock_for_gc);
142 CodeBlobClosure* code_roots, 149 CodeBlobClosure* code_roots,
143 OopsInGenClosure* perm_blk) { 150 OopsInGenClosure* perm_blk) {
144 StrongRootsScope srs(this, activate_scope); 151 StrongRootsScope srs(this, activate_scope);
145 // General strong roots. 152 // General strong roots.
146 assert(_strong_roots_parity != 0, "must have called prologue code"); 153 assert(_strong_roots_parity != 0, "must have called prologue code");
154 // _n_termination for _process_strong_tasks should be set up stream
155 // in a method not running in a GC worker. Otherwise the GC worker
156 // could be trying to change the termination condition while the task
157 // is executing in another GC worker.
147 if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) { 158 if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) {
148 Universe::oops_do(roots); 159 Universe::oops_do(roots);
149 // Consider perm-gen discovered lists to be strong. 160 // Consider perm-gen discovered lists to be strong.
150 perm_gen()->ref_processor()->weak_oops_do(roots); 161 perm_gen()->ref_processor()->weak_oops_do(roots);
151 } 162 }