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 #ifndef SHARE_GC_SHARED_COLLECTEDHEAP_HPP
26 #define SHARE_GC_SHARED_COLLECTEDHEAP_HPP
27
28 #include "gc/shared/gcCause.hpp"
29 #include "gc/shared/gcWhen.hpp"
30 #include "gc/shared/verifyOption.hpp"
31 #include "memory/allocation.hpp"
32 #include "runtime/handles.hpp"
33 #include "runtime/perfData.hpp"
34 #include "runtime/safepoint.hpp"
35 #include "services/memoryUsage.hpp"
36 #include "utilities/debug.hpp"
37 #include "utilities/events.hpp"
38 #include "utilities/formatBuffer.hpp"
39 #include "utilities/growableArray.hpp"
40
41 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This
42 // is an abstract class: there may be many different kinds of heaps. This
43 // class defines the functions that a heap must implement, and contains
44 // infrastructure common to all heaps.
45
46 class AdaptiveSizePolicy;
47 class BarrierSet;
48 class GCHeapSummary;
49 class GCTimer;
50 class GCTracer;
51 class GCMemoryManager;
52 class MemoryPool;
53 class MetaspaceSummary;
54 class ReservedHeapSpace;
55 class SoftRefPolicy;
56 class Thread;
57 class ThreadClosure;
58 class VirtualSpaceSummary;
59 class WorkGang;
60 class nmethod;
61
62 class GCMessage : public FormatBuffer<1024> {
63 public:
64 bool is_before;
65
67 GCMessage() {}
68 };
69
70 class CollectedHeap;
71
72 class GCHeapLog : public EventLogBase<GCMessage> {
73 private:
74 void log_heap(CollectedHeap* heap, bool before);
75
76 public:
77 GCHeapLog() : EventLogBase<GCMessage>("GC Heap History", "gc") {}
78
79 void log_heap_before(CollectedHeap* heap) {
80 log_heap(heap, true);
81 }
82 void log_heap_after(CollectedHeap* heap) {
83 log_heap(heap, false);
84 }
85 };
86
87 //
88 // CollectedHeap
89 // GenCollectedHeap
90 // SerialHeap
91 // G1CollectedHeap
92 // ParallelScavengeHeap
93 // ShenandoahHeap
94 // ZCollectedHeap
95 //
96 class CollectedHeap : public CHeapObj<mtInternal> {
97 friend class VMStructs;
98 friend class JVMCIVMStructs;
99 friend class IsGCActiveMark; // Block structured external access to _is_gc_active
100 friend class MemAllocator;
101
102 private:
103 GCHeapLog* _gc_heap_log;
104
105 protected:
106 // Not used by all GCs
368
369 // Increment total number of GC collections (started)
370 void increment_total_collections(bool full = false) {
371 _total_collections++;
372 if (full) {
373 increment_total_full_collections();
374 }
375 }
376
377 void increment_total_full_collections() { _total_full_collections++; }
378
379 // Return the SoftRefPolicy for the heap;
380 virtual SoftRefPolicy* soft_ref_policy() = 0;
381
382 virtual MemoryUsage memory_usage();
383 virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
384 virtual GrowableArray<MemoryPool*> memory_pools() = 0;
385
386 // Iterate over all objects, calling "cl.do_object" on each.
387 virtual void object_iterate(ObjectClosure* cl) = 0;
388
389 // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
390 virtual void keep_alive(oop obj) {}
391
392 // Returns the longest time (in ms) that has elapsed since the last
393 // time that any part of the heap was examined by a garbage collection.
394 virtual jlong millis_since_last_gc() = 0;
395
396 // Perform any cleanup actions necessary before allowing a verification.
397 virtual void prepare_for_verify() = 0;
398
399 // Generate any dumps preceding or following a full gc
400 private:
401 void full_gc_dump(GCTimer* timer, bool before);
402
403 virtual void initialize_serviceability() = 0;
404
405 public:
406 void pre_full_gc_dump(GCTimer* timer);
407 void post_full_gc_dump(GCTimer* timer);
|
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 #ifndef SHARE_GC_SHARED_COLLECTEDHEAP_HPP
26 #define SHARE_GC_SHARED_COLLECTEDHEAP_HPP
27
28 #include "gc/shared/gcCause.hpp"
29 #include "gc/shared/gcWhen.hpp"
30 #include "gc/shared/verifyOption.hpp"
31 #include "memory/allocation.hpp"
32 #include "memory/heapInspection.hpp"
33 #include "runtime/handles.hpp"
34 #include "runtime/perfData.hpp"
35 #include "runtime/safepoint.hpp"
36 #include "services/memoryUsage.hpp"
37 #include "utilities/debug.hpp"
38 #include "utilities/events.hpp"
39 #include "utilities/formatBuffer.hpp"
40 #include "utilities/growableArray.hpp"
41
42 // A "CollectedHeap" is an implementation of a java heap for HotSpot. This
43 // is an abstract class: there may be many different kinds of heaps. This
44 // class defines the functions that a heap must implement, and contains
45 // infrastructure common to all heaps.
46
47 class AbstractGangTask;
48 class AdaptiveSizePolicy;
49 class BarrierSet;
50 class GCHeapSummary;
51 class GCTimer;
52 class GCTracer;
53 class GCMemoryManager;
54 class MemoryPool;
55 class MetaspaceSummary;
56 class ReservedHeapSpace;
57 class SoftRefPolicy;
58 class Thread;
59 class ThreadClosure;
60 class VirtualSpaceSummary;
61 class WorkGang;
62 class nmethod;
63
64 class GCMessage : public FormatBuffer<1024> {
65 public:
66 bool is_before;
67
69 GCMessage() {}
70 };
71
72 class CollectedHeap;
73
74 class GCHeapLog : public EventLogBase<GCMessage> {
75 private:
76 void log_heap(CollectedHeap* heap, bool before);
77
78 public:
79 GCHeapLog() : EventLogBase<GCMessage>("GC Heap History", "gc") {}
80
81 void log_heap_before(CollectedHeap* heap) {
82 log_heap(heap, true);
83 }
84 void log_heap_after(CollectedHeap* heap) {
85 log_heap(heap, false);
86 }
87 };
88
89 class ParallelObjectIterator : public CHeapObj<mtGC> {
90 public:
91 virtual void object_iterate(ObjectClosure* cl, uint worker_id) = 0;
92 };
93
94 //
95 // CollectedHeap
96 // GenCollectedHeap
97 // SerialHeap
98 // G1CollectedHeap
99 // ParallelScavengeHeap
100 // ShenandoahHeap
101 // ZCollectedHeap
102 //
103 class CollectedHeap : public CHeapObj<mtInternal> {
104 friend class VMStructs;
105 friend class JVMCIVMStructs;
106 friend class IsGCActiveMark; // Block structured external access to _is_gc_active
107 friend class MemAllocator;
108
109 private:
110 GCHeapLog* _gc_heap_log;
111
112 protected:
113 // Not used by all GCs
375
376 // Increment total number of GC collections (started)
377 void increment_total_collections(bool full = false) {
378 _total_collections++;
379 if (full) {
380 increment_total_full_collections();
381 }
382 }
383
384 void increment_total_full_collections() { _total_full_collections++; }
385
386 // Return the SoftRefPolicy for the heap;
387 virtual SoftRefPolicy* soft_ref_policy() = 0;
388
389 virtual MemoryUsage memory_usage();
390 virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
391 virtual GrowableArray<MemoryPool*> memory_pools() = 0;
392
393 // Iterate over all objects, calling "cl.do_object" on each.
394 virtual void object_iterate(ObjectClosure* cl) = 0;
395
396 virtual ParallelObjectIterator* parallel_object_iterator(uint thread_num) {
397 return NULL;
398 }
399
400 // Run given task. Possibly in parallel if the GC supports it.
401 virtual void run_task(AbstractGangTask* task) = 0;
402
403 // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
404 virtual void keep_alive(oop obj) {}
405
406 // Returns the longest time (in ms) that has elapsed since the last
407 // time that any part of the heap was examined by a garbage collection.
408 virtual jlong millis_since_last_gc() = 0;
409
410 // Perform any cleanup actions necessary before allowing a verification.
411 virtual void prepare_for_verify() = 0;
412
413 // Generate any dumps preceding or following a full gc
414 private:
415 void full_gc_dump(GCTimer* timer, bool before);
416
417 virtual void initialize_serviceability() = 0;
418
419 public:
420 void pre_full_gc_dump(GCTimer* timer);
421 void post_full_gc_dump(GCTimer* timer);
|