6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/cms/concurrentMarkSweepThread.hpp"
27 #include "gc/cms/cmsHeap.hpp"
28 #include "gc/cms/vmCMSOperations.hpp"
29 #include "gc/shared/genOopClosures.inline.hpp"
30 #include "gc/shared/strongRootsScope.hpp"
31 #include "gc/shared/workgroup.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/vmThread.hpp"
34 #include "utilities/stack.inline.hpp"
35
36 CMSHeap::CMSHeap(GenCollectorPolicy *policy) : GenCollectedHeap(policy) {
37 _workers = new WorkGang("GC Thread", ParallelGCThreads,
38 /* are_GC_task_threads */true,
39 /* are_ConcurrentGC_threads */false);
40 _workers->initialize_workers();
41 }
42
43 jint CMSHeap::initialize() {
44 jint status = GenCollectedHeap::initialize();
45 if (status != JNI_OK) return status;
46
47 // If we are running CMS, create the collector responsible
48 // for collecting the CMS generations.
49 assert(collector_policy()->is_concurrent_mark_sweep_policy(), "must be CMS policy");
50 if (!create_cms_collector()) {
51 return JNI_ENOMEM;
52 }
53
54 return JNI_OK;
55 }
56
57 void CMSHeap::check_gen_kinds() {
58 assert(young_gen()->kind() == Generation::ParNew,
59 "Wrong youngest generation type");
60 assert(old_gen()->kind() == Generation::ConcurrentMarkSweep,
61 "Wrong generation kind");
62 }
63
64 CMSHeap* CMSHeap::heap() {
65 CollectedHeap* heap = Universe::heap();
66 assert(heap != NULL, "Uninitialized access to CMSHeap::heap()");
67 assert(heap->kind() == CollectedHeap::CMSHeap, "Not a CMSHeap");
68 return (CMSHeap*) heap;
69 }
70
71 void CMSHeap::gc_threads_do(ThreadClosure* tc) const {
72 assert(workers() != NULL, "should have workers here");
73 workers()->threads_do(tc);
74 ConcurrentMarkSweepThread::threads_do(tc);
75 }
76
166
167 if (young_gen_as_roots &&
168 !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
169 root_closure->set_generation(young_gen());
170 young_gen()->oop_iterate(root_closure);
171 root_closure->reset_generation();
172 }
173
174 _process_strong_tasks->all_tasks_completed(scope->n_threads());
175 }
176
177 void CMSHeap::gc_prologue(bool full) {
178 always_do_update_barrier = false;
179 GenCollectedHeap::gc_prologue(full);
180 };
181
182 void CMSHeap::gc_epilogue(bool full) {
183 GenCollectedHeap::gc_epilogue(full);
184 always_do_update_barrier = true;
185 };
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/cms/compactibleFreeListSpace.hpp"
27 #include "gc/cms/concurrentMarkSweepGeneration.hpp"
28 #include "gc/cms/concurrentMarkSweepThread.hpp"
29 #include "gc/cms/cmsHeap.hpp"
30 #include "gc/cms/parNewGeneration.hpp"
31 #include "gc/cms/vmCMSOperations.hpp"
32 #include "gc/shared/genMemoryPools.hpp"
33 #include "gc/shared/genOopClosures.inline.hpp"
34 #include "gc/shared/strongRootsScope.hpp"
35 #include "gc/shared/workgroup.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "runtime/vmThread.hpp"
38 #include "services/memoryManager.hpp"
39 #include "utilities/stack.inline.hpp"
40
41 class CompactibleFreeListSpacePool : public CollectedMemoryPool {
42 private:
43 CompactibleFreeListSpace* _space;
44 public:
45 CompactibleFreeListSpacePool(CompactibleFreeListSpace* space,
46 const char* name,
47 size_t max_size,
48 bool support_usage_threshold) :
49 CollectedMemoryPool(name, space->capacity(), max_size, support_usage_threshold),
50 _space(space) {
51 }
52
53 MemoryUsage get_memory_usage() {
54 size_t max_heap_size = (available_for_allocation() ? max_size() : 0);
55 size_t used = used_in_bytes();
56 size_t committed = _space->capacity();
57
58 return MemoryUsage(initial_size(), used, committed, max_heap_size);
59 }
60
61 size_t used_in_bytes() {
62 return _space->used();
63 }
64 };
65
66 CMSHeap::CMSHeap(GenCollectorPolicy *policy) :
67 GenCollectedHeap(policy), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL) {
68 _workers = new WorkGang("GC Thread", ParallelGCThreads,
69 /* are_GC_task_threads */true,
70 /* are_ConcurrentGC_threads */false);
71 _workers->initialize_workers();
72 }
73
74 jint CMSHeap::initialize() {
75 jint status = GenCollectedHeap::initialize();
76 if (status != JNI_OK) return status;
77
78 // If we are running CMS, create the collector responsible
79 // for collecting the CMS generations.
80 assert(collector_policy()->is_concurrent_mark_sweep_policy(), "must be CMS policy");
81 if (!create_cms_collector()) {
82 return JNI_ENOMEM;
83 }
84
85 return JNI_OK;
86 }
87
88 void CMSHeap::initialize_serviceability() {
89 _young_manager = new GCMemoryManager("ParNew", "end of minor GC");
90 _old_manager = new GCMemoryManager("ConcurrentMarkSweep", "end of major GC");
91
92 ParNewGeneration* young = (ParNewGeneration*) young_gen();
93 _eden_pool = new ContiguousSpacePool(young->eden(),
94 "Par Eden Space",
95 young->max_eden_size(),
96 false);
97
98 _survivor_pool = new SurvivorContiguousSpacePool(young,
99 "Par Survivor Space",
100 young->max_survivor_size(),
101 false);
102
103 ConcurrentMarkSweepGeneration* old = (ConcurrentMarkSweepGeneration*) old_gen();
104 _old_pool = new CompactibleFreeListSpacePool(old->cmsSpace(),
105 "CMS Old Gen",
106 old->reserved().byte_size(),
107 true);
108
109 _young_manager->add_pool(_eden_pool);
110 _young_manager->add_pool(_survivor_pool);
111 young->set_gc_manager(_young_manager);
112
113 _old_manager->add_pool(_eden_pool);
114 _old_manager->add_pool(_survivor_pool);
115 _old_manager->add_pool(_old_pool);
116 old ->set_gc_manager(_old_manager);
117
118 }
119
120 void CMSHeap::check_gen_kinds() {
121 assert(young_gen()->kind() == Generation::ParNew,
122 "Wrong youngest generation type");
123 assert(old_gen()->kind() == Generation::ConcurrentMarkSweep,
124 "Wrong generation kind");
125 }
126
127 CMSHeap* CMSHeap::heap() {
128 CollectedHeap* heap = Universe::heap();
129 assert(heap != NULL, "Uninitialized access to CMSHeap::heap()");
130 assert(heap->kind() == CollectedHeap::CMSHeap, "Not a CMSHeap");
131 return (CMSHeap*) heap;
132 }
133
134 void CMSHeap::gc_threads_do(ThreadClosure* tc) const {
135 assert(workers() != NULL, "should have workers here");
136 workers()->threads_do(tc);
137 ConcurrentMarkSweepThread::threads_do(tc);
138 }
139
229
230 if (young_gen_as_roots &&
231 !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
232 root_closure->set_generation(young_gen());
233 young_gen()->oop_iterate(root_closure);
234 root_closure->reset_generation();
235 }
236
237 _process_strong_tasks->all_tasks_completed(scope->n_threads());
238 }
239
240 void CMSHeap::gc_prologue(bool full) {
241 always_do_update_barrier = false;
242 GenCollectedHeap::gc_prologue(full);
243 };
244
245 void CMSHeap::gc_epilogue(bool full) {
246 GenCollectedHeap::gc_epilogue(full);
247 always_do_update_barrier = true;
248 };
249
250 GrowableArray<GCMemoryManager*> CMSHeap::memory_managers() {
251 GrowableArray<GCMemoryManager*> memory_managers(2);
252 memory_managers.append(_young_manager);
253 memory_managers.append(_old_manager);
254 return memory_managers;
255 }
256
257 GrowableArray<MemoryPool*> CMSHeap::memory_pools() {
258 GrowableArray<MemoryPool*> memory_pools(3);
259 memory_pools.append(_eden_pool);
260 memory_pools.append(_survivor_pool);
261 memory_pools.append(_old_pool);
262 return memory_pools;
263 }
|