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