Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/parallel/psOldGen.hpp
41149 views
1
/*
2
* Copyright (c) 2001, 2021, 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_GC_PARALLEL_PSOLDGEN_HPP
26
#define SHARE_GC_PARALLEL_PSOLDGEN_HPP
27
28
#include "gc/parallel/mutableSpace.hpp"
29
#include "gc/parallel/objectStartArray.hpp"
30
#include "gc/parallel/psGenerationCounters.hpp"
31
#include "gc/parallel/psVirtualspace.hpp"
32
#include "gc/parallel/spaceCounters.hpp"
33
#include "runtime/safepoint.hpp"
34
35
class PSOldGen : public CHeapObj<mtGC> {
36
friend class VMStructs;
37
38
private:
39
MemRegion _reserved; // Used for simple containment tests
40
PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem
41
ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block
42
MutableSpace* _object_space; // Where all the objects live
43
44
// Performance Counters
45
PSGenerationCounters* _gen_counters;
46
SpaceCounters* _space_counters;
47
48
// Sizing information, in bytes, set in constructor
49
const size_t _min_gen_size;
50
const size_t _max_gen_size;
51
52
// Block size for parallel iteration
53
static const size_t IterateBlockSize = 1024 * 1024;
54
55
#ifdef ASSERT
56
void assert_block_in_covered_region(MemRegion new_memregion) {
57
// Explictly capture current covered_region in a local
58
MemRegion covered_region = this->start_array()->covered_region();
59
assert(covered_region.contains(new_memregion),
60
"new region is not in covered_region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
61
"new region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
62
"object space [ " PTR_FORMAT ", " PTR_FORMAT " ]",
63
p2i(covered_region.start()),
64
p2i(covered_region.end()),
65
p2i(new_memregion.start()),
66
p2i(new_memregion.end()),
67
p2i(this->object_space()->used_region().start()),
68
p2i(this->object_space()->used_region().end()));
69
}
70
#endif
71
72
HeapWord* cas_allocate_noexpand(size_t word_size) {
73
assert_locked_or_safepoint(Heap_lock);
74
HeapWord* res = object_space()->cas_allocate(word_size);
75
if (res != NULL) {
76
DEBUG_ONLY(assert_block_in_covered_region(MemRegion(res, word_size)));
77
_start_array.allocate_block(res);
78
}
79
return res;
80
}
81
82
bool expand_for_allocate(size_t word_size);
83
bool expand(size_t bytes);
84
bool expand_by(size_t bytes);
85
bool expand_to_reserved();
86
87
void shrink(size_t bytes);
88
89
void post_resize();
90
91
void initialize(ReservedSpace rs, size_t initial_size, size_t alignment,
92
const char* perf_data_name, int level);
93
void initialize_virtual_space(ReservedSpace rs, size_t initial_size, size_t alignment);
94
void initialize_work(const char* perf_data_name, int level);
95
void initialize_performance_counters(const char* perf_data_name, int level);
96
97
public:
98
// Initialize the generation.
99
PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
100
size_t max_size, const char* perf_data_name, int level);
101
102
MemRegion reserved() const { return _reserved; }
103
size_t max_gen_size() const { return _max_gen_size; }
104
size_t min_gen_size() const { return _min_gen_size; }
105
106
bool is_in(const void* p) const {
107
return _virtual_space->contains((void *)p);
108
}
109
110
bool is_in_reserved(const void* p) const {
111
return reserved().contains(p);
112
}
113
114
MutableSpace* object_space() const { return _object_space; }
115
ObjectStartArray* start_array() { return &_start_array; }
116
PSVirtualSpace* virtual_space() const { return _virtual_space;}
117
118
// Has the generation been successfully allocated?
119
bool is_allocated();
120
121
// Size info
122
size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); }
123
size_t used_in_bytes() const { return object_space()->used_in_bytes(); }
124
size_t free_in_bytes() const { return object_space()->free_in_bytes(); }
125
126
size_t capacity_in_words() const { return object_space()->capacity_in_words(); }
127
size_t used_in_words() const { return object_space()->used_in_words(); }
128
size_t free_in_words() const { return object_space()->free_in_words(); }
129
130
bool is_maximal_no_gc() const {
131
return virtual_space()->uncommitted_size() == 0;
132
}
133
134
// Calculating new sizes
135
void resize(size_t desired_free_space);
136
137
HeapWord* allocate(size_t word_size) {
138
HeapWord* res;
139
do {
140
res = cas_allocate_noexpand(word_size);
141
// Retry failed allocation if expand succeeds.
142
} while ((res == nullptr) && expand_for_allocate(word_size));
143
return res;
144
}
145
146
// Iteration.
147
void oop_iterate(OopIterateClosure* cl) { object_space()->oop_iterate(cl); }
148
void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); }
149
150
// Number of blocks to be iterated over in the used part of old gen.
151
size_t num_iterable_blocks() const;
152
// Iterate the objects starting in block block_index within [bottom, top) of the
153
// old gen. The object just reaching into this block is not iterated over.
154
// A block is an evenly sized non-overlapping part of the old gen of
155
// IterateBlockSize bytes.
156
void object_iterate_block(ObjectClosure* cl, size_t block_index);
157
158
// Debugging - do not use for time critical operations
159
void print() const;
160
virtual void print_on(outputStream* st) const;
161
162
void verify();
163
void verify_object_start_array();
164
165
// Performance Counter support
166
void update_counters();
167
168
// Printing support
169
const char* name() const { return "ParOldGen"; }
170
171
// Debugging support
172
// Save the tops of all spaces for later use during mangling.
173
void record_spaces_top() PRODUCT_RETURN;
174
};
175
176
#endif // SHARE_GC_PARALLEL_PSOLDGEN_HPP
177
178