< prev index next >

src/hotspot/share/gc/epsilon/epsilonHeap.hpp

Print this page

 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_GC_EPSILON_EPSILONHEAP_HPP
 27 #define SHARE_GC_EPSILON_EPSILONHEAP_HPP
 28 
 29 #include "gc/epsilon/epsilonBarrierSet.hpp"
 30 #include "gc/epsilon/epsilonMonitoringSupport.hpp"
 31 #include "gc/shared/collectedHeap.hpp"

 32 #include "gc/shared/space.hpp"
 33 #include "memory/virtualspace.hpp"
 34 #include "services/memoryManager.hpp"
 35 
 36 class EpsilonHeap : public CollectedHeap {
 37   friend class VMStructs;
 38 private:
 39   EpsilonMonitoringSupport* _monitoring_support;
 40   MemoryPool* _pool;
 41   GCMemoryManager _memory_manager;
 42   ContiguousSpace* _space;
 43   VirtualSpace _virtual_space;
 44   size_t _max_tlab_size;
 45   size_t _step_counter_update;
 46   size_t _step_heap_print;
 47   int64_t _decay_time_ns;
 48   volatile size_t _last_counter_update;
 49   volatile size_t _last_heap_print;


 50 
 51   void print_tracing_info() const override;
 52   void stop() override {};
 53 
 54 public:
 55   static EpsilonHeap* heap();
 56 
 57   EpsilonHeap() :
 58           _memory_manager("Epsilon Heap"),
 59           _space(nullptr) {};
 60 
 61   Name kind() const override {
 62     return CollectedHeap::Epsilon;
 63   }
 64 
 65   const char* name() const override {
 66     return "Epsilon";
 67   }
 68 
 69   jint initialize() override;
 70   void initialize_serviceability() override;
 71 
 72   GrowableArray<GCMemoryManager*> memory_managers() override;
 73   GrowableArray<MemoryPool*> memory_pools() override;
 74 
 75   size_t max_capacity() const override { return _virtual_space.reserved_size();  }
 76   size_t capacity()     const override { return _virtual_space.committed_size(); }
 77   size_t used()         const override { return _space->used(); }
 78 
 79   bool is_in(const void* p) const override {
 80     return _space->is_in(p);
 81   }
 82 
 83   bool requires_barriers(stackChunkOop obj) const override { return false; }
 84 
 85   // Allocation
 86   HeapWord* allocate_work(size_t size, bool verbose = true);

 87   HeapWord* mem_allocate(size_t size) override;
 88   HeapWord* allocate_new_tlab(size_t min_size,
 89                               size_t requested_size,
 90                               size_t* actual_size) override;
 91 
 92   // TLAB allocation
 93   size_t tlab_capacity(Thread* thr)         const override { return capacity();     }
 94   size_t tlab_used(Thread* thr)             const override { return used();         }
 95   size_t max_tlab_size()                    const override { return _max_tlab_size; }
 96   size_t unsafe_max_tlab_alloc(Thread* thr) const override;
 97 
 98   void collect(GCCause::Cause cause) override;
 99   void do_full_collection(bool clear_all_soft_refs) override;
100 
101   // Heap walking support
102   void object_iterate(ObjectClosure* cl) override;
103 
104   // Object pinning support: every object is implicitly pinned
105   void pin_object(JavaThread* thread, oop obj) override { }
106   void unpin_object(JavaThread* thread, oop obj) override { }
107 
108   // No support for block parsing.
109   HeapWord* block_start(const void* addr) const { return nullptr;  }
110   bool block_is_obj(const HeapWord* addr) const { return false; }
111 
112   // No GC threads
113   void gc_threads_do(ThreadClosure* tc) const override {}
114 
115   // No nmethod handling
116   void register_nmethod(nmethod* nm) override {}
117   void unregister_nmethod(nmethod* nm) override {}
118   void verify_nmethod(nmethod* nm) override {}
119 
120   // No heap verification
121   void prepare_for_verify() override {}
122   void verify(VerifyOption option) override {}
123 
124   MemRegion reserved_region() const { return _reserved; }
125   bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); }
126 
127   // Support for loading objects from CDS archive into the heap
128   bool can_load_archived_objects() const override { return true; }
129   HeapWord* allocate_loaded_archive_space(size_t size) override;
130 
131   void print_heap_on(outputStream* st) const override;
132   void print_gc_on(outputStream* st) const override {}
133   bool print_location(outputStream* st, void* addr) const override;
134 


135 private:
136   void print_heap_info(size_t used) const;
137   void print_metaspace_info() const;
138 





139 };
140 
141 #endif // SHARE_GC_EPSILON_EPSILONHEAP_HPP

 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_GC_EPSILON_EPSILONHEAP_HPP
 27 #define SHARE_GC_EPSILON_EPSILONHEAP_HPP
 28 
 29 #include "gc/epsilon/epsilonBarrierSet.hpp"
 30 #include "gc/epsilon/epsilonMonitoringSupport.hpp"
 31 #include "gc/shared/collectedHeap.hpp"
 32 #include "gc/shared/markBitMap.hpp"
 33 #include "gc/shared/space.hpp"
 34 #include "memory/virtualspace.hpp"
 35 #include "services/memoryManager.hpp"
 36 
 37 class EpsilonHeap : public CollectedHeap {
 38   friend class VMStructs;
 39 private:
 40   EpsilonMonitoringSupport* _monitoring_support;
 41   MemoryPool* _pool;
 42   GCMemoryManager _memory_manager;
 43   ContiguousSpace* _space;
 44   VirtualSpace _virtual_space;
 45   size_t _max_tlab_size;
 46   size_t _step_counter_update;
 47   size_t _step_heap_print;
 48   int64_t _decay_time_ns;
 49   volatile size_t _last_counter_update;
 50   volatile size_t _last_heap_print;
 51   MemRegion  _bitmap_region;
 52   MarkBitMap _bitmap;
 53 
 54   void print_tracing_info() const override;
 55   void stop() override {};
 56 
 57 public:
 58   static EpsilonHeap* heap();
 59 
 60   EpsilonHeap() :
 61           _memory_manager("Epsilon Heap"),
 62           _space(nullptr) {};
 63 
 64   Name kind() const override {
 65     return CollectedHeap::Epsilon;
 66   }
 67 
 68   const char* name() const override {
 69     return "Epsilon";
 70   }
 71 
 72   jint initialize() override;
 73   void initialize_serviceability() override;
 74 
 75   GrowableArray<GCMemoryManager*> memory_managers() override;
 76   GrowableArray<MemoryPool*> memory_pools() override;
 77 
 78   size_t max_capacity() const override { return _virtual_space.reserved_size();  }
 79   size_t capacity()     const override { return _virtual_space.committed_size(); }
 80   size_t used()         const override { return _space->used(); }
 81 
 82   bool is_in(const void* p) const override {
 83     return _space->is_in(p);
 84   }
 85 
 86   bool requires_barriers(stackChunkOop obj) const override { return false; }
 87 
 88   // Allocation
 89   HeapWord* allocate_work(size_t size, bool verbose = true);
 90   HeapWord* allocate_or_collect_work(size_t size, bool verbose = true);
 91   HeapWord* mem_allocate(size_t size) override;
 92   HeapWord* allocate_new_tlab(size_t min_size,
 93                               size_t requested_size,
 94                               size_t* actual_size) override;
 95 
 96   // TLAB allocation
 97   size_t tlab_capacity(Thread* thr)         const override { return capacity();     }
 98   size_t tlab_used(Thread* thr)             const override { return used();         }
 99   size_t max_tlab_size()                    const override { return _max_tlab_size; }
100   size_t unsafe_max_tlab_alloc(Thread* thr) const override;
101 
102   void collect(GCCause::Cause cause) override;
103   void do_full_collection(bool clear_all_soft_refs) override;
104 
105   // Heap walking support
106   void object_iterate(ObjectClosure* cl) override;
107 
108   // Object pinning support: every object is implicitly pinned
109   void pin_object(JavaThread* thread, oop obj) override;
110   void unpin_object(JavaThread* thread, oop obj) override;
111 
112   // No support for block parsing.
113   HeapWord* block_start(const void* addr) const { return nullptr;  }
114   bool block_is_obj(const HeapWord* addr) const { return false; }
115 
116   // No GC threads
117   void gc_threads_do(ThreadClosure* tc) const override {}
118 
119   // No nmethod handling
120   void register_nmethod(nmethod* nm) override {}
121   void unregister_nmethod(nmethod* nm) override {}
122   void verify_nmethod(nmethod* nm) override {}
123 
124   // No heap verification
125   void prepare_for_verify() override {}
126   void verify(VerifyOption option) override {}
127 
128   MemRegion reserved_region() const { return _reserved; }
129   bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); }
130 
131   // Support for loading objects from CDS archive into the heap
132   bool can_load_archived_objects() const override { return true; }
133   HeapWord* allocate_loaded_archive_space(size_t size) override;
134 
135   void print_heap_on(outputStream* st) const override;
136   void print_gc_on(outputStream* st) const override {}
137   bool print_location(outputStream* st, void* addr) const override;
138 
139   void entry_collect(GCCause::Cause cause);
140 
141 private:
142   void print_heap_info(size_t used) const;
143   void print_metaspace_info() const;
144 
145   void vmentry_collect(GCCause::Cause cause);
146 
147   void process_roots(OopClosure* cl, bool update);
148   void walk_bitmap(ObjectClosure* cl);
149 
150 };
151 
152 #endif // SHARE_GC_EPSILON_EPSILONHEAP_HPP
< prev index next >