1 /* 2 * Copyright (c) 2017, 2018, 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_VM_GC_CMS_CMSHEAP_HPP 26 #define SHARE_VM_GC_CMS_CMSHEAP_HPP 27 28 #include "gc/cms/concurrentMarkSweepGeneration.hpp" 29 #include "gc/shared/collectedHeap.hpp" 30 #include "gc/shared/gcCause.hpp" 31 #include "gc/shared/genCollectedHeap.hpp" 32 #include "utilities/growableArray.hpp" 33 34 class CLDClosure; 35 class GenCollectorPolicy; 36 class GCMemoryManager; 37 class MemoryPool; 38 class OopsInGenClosure; 39 class outputStream; 40 class StrongRootsScope; 41 class ThreadClosure; 42 class WorkGang; 43 44 class CMSHeap : public GenCollectedHeap { 45 46 protected: 47 virtual void check_gen_kinds(); 48 49 public: 50 CMSHeap(GenCollectorPolicy *policy); 51 52 // Returns JNI_OK on success 53 virtual jint initialize(); 54 virtual CardTableRS* create_rem_set(const MemRegion& reserved_region); 55 56 // Convenience function to be used in situations where the heap type can be 57 // asserted to be this type. 58 static CMSHeap* heap(); 59 60 virtual Name kind() const { 61 return CollectedHeap::CMS; 62 } 63 64 virtual const char* name() const { 65 return "Concurrent Mark Sweep"; 66 } 67 68 WorkGang* workers() const { return _workers; } 69 70 virtual void print_gc_threads_on(outputStream* st) const; 71 virtual void gc_threads_do(ThreadClosure* tc) const; 72 virtual void print_on_error(outputStream* st) const; 73 74 // Perform a full collection of the heap; intended for use in implementing 75 // "System.gc". This implies as full a collection as the CollectedHeap 76 // supports. Caller does not hold the Heap_lock on entry. 77 void collect(GCCause::Cause cause); 78 79 void stop(); 80 void safepoint_synchronize_begin(); 81 void safepoint_synchronize_end(); 82 83 virtual GrowableArray<GCMemoryManager*> memory_managers(); 84 virtual GrowableArray<MemoryPool*> memory_pools(); 85 86 // If "young_gen_as_roots" is false, younger generations are 87 // not scanned as roots; in this case, the caller must be arranging to 88 // scan the younger generations itself. (For example, a generation might 89 // explicitly mark reachable objects in younger generations, to avoid 90 // excess storage retention.) 91 void cms_process_roots(StrongRootsScope* scope, 92 bool young_gen_as_roots, 93 ScanningOption so, 94 bool only_strong_roots, 95 OopsInGenClosure* root_closure, 96 CLDClosure* cld_closure); 97 98 GCMemoryManager* old_manager() const { return _old_manager; } 99 100 private: 101 WorkGang* _workers; 102 MemoryPool* _eden_pool; 103 MemoryPool* _survivor_pool; 104 MemoryPool* _old_pool; 105 106 virtual void gc_prologue(bool full); 107 virtual void gc_epilogue(bool full); 108 109 virtual void initialize_serviceability(); 110 111 // Accessor for memory state verification support 112 NOT_PRODUCT( 113 virtual size_t skip_header_HeapWords() { return CMSCollector::skip_header_HeapWords(); } 114 ) 115 116 // Returns success or failure. 117 bool create_cms_collector(); 118 119 // In support of ExplicitGCInvokesConcurrent functionality 120 bool should_do_concurrent_full_gc(GCCause::Cause cause); 121 122 void collect_mostly_concurrent(GCCause::Cause cause); 123 }; 124 125 #endif // SHARE_VM_GC_CMS_CMSHEAP_HPP