55767
|
1 |
/*
|
56350
|
2 |
* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
|
55767
|
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"
|
56354
|
28 |
#include "gc/shared/softRefPolicy.hpp"
|
55767
|
29 |
#include "gc/shared/space.hpp"
|
55975
|
30 |
#include "services/memoryManager.hpp"
|
55767
|
31 |
#include "gc/epsilon/epsilonCollectorPolicy.hpp"
|
|
32 |
#include "gc/epsilon/epsilonMonitoringSupport.hpp"
|
|
33 |
#include "gc/epsilon/epsilonBarrierSet.hpp"
|
|
34 |
#include "gc/epsilon/epsilon_globals.hpp"
|
|
35 |
|
55939
|
36 |
class EpsilonHeap : public CollectedHeap {
|
55767
|
37 |
private:
|
|
38 |
EpsilonCollectorPolicy* _policy;
|
56276
|
39 |
SoftRefPolicy _soft_ref_policy;
|
55767
|
40 |
EpsilonMonitoringSupport* _monitoring_support;
|
55975
|
41 |
MemoryPool* _pool;
|
|
42 |
GCMemoryManager _memory_manager;
|
55767
|
43 |
ContiguousSpace* _space;
|
|
44 |
VirtualSpace _virtual_space;
|
|
45 |
size_t _max_tlab_size;
|
|
46 |
size_t _last_counter_update;
|
55979
|
47 |
size_t _last_heap_print;
|
|
48 |
size_t _step_counter_update;
|
|
49 |
size_t _step_heap_print;
|
56492
|
50 |
|
55767
|
51 |
public:
|
56492
|
52 |
static EpsilonHeap* heap();
|
|
53 |
|
55975
|
54 |
EpsilonHeap(EpsilonCollectorPolicy* p) :
|
|
55 |
_policy(p),
|
|
56 |
_memory_manager("Epsilon Heap", "") {};
|
55767
|
57 |
|
|
58 |
virtual Name kind() const {
|
56422
|
59 |
return CollectedHeap::Epsilon;
|
55767
|
60 |
}
|
|
61 |
|
56352
|
62 |
virtual const char* name() const {
|
|
63 |
return "Epsilon";
|
55767
|
64 |
}
|
|
65 |
|
56352
|
66 |
virtual CollectorPolicy* collector_policy() const {
|
55767
|
67 |
return _policy;
|
|
68 |
}
|
|
69 |
|
56276
|
70 |
virtual SoftRefPolicy* soft_ref_policy() {
|
|
71 |
return &_soft_ref_policy;
|
|
72 |
}
|
|
73 |
|
56492
|
74 |
virtual jint initialize();
|
|
75 |
virtual void post_initialize();
|
|
76 |
virtual void initialize_serviceability();
|
|
77 |
|
|
78 |
virtual GrowableArray<GCMemoryManager*> memory_managers();
|
|
79 |
virtual GrowableArray<MemoryPool*> memory_pools();
|
|
80 |
|
|
81 |
virtual size_t max_capacity() const { return _virtual_space.reserved_size(); }
|
|
82 |
virtual size_t capacity() const { return _virtual_space.committed_size(); }
|
|
83 |
virtual size_t used() const { return _space->used(); }
|
|
84 |
|
|
85 |
virtual bool is_in(const void* p) const {
|
|
86 |
return _space->is_in(p);
|
|
87 |
}
|
|
88 |
|
|
89 |
virtual bool is_scavengable(oop obj) {
|
|
90 |
// No GC is going to happen, therefore no objects ever move.
|
|
91 |
return false;
|
|
92 |
}
|
|
93 |
|
|
94 |
virtual bool is_maximal_no_gc() const {
|
|
95 |
// No GC is going to happen. Return "we are at max", when we are about to fail.
|
|
96 |
return used() == capacity();
|
|
97 |
}
|
|
98 |
|
|
99 |
// Allocation
|
|
100 |
HeapWord* allocate_work(size_t size);
|
|
101 |
virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
|
56508
|
102 |
virtual HeapWord* allocate_new_tlab(size_t min_size,
|
|
103 |
size_t requested_size,
|
|
104 |
size_t* actual_size);
|
56492
|
105 |
|
|
106 |
// TLAB allocation
|
|
107 |
virtual bool supports_tlab_allocation() const { return UseTLAB; }
|
|
108 |
virtual size_t tlab_capacity(Thread* thr) const { return capacity(); }
|
|
109 |
virtual size_t tlab_used(Thread* thr) const { return used(); }
|
|
110 |
virtual size_t max_tlab_size() const { return _max_tlab_size; }
|
|
111 |
virtual size_t unsafe_max_tlab_alloc(Thread* thr) const;
|
|
112 |
|
|
113 |
virtual void collect(GCCause::Cause cause);
|
|
114 |
virtual void do_full_collection(bool clear_all_soft_refs);
|
|
115 |
|
|
116 |
// Heap walking support
|
|
117 |
virtual void safe_object_iterate(ObjectClosure* cl);
|
56352
|
118 |
virtual void object_iterate(ObjectClosure* cl) {
|
55767
|
119 |
safe_object_iterate(cl);
|
|
120 |
}
|
|
121 |
|
56492
|
122 |
// No support for block parsing.
|
|
123 |
virtual HeapWord* block_start(const void* addr) const { return NULL; }
|
|
124 |
virtual size_t block_size(const HeapWord* addr) const { return 0; }
|
|
125 |
virtual bool block_is_obj(const HeapWord* addr) const { return false; }
|
55767
|
126 |
|
56492
|
127 |
// No GC threads
|
|
128 |
virtual void print_gc_threads_on(outputStream* st) const {}
|
|
129 |
virtual void gc_threads_do(ThreadClosure* tc) const {}
|
55767
|
130 |
|
56492
|
131 |
// No heap verification
|
|
132 |
virtual void prepare_for_verify() {}
|
|
133 |
virtual void verify(VerifyOption option) {}
|
55767
|
134 |
|
|
135 |
virtual jlong millis_since_last_gc() {
|
|
136 |
// Report time since the VM start
|
|
137 |
return os::elapsed_counter() / NANOSECS_PER_MILLISEC;
|
|
138 |
}
|
|
139 |
|
56352
|
140 |
virtual void print_on(outputStream* st) const;
|
|
141 |
virtual void print_tracing_info() const;
|
|
142 |
|
55767
|
143 |
};
|
|
144 |
|
|
145 |
#endif // SHARE_VM_GC_EPSILON_COLLECTEDHEAP_HPP
|