1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
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 *
29 #include "memory/generation.hpp"
30
31 // A "SharedHeap" is an implementation of a java heap for HotSpot. This
32 // is an abstract class: there may be many different kinds of heaps. This
33 // class defines the functions that a heap must implement, and contains
34 // infrastructure common to all heaps.
35
36 class Generation;
37 class BarrierSet;
38 class GenRemSet;
39 class Space;
40 class SpaceClosure;
41 class OopClosure;
42 class OopsInGenClosure;
43 class ObjectClosure;
44 class SubTasksDone;
45 class WorkGang;
46 class FlexibleWorkGang;
47 class CollectorPolicy;
48 class KlassClosure;
49 class GCPhaseTimeTracker;
50
51 // Note on use of FlexibleWorkGang's for GC.
52 // There are three places where task completion is determined.
53 // In
54 // 1) ParallelTaskTerminator::offer_termination() where _n_threads
55 // must be set to the correct value so that count of workers that
56 // have offered termination will exactly match the number
57 // working on the task. Tasks such as those derived from GCTask
58 // use ParallelTaskTerminator's. Tasks that want load balancing
59 // by work stealing use this method to gauge completion.
60 // 2) SubTasksDone has a variable _n_threads that is used in
61 // all_tasks_completed() to determine completion. all_tasks_complete()
62 // counts the number of tasks that have been done and then reset
63 // the SubTasksDone so that it can be used again. When the number of
64 // tasks is set to the number of GC workers, then _n_threads must
65 // be set to the number of active GC workers. G1CollectedHeap,
66 // HRInto_G1RemSet, GenCollectedHeap and SharedHeap have SubTasksDone.
67 // This seems too many.
68 // 3) SequentialSubTasksDone has an _n_threads that is used in
69 // a way similar to SubTasksDone and has the same dependency on the
243 enum ScanningOption {
244 SO_None = 0x0,
245 SO_AllCodeCache = 0x8,
246 SO_ScavengeCodeCache = 0x10
247 };
248
249 FlexibleWorkGang* workers() const { return _workers; }
250
251 // Invoke the "do_oop" method the closure "roots" on all root locations.
252 // The "so" argument determines which roots the closure is applied to:
253 // "SO_None" does none;
254 // "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
255 // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
256 void process_roots(bool activate_scope,
257 ScanningOption so,
258 OopClosure* strong_roots,
259 OopClosure* weak_roots,
260 CLDClosure* strong_cld_closure,
261 CLDClosure* weak_cld_closure,
262 CodeBlobClosure* code_roots,
263 GCPhaseTimeTracker* phase_durations = NULL);
264 void process_all_roots(bool activate_scope,
265 ScanningOption so,
266 OopClosure* roots,
267 CLDClosure* cld_closure,
268 CodeBlobClosure* code_roots,
269 GCPhaseTimeTracker* phase_durations = NULL);
270 void process_strong_roots(bool activate_scope,
271 ScanningOption so,
272 OopClosure* roots,
273 CLDClosure* cld_closure,
274 CodeBlobClosure* code_roots,
275 GCPhaseTimeTracker* phase_durations = NULL);
276
277
278 // Apply "root_closure" to the JNI weak roots..
279 void process_weak_roots(OopClosure* root_closure);
280
281 // The functions below are helper functions that a subclass of
282 // "SharedHeap" can use in the implementation of its virtual
283 // functions.
284
285 public:
286
287 // Do anything common to GC's.
288 virtual void gc_prologue(bool full) = 0;
289 virtual void gc_epilogue(bool full) = 0;
290
291 // Sets the number of parallel threads that will be doing tasks
292 // (such as process roots) subsequently.
293 virtual void set_par_threads(uint t);
294
295 int n_termination();
|
1 /*
2 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
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 *
29 #include "memory/generation.hpp"
30
31 // A "SharedHeap" is an implementation of a java heap for HotSpot. This
32 // is an abstract class: there may be many different kinds of heaps. This
33 // class defines the functions that a heap must implement, and contains
34 // infrastructure common to all heaps.
35
36 class Generation;
37 class BarrierSet;
38 class GenRemSet;
39 class Space;
40 class SpaceClosure;
41 class OopClosure;
42 class OopsInGenClosure;
43 class ObjectClosure;
44 class SubTasksDone;
45 class WorkGang;
46 class FlexibleWorkGang;
47 class CollectorPolicy;
48 class KlassClosure;
49
50 // Note on use of FlexibleWorkGang's for GC.
51 // There are three places where task completion is determined.
52 // In
53 // 1) ParallelTaskTerminator::offer_termination() where _n_threads
54 // must be set to the correct value so that count of workers that
55 // have offered termination will exactly match the number
56 // working on the task. Tasks such as those derived from GCTask
57 // use ParallelTaskTerminator's. Tasks that want load balancing
58 // by work stealing use this method to gauge completion.
59 // 2) SubTasksDone has a variable _n_threads that is used in
60 // all_tasks_completed() to determine completion. all_tasks_complete()
61 // counts the number of tasks that have been done and then reset
62 // the SubTasksDone so that it can be used again. When the number of
63 // tasks is set to the number of GC workers, then _n_threads must
64 // be set to the number of active GC workers. G1CollectedHeap,
65 // HRInto_G1RemSet, GenCollectedHeap and SharedHeap have SubTasksDone.
66 // This seems too many.
67 // 3) SequentialSubTasksDone has an _n_threads that is used in
68 // a way similar to SubTasksDone and has the same dependency on the
242 enum ScanningOption {
243 SO_None = 0x0,
244 SO_AllCodeCache = 0x8,
245 SO_ScavengeCodeCache = 0x10
246 };
247
248 FlexibleWorkGang* workers() const { return _workers; }
249
250 // Invoke the "do_oop" method the closure "roots" on all root locations.
251 // The "so" argument determines which roots the closure is applied to:
252 // "SO_None" does none;
253 // "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
254 // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
255 void process_roots(bool activate_scope,
256 ScanningOption so,
257 OopClosure* strong_roots,
258 OopClosure* weak_roots,
259 CLDClosure* strong_cld_closure,
260 CLDClosure* weak_cld_closure,
261 CodeBlobClosure* code_roots,
262 PhaseTimeData* phase_durations = NULL);
263 void process_all_roots(bool activate_scope,
264 ScanningOption so,
265 OopClosure* roots,
266 CLDClosure* cld_closure,
267 CodeBlobClosure* code_roots,
268 PhaseTimeData* phase_durations = NULL);
269 void process_strong_roots(bool activate_scope,
270 ScanningOption so,
271 OopClosure* roots,
272 CLDClosure* cld_closure,
273 CodeBlobClosure* code_roots,
274 PhaseTimeData* phase_durations = NULL);
275
276
277 // Apply "root_closure" to the JNI weak roots..
278 void process_weak_roots(OopClosure* root_closure);
279
280 // The functions below are helper functions that a subclass of
281 // "SharedHeap" can use in the implementation of its virtual
282 // functions.
283
284 public:
285
286 // Do anything common to GC's.
287 virtual void gc_prologue(bool full) = 0;
288 virtual void gc_epilogue(bool full) = 0;
289
290 // Sets the number of parallel threads that will be doing tasks
291 // (such as process roots) subsequently.
292 virtual void set_par_threads(uint t);
293
294 int n_termination();
|