55 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) { |
55 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) { |
56 vm_exit_during_initialization("Failed necessary allocation."); |
56 vm_exit_during_initialization("Failed necessary allocation."); |
57 } |
57 } |
58 _sh = this; // ch is static, should be set only once. |
58 _sh = this; // ch is static, should be set only once. |
59 if ((UseParNewGC || |
59 if ((UseParNewGC || |
60 (UseConcMarkSweepGC && CMSParallelRemarkEnabled)) && |
60 (UseConcMarkSweepGC && CMSParallelRemarkEnabled) || |
|
61 UseG1GC) && |
61 ParallelGCThreads > 0) { |
62 ParallelGCThreads > 0) { |
62 _workers = new WorkGang("Parallel GC Threads", ParallelGCThreads, true); |
63 _workers = new WorkGang("Parallel GC Threads", ParallelGCThreads, |
|
64 /* are_GC_task_threads */true, |
|
65 /* are_ConcurrentGC_threads */false); |
63 if (_workers == NULL) { |
66 if (_workers == NULL) { |
64 vm_exit_during_initialization("Failed necessary allocation."); |
67 vm_exit_during_initialization("Failed necessary allocation."); |
65 } |
68 } |
66 } |
69 } |
67 } |
70 } |
68 |
71 |
|
72 bool SharedHeap::heap_lock_held_for_gc() { |
|
73 Thread* t = Thread::current(); |
|
74 return Heap_lock->owned_by_self() |
|
75 || ( (t->is_GC_task_thread() || t->is_VM_thread()) |
|
76 && _thread_holds_heap_lock_for_gc); |
|
77 } |
69 |
78 |
70 void SharedHeap::set_par_threads(int t) { |
79 void SharedHeap::set_par_threads(int t) { |
71 _n_par_threads = t; |
80 _n_par_threads = t; |
72 _process_strong_tasks->set_par_threads(t); |
81 _process_strong_tasks->set_par_threads(t); |
73 } |
82 } |
278 mr.word_size()); |
287 mr.word_size()); |
279 } |
288 } |
280 } |
289 } |
281 |
290 |
282 // Some utilities. |
291 // Some utilities. |
283 void SharedHeap::print_size_transition(size_t bytes_before, |
292 void SharedHeap::print_size_transition(outputStream* out, |
|
293 size_t bytes_before, |
284 size_t bytes_after, |
294 size_t bytes_after, |
285 size_t capacity) { |
295 size_t capacity) { |
286 tty->print(" %d%s->%d%s(%d%s)", |
296 out->print(" %d%s->%d%s(%d%s)", |
287 byte_size_in_proper_unit(bytes_before), |
297 byte_size_in_proper_unit(bytes_before), |
288 proper_unit_for_byte_size(bytes_before), |
298 proper_unit_for_byte_size(bytes_before), |
289 byte_size_in_proper_unit(bytes_after), |
299 byte_size_in_proper_unit(bytes_after), |
290 proper_unit_for_byte_size(bytes_after), |
300 proper_unit_for_byte_size(bytes_after), |
291 byte_size_in_proper_unit(capacity), |
301 byte_size_in_proper_unit(capacity), |