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