shade@55767
|
1 /*
|
shade@56350
|
2 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
|
shade@55767
|
3 *
|
shade@55767
|
4 * This code is free software; you can redistribute it and/or modify it
|
shade@55767
|
5 * under the terms of the GNU General Public License version 2 only, as
|
shade@55767
|
6 * published by the Free Software Foundation.
|
shade@55767
|
7 *
|
shade@55767
|
8 * This code is distributed in the hope that it will be useful, but WITHOUT
|
shade@55767
|
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
shade@55767
|
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
shade@55767
|
11 * version 2 for more details (a copy is included in the LICENSE file that
|
shade@55767
|
12 * accompanied this code).
|
shade@55767
|
13 *
|
shade@55767
|
14 * You should have received a copy of the GNU General Public License version
|
shade@55767
|
15 * 2 along with this work; if not, write to the Free Software Foundation,
|
shade@55767
|
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
shade@55767
|
17 *
|
shade@55767
|
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
shade@55767
|
19 * or visit www.oracle.com if you need additional information or have any
|
shade@55767
|
20 * questions.
|
shade@55767
|
21 *
|
shade@55767
|
22 */
|
shade@55767
|
23
|
shade@55767
|
24 #ifndef SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
|
shade@55767
|
25 #define SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
|
shade@55767
|
26
|
shade@55767
|
27 #include "gc/shared/collectedHeap.hpp"
|
shade@56354
|
28 #include "gc/shared/softRefPolicy.hpp"
|
shade@55767
|
29 #include "gc/shared/space.hpp"
|
shade@55975
|
30 #include "services/memoryManager.hpp"
|
shade@55767
|
31 #include "gc/epsilon/epsilonCollectorPolicy.hpp"
|
shade@55767
|
32 #include "gc/epsilon/epsilonMonitoringSupport.hpp"
|
shade@55767
|
33 #include "gc/epsilon/epsilonBarrierSet.hpp"
|
shade@55767
|
34 #include "gc/epsilon/epsilon_globals.hpp"
|
shade@55767
|
35
|
shade@55939
|
36 class EpsilonHeap : public CollectedHeap {
|
shade@56576
|
37 friend class VMStructs;
|
shade@55767
|
38 private:
|
shade@55767
|
39 EpsilonCollectorPolicy* _policy;
|
shade@56276
|
40 SoftRefPolicy _soft_ref_policy;
|
shade@55767
|
41 EpsilonMonitoringSupport* _monitoring_support;
|
shade@55975
|
42 MemoryPool* _pool;
|
shade@55975
|
43 GCMemoryManager _memory_manager;
|
shade@55767
|
44 ContiguousSpace* _space;
|
shade@55767
|
45 VirtualSpace _virtual_space;
|
shade@55767
|
46 size_t _max_tlab_size;
|
shade@55767
|
47 size_t _last_counter_update;
|
shade@55979
|
48 size_t _last_heap_print;
|
shade@55979
|
49 size_t _step_counter_update;
|
shade@55979
|
50 size_t _step_heap_print;
|
shade@56577
|
51 int64_t _decay_time_ns;
|
shade@56492
|
52
|
shade@55767
|
53 public:
|
shade@56492
|
54 static EpsilonHeap* heap();
|
shade@56492
|
55
|
shade@55975
|
56 EpsilonHeap(EpsilonCollectorPolicy* p) :
|
shade@55975
|
57 _policy(p),
|
shade@55975
|
58 _memory_manager("Epsilon Heap", "") {};
|
shade@55767
|
59
|
shade@55767
|
60 virtual Name kind() const {
|
shade@56422
|
61 return CollectedHeap::Epsilon;
|
shade@55767
|
62 }
|
shade@55767
|
63
|
shade@56352
|
64 virtual const char* name() const {
|
shade@56352
|
65 return "Epsilon";
|
shade@55767
|
66 }
|
shade@55767
|
67
|
shade@56352
|
68 virtual CollectorPolicy* collector_policy() const {
|
shade@55767
|
69 return _policy;
|
shade@55767
|
70 }
|
shade@55767
|
71
|
shade@56276
|
72 virtual SoftRefPolicy* soft_ref_policy() {
|
shade@56276
|
73 return &_soft_ref_policy;
|
shade@56276
|
74 }
|
shade@56276
|
75
|
shade@56492
|
76 virtual jint initialize();
|
shade@56492
|
77 virtual void post_initialize();
|
shade@56492
|
78 virtual void initialize_serviceability();
|
shade@56492
|
79
|
shade@56492
|
80 virtual GrowableArray<GCMemoryManager*> memory_managers();
|
shade@56492
|
81 virtual GrowableArray<MemoryPool*> memory_pools();
|
shade@56492
|
82
|
shade@56492
|
83 virtual size_t max_capacity() const { return _virtual_space.reserved_size(); }
|
shade@56492
|
84 virtual size_t capacity() const { return _virtual_space.committed_size(); }
|
shade@56492
|
85 virtual size_t used() const { return _space->used(); }
|
shade@56492
|
86
|
shade@56492
|
87 virtual bool is_in(const void* p) const {
|
shade@56492
|
88 return _space->is_in(p);
|
shade@56492
|
89 }
|
shade@56492
|
90
|
shade@56492
|
91 virtual bool is_scavengable(oop obj) {
|
shade@56492
|
92 // No GC is going to happen, therefore no objects ever move.
|
shade@56492
|
93 return false;
|
shade@56492
|
94 }
|
shade@56492
|
95
|
shade@56492
|
96 virtual bool is_maximal_no_gc() const {
|
shade@56492
|
97 // No GC is going to happen. Return "we are at max", when we are about to fail.
|
shade@56492
|
98 return used() == capacity();
|
shade@56492
|
99 }
|
shade@56492
|
100
|
shade@56492
|
101 // Allocation
|
shade@56492
|
102 HeapWord* allocate_work(size_t size);
|
shade@56492
|
103 virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
|
shade@56508
|
104 virtual HeapWord* allocate_new_tlab(size_t min_size,
|
shade@56508
|
105 size_t requested_size,
|
shade@56508
|
106 size_t* actual_size);
|
shade@56492
|
107
|
shade@56492
|
108 // TLAB allocation
|
shade@56492
|
109 virtual bool supports_tlab_allocation() const { return UseTLAB; }
|
shade@56492
|
110 virtual size_t tlab_capacity(Thread* thr) const { return capacity(); }
|
shade@56492
|
111 virtual size_t tlab_used(Thread* thr) const { return used(); }
|
shade@56492
|
112 virtual size_t max_tlab_size() const { return _max_tlab_size; }
|
shade@56492
|
113 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
|
shade@56492
|
114
|
shade@56492
|
115 virtual void collect(GCCause::Cause cause);
|
shade@56492
|
116 virtual void do_full_collection(bool clear_all_soft_refs);
|
shade@56492
|
117
|
shade@56492
|
118 // Heap walking support
|
shade@56492
|
119 virtual void safe_object_iterate(ObjectClosure* cl);
|
shade@56352
|
120 virtual void object_iterate(ObjectClosure* cl) {
|
shade@55767
|
121 safe_object_iterate(cl);
|
shade@55767
|
122 }
|
shade@55767
|
123
|
shade@56492
|
124 // No support for block parsing.
|
shade@56492
|
125 virtual HeapWord* block_start(const void* addr) const { return NULL; }
|
shade@56492
|
126 virtual size_t block_size(const HeapWord* addr) const { return 0; }
|
shade@56492
|
127 virtual bool block_is_obj(const HeapWord* addr) const { return false; }
|
shade@55767
|
128
|
shade@56492
|
129 // No GC threads
|
shade@56492
|
130 virtual void print_gc_threads_on(outputStream* st) const {}
|
shade@56492
|
131 virtual void gc_threads_do(ThreadClosure* tc) const {}
|
shade@55767
|
132
|
shade@56492
|
133 // No heap verification
|
shade@56492
|
134 virtual void prepare_for_verify() {}
|
shade@56492
|
135 virtual void verify(VerifyOption option) {}
|
shade@55767
|
136
|
shade@55767
|
137 virtual jlong millis_since_last_gc() {
|
shade@55767
|
138 // Report time since the VM start
|
shade@55767
|
139 return os::elapsed_counter() / NANOSECS_PER_MILLISEC;
|
shade@55767
|
140 }
|
shade@55767
|
141
|
shade@56352
|
142 virtual void print_on(outputStream* st) const;
|
shade@56352
|
143 virtual void print_tracing_info() const;
|
shade@56352
|
144
|
shade@55767
|
145 };
|
shade@55767
|
146
|
shade@55767
|
147 #endif // SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
|