1 /* |
1 /* |
2 * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
48 CollectedHeap(), |
48 CollectedHeap(), |
49 _collector_policy(policy_), |
49 _collector_policy(policy_), |
50 _perm_gen(NULL), _rem_set(NULL), |
50 _perm_gen(NULL), _rem_set(NULL), |
51 _strong_roots_parity(0), |
51 _strong_roots_parity(0), |
52 _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)), |
52 _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)), |
53 _workers(NULL), _n_par_threads(0) |
53 _n_par_threads(0), |
|
54 _workers(NULL) |
54 { |
55 { |
55 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) { |
56 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) { |
56 vm_exit_during_initialization("Failed necessary allocation."); |
57 vm_exit_during_initialization("Failed necessary allocation."); |
57 } |
58 } |
58 _sh = this; // ch is static, should be set only once. |
59 _sh = this; // ch is static, should be set only once. |
59 if ((UseParNewGC || |
60 if ((UseParNewGC || |
60 (UseConcMarkSweepGC && CMSParallelRemarkEnabled) || |
61 (UseConcMarkSweepGC && CMSParallelRemarkEnabled) || |
61 UseG1GC) && |
62 UseG1GC) && |
62 ParallelGCThreads > 0) { |
63 ParallelGCThreads > 0) { |
63 _workers = new WorkGang("Parallel GC Threads", ParallelGCThreads, |
64 _workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads, |
64 /* are_GC_task_threads */true, |
65 /* are_GC_task_threads */true, |
65 /* are_ConcurrentGC_threads */false); |
66 /* are_ConcurrentGC_threads */false); |
66 if (_workers == NULL) { |
67 if (_workers == NULL) { |
67 vm_exit_during_initialization("Failed necessary allocation."); |
68 vm_exit_during_initialization("Failed necessary allocation."); |
|
69 } else { |
|
70 _workers->initialize_workers(); |
68 } |
71 } |
69 } |
72 } |
70 } |
73 } |
71 |
74 |
72 bool SharedHeap::heap_lock_held_for_gc() { |
75 bool SharedHeap::heap_lock_held_for_gc() { |
75 || ( (t->is_GC_task_thread() || t->is_VM_thread()) |
78 || ( (t->is_GC_task_thread() || t->is_VM_thread()) |
76 && _thread_holds_heap_lock_for_gc); |
79 && _thread_holds_heap_lock_for_gc); |
77 } |
80 } |
78 |
81 |
79 void SharedHeap::set_par_threads(int t) { |
82 void SharedHeap::set_par_threads(int t) { |
|
83 assert(t == 0 || !UseSerialGC, "Cannot have parallel threads"); |
80 _n_par_threads = t; |
84 _n_par_threads = t; |
81 _process_strong_tasks->set_par_threads(t); |
85 _process_strong_tasks->set_n_threads(t); |
82 } |
86 } |
83 |
87 |
84 class AssertIsPermClosure: public OopClosure { |
88 class AssertIsPermClosure: public OopClosure { |
85 public: |
89 public: |
86 virtual void do_oop(oop* p) { |
90 virtual void do_oop(oop* p) { |