1 /*
2 * Copyright (c) 2001, 2019, 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 *
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
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);
|
1 /*
2 * Copyright (c) 2001, 2020, 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 *
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
370
371 // Increment total number of GC collections (started)
372 void increment_total_collections(bool full = false) {
373 _total_collections++;
374 if (full) {
375 increment_total_full_collections();
376 }
377 }
378
379 void increment_total_full_collections() { _total_full_collections++; }
380
381 // Return the SoftRefPolicy for the heap;
382 virtual SoftRefPolicy* soft_ref_policy() = 0;
383
384 virtual MemoryUsage memory_usage();
385 virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
386 virtual GrowableArray<MemoryPool*> memory_pools() = 0;
387
388 // Iterate over all objects, calling "cl.do_object" on each.
389 virtual void object_iterate(ObjectClosure* cl) = 0;
390
391 // Run parallel heap inspection, return false as not supported by heap.
392 virtual bool run_par_heap_inspect_task(KlassInfoTable* cit,
393 BoolObjectClosure* filter,
394 size_t* missed_count,
395 size_t thread_num) {
396 return false;
397 }
398
399 // Parallel iterate over all objects, reture false if heap not support.
400 virtual bool object_iterate_try_parallel(AbstractGangTask *task, size_t thread_num) {
401 return false;
402 }
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);
|