author | mgronlun |
Wed, 30 Oct 2019 19:43:52 +0100 | |
changeset 58863 | c16ac7a2eba4 |
parent 54843 | 25c329958c70 |
child 59060 | fce1fa1bdc91 |
permissions | -rw-r--r-- |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52674
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
4 |
* |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
8 |
* |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
13 |
* accompanied this code). |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
14 |
* |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
18 |
* |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
21 |
* questions. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
22 |
* |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
23 |
*/ |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
24 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52674
diff
changeset
|
25 |
#ifndef SHARE_GC_G1_G1ALLOCATOR_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52674
diff
changeset
|
26 |
#define SHARE_GC_G1_G1ALLOCATOR_HPP |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
27 |
|
30764 | 28 |
#include "gc/g1/g1AllocRegion.hpp" |
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
29 |
#include "gc/g1/g1HeapRegionAttr.hpp" |
30764 | 30 |
#include "gc/shared/collectedHeap.hpp" |
31 |
#include "gc/shared/plab.hpp" |
|
30175 | 32 |
|
53411
aa87f38fcba2
8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents:
53244
diff
changeset
|
33 |
class G1EvacuationInfo; |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
34 |
|
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
35 |
// Interface to keep track of which regions G1 is currently allocating into. Provides |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
36 |
// some accessors (e.g. allocating into them, or getting their occupancy). |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
37 |
// Also keeps track of retained regions across GCs. |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
38 |
class G1Allocator : public CHeapObj<mtGC> { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
39 |
friend class VMStructs; |
49713 | 40 |
|
41 |
private: |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
42 |
G1CollectedHeap* _g1h; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
43 |
|
34146
42523f0da397
8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents:
33105
diff
changeset
|
44 |
bool _survivor_is_full; |
42523f0da397
8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents:
33105
diff
changeset
|
45 |
bool _old_is_full; |
49713 | 46 |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
47 |
// Alloc region used to satisfy mutator allocation requests. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
48 |
MutatorAllocRegion _mutator_alloc_region; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
49 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
50 |
// Alloc region used to satisfy allocation requests by the GC for |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
51 |
// survivor objects. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
52 |
SurvivorGCAllocRegion _survivor_gc_alloc_region; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
53 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
54 |
// Alloc region used to satisfy allocation requests by the GC for |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
55 |
// old objects. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
56 |
OldGCAllocRegion _old_gc_alloc_region; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
57 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
58 |
HeapRegion* _retained_old_gc_alloc_region; |
49713 | 59 |
|
60 |
bool survivor_is_full() const; |
|
61 |
bool old_is_full() const; |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
62 |
|
49713 | 63 |
void set_survivor_full(); |
64 |
void set_old_full(); |
|
34146
42523f0da397
8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents:
33105
diff
changeset
|
65 |
|
53411
aa87f38fcba2
8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents:
53244
diff
changeset
|
66 |
void reuse_retained_old_region(G1EvacuationInfo& evacuation_info, |
49713 | 67 |
OldGCAllocRegion* old, |
68 |
HeapRegion** retained); |
|
34146
42523f0da397
8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents:
33105
diff
changeset
|
69 |
|
49713 | 70 |
// Accessors to the allocation regions. |
71 |
inline MutatorAllocRegion* mutator_alloc_region(); |
|
72 |
inline SurvivorGCAllocRegion* survivor_gc_alloc_region(); |
|
73 |
inline OldGCAllocRegion* old_gc_alloc_region(); |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
74 |
|
49713 | 75 |
// Allocation attempt during GC for a survivor object / PLAB. |
76 |
HeapWord* survivor_attempt_allocation(size_t min_word_size, |
|
77 |
size_t desired_word_size, |
|
78 |
size_t* actual_word_size); |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
79 |
|
49713 | 80 |
// Allocation attempt during GC for an old object / PLAB. |
81 |
HeapWord* old_attempt_allocation(size_t min_word_size, |
|
82 |
size_t desired_word_size, |
|
83 |
size_t* actual_word_size); |
|
84 |
public: |
|
85 |
G1Allocator(G1CollectedHeap* heap); |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
86 |
|
49713 | 87 |
#ifdef ASSERT |
88 |
// Do we currently have an active mutator region to allocate into? |
|
89 |
bool has_mutator_alloc_region() { return mutator_alloc_region()->get() != NULL; } |
|
90 |
#endif |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
91 |
|
49713 | 92 |
void init_mutator_alloc_region(); |
93 |
void release_mutator_alloc_region(); |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
94 |
|
53411
aa87f38fcba2
8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents:
53244
diff
changeset
|
95 |
void init_gc_alloc_regions(G1EvacuationInfo& evacuation_info); |
aa87f38fcba2
8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents:
53244
diff
changeset
|
96 |
void release_gc_alloc_regions(G1EvacuationInfo& evacuation_info); |
49713 | 97 |
void abandon_gc_alloc_regions(); |
98 |
bool is_retained_old_region(HeapRegion* hr); |
|
99 |
||
100 |
// Allocate blocks of memory during mutator time. |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
101 |
|
49945 | 102 |
inline HeapWord* attempt_allocation(size_t min_word_size, |
103 |
size_t desired_word_size, |
|
104 |
size_t* actual_word_size); |
|
49713 | 105 |
inline HeapWord* attempt_allocation_locked(size_t word_size); |
106 |
inline HeapWord* attempt_allocation_force(size_t word_size); |
|
107 |
||
108 |
size_t unsafe_max_tlab_alloc(); |
|
109 |
size_t used_in_alloc_regions(); |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
110 |
|
49713 | 111 |
// Allocate blocks of memory during garbage collection. Will ensure an |
112 |
// allocation region, either by picking one or expanding the |
|
113 |
// heap, and then allocate a block of the given size. The block |
|
114 |
// may not be a humongous - it must fit into a single heap region. |
|
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
115 |
HeapWord* par_allocate_during_gc(G1HeapRegionAttr dest, |
49713 | 116 |
size_t word_size); |
117 |
||
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
118 |
HeapWord* par_allocate_during_gc(G1HeapRegionAttr dest, |
49713 | 119 |
size_t min_word_size, |
120 |
size_t desired_word_size, |
|
121 |
size_t* actual_word_size); |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
122 |
}; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
123 |
|
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
124 |
// Manages the PLABs used during garbage collection. Interface for allocation from PLABs. |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
125 |
// Needs to handle multiple contexts, extra alignment in any "survivor" area and some |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
126 |
// statistics. |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
127 |
class G1PLABAllocator : public CHeapObj<mtGC> { |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
128 |
friend class G1ParScanThreadState; |
49713 | 129 |
private: |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
130 |
G1CollectedHeap* _g1h; |
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
131 |
G1Allocator* _allocator; |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
132 |
|
49713 | 133 |
PLAB _surviving_alloc_buffer; |
134 |
PLAB _tenured_alloc_buffer; |
|
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
135 |
PLAB* _alloc_buffers[G1HeapRegionAttr::Num]; |
49713 | 136 |
|
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
137 |
// The survivor alignment in effect in bytes. |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
138 |
// == 0 : don't align survivors |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
139 |
// != 0 : align survivors to that alignment |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
140 |
// These values were chosen to favor the non-alignment case since some |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
141 |
// architectures have a special compare against zero instructions. |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
142 |
const uint _survivor_alignment_bytes; |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
143 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32378
diff
changeset
|
144 |
// Number of words allocated directly (not counting PLAB allocation). |
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
145 |
size_t _direct_allocated[G1HeapRegionAttr::Num]; |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32378
diff
changeset
|
146 |
|
49713 | 147 |
void flush_and_retire_stats(); |
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
148 |
inline PLAB* alloc_buffer(G1HeapRegionAttr dest); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
149 |
|
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
150 |
// Calculate the survivor space object alignment in bytes. Returns that or 0 if |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
151 |
// there are no restrictions on survivor alignment. |
49713 | 152 |
static uint calc_survivor_alignment_bytes(); |
32377
5ee15c417d02
8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents:
32185
diff
changeset
|
153 |
|
32383
bc9971c6bf2b
8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents:
32379
diff
changeset
|
154 |
bool may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const; |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
155 |
public: |
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
31975
diff
changeset
|
156 |
G1PLABAllocator(G1Allocator* allocator); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
157 |
|
53846
fe95464806a7
8219096: Merge print_termination_stats code with current logging
tschatzl
parents:
53411
diff
changeset
|
158 |
size_t waste() const; |
fe95464806a7
8219096: Merge print_termination_stats code with current logging
tschatzl
parents:
53411
diff
changeset
|
159 |
size_t undo_waste() const; |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
160 |
|
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
161 |
// Allocate word_sz words in dest, either directly into the regions or by |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
162 |
// allocating a new PLAB. Returns the address of the allocated memory, NULL if |
32377
5ee15c417d02
8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents:
32185
diff
changeset
|
163 |
// not successful. Plab_refill_failed indicates whether an attempt to refill the |
5ee15c417d02
8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents:
32185
diff
changeset
|
164 |
// PLAB failed or not. |
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
165 |
HeapWord* allocate_direct_or_new_plab(G1HeapRegionAttr dest, |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
166 |
size_t word_sz, |
32377
5ee15c417d02
8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents:
32185
diff
changeset
|
167 |
bool* plab_refill_failed); |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
168 |
|
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
169 |
// Allocate word_sz words in the PLAB of dest. Returns the address of the |
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
170 |
// allocated memory, NULL if not successful. |
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
171 |
inline HeapWord* plab_allocate(G1HeapRegionAttr dest, |
49323 | 172 |
size_t word_sz); |
28213
b0bf57cd1e9d
8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents:
26839
diff
changeset
|
173 |
|
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
174 |
inline HeapWord* allocate(G1HeapRegionAttr dest, |
49713 | 175 |
size_t word_sz, |
176 |
bool* refill_failed); |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
177 |
|
54843
25c329958c70
8200545: Improve filter for enqueued deferred cards
tschatzl
parents:
53846
diff
changeset
|
178 |
void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
179 |
}; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff
changeset
|
180 |
|
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
181 |
// G1ArchiveRegionMap is a boolean array used to mark G1 regions as |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
182 |
// archive regions. This allows a quick check for whether an object |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
183 |
// should not be marked because it is in an archive region. |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
184 |
class G1ArchiveRegionMap : public G1BiasedMappedArray<bool> { |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
185 |
protected: |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
186 |
bool default_value() const { return false; } |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
187 |
}; |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
188 |
|
31346
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
189 |
// G1ArchiveAllocator is used to allocate memory in archive |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
190 |
// regions. Such regions are not scavenged nor compacted by GC. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
191 |
// There are two types of archive regions, which are |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
192 |
// differ in the kind of references allowed for the contained objects: |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
193 |
// |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
194 |
// - 'Closed' archive region contain no references outside of other |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
195 |
// closed archive regions. The region is immutable by GC. GC does |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
196 |
// not mark object header in 'closed' archive region. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
197 |
// - An 'open' archive region allow references to any other regions, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
198 |
// including closed archive, open archive and other java heap regions. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
199 |
// GC can adjust pointers and mark object header in 'open' archive region. |
31346
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
200 |
class G1ArchiveAllocator : public CHeapObj<mtGC> { |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
201 |
protected: |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
202 |
bool _open; // Indicate if the region is 'open' archive. |
31346
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
203 |
G1CollectedHeap* _g1h; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
204 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
205 |
// The current allocation region |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
206 |
HeapRegion* _allocation_region; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
207 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
208 |
// Regions allocated for the current archive range. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
209 |
GrowableArray<HeapRegion*> _allocated_regions; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
210 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
211 |
// The number of bytes used in the current range. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
212 |
size_t _summary_bytes_used; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
213 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
214 |
// Current allocation window within the current region. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
215 |
HeapWord* _bottom; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
216 |
HeapWord* _top; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
217 |
HeapWord* _max; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
218 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
219 |
// Allocate a new region for this archive allocator. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
220 |
// Allocation is from the top of the reserved heap downward. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
221 |
bool alloc_new_region(); |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
222 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
223 |
public: |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
224 |
G1ArchiveAllocator(G1CollectedHeap* g1h, bool open) : |
51332 | 225 |
_open(open), |
31346
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
226 |
_g1h(g1h), |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
227 |
_allocation_region(NULL), |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
228 |
_allocated_regions((ResourceObj::set_allocation_type((address) &_allocated_regions, |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
229 |
ResourceObj::C_HEAP), |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
230 |
2), true /* C_Heap */), |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
231 |
_summary_bytes_used(0), |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
232 |
_bottom(NULL), |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
233 |
_top(NULL), |
51332 | 234 |
_max(NULL) { } |
31346
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
235 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
236 |
virtual ~G1ArchiveAllocator() { |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
237 |
assert(_allocation_region == NULL, "_allocation_region not NULL"); |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
238 |
} |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
239 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
240 |
static G1ArchiveAllocator* create_allocator(G1CollectedHeap* g1h, bool open); |
31346
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
241 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
242 |
// Allocate memory for an individual object. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
243 |
HeapWord* archive_mem_allocate(size_t word_size); |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
244 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
245 |
// Return the memory ranges used in the current archive, after |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
246 |
// aligning to the requested alignment. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
247 |
void complete_archive(GrowableArray<MemRegion>* ranges, |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
248 |
size_t end_alignment_in_bytes); |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
249 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
250 |
// The number of bytes allocated by this allocator. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
251 |
size_t used() { |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
252 |
return _summary_bytes_used; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
253 |
} |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
254 |
|
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
255 |
// Clear the count of bytes allocated in prior G1 regions. This |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
256 |
// must be done when recalculate_use is used to reset the counter |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
257 |
// for the generic allocator, since it counts bytes in all G1 |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
258 |
// regions, including those still associated with this allocator. |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
259 |
void clear_used() { |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
260 |
_summary_bytes_used = 0; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
261 |
} |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
262 |
|
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
263 |
// Create the _archive_region_map which is used to identify archive objects. |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
264 |
static inline void enable_archive_object_check(); |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
265 |
|
52674
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52062
diff
changeset
|
266 |
// Mark regions containing the specified address range as archive/non-archive. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
267 |
static inline void set_range_archive(MemRegion range, bool open); |
52674
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52062
diff
changeset
|
268 |
static inline void clear_range_archive(MemRegion range, bool open); |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
269 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
270 |
// Check if the object is in closed archive |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
271 |
static inline bool is_closed_archive_object(oop object); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
272 |
// Check if the object is in open archive |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
273 |
static inline bool is_open_archive_object(oop object); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
274 |
// Check if the object is either in closed archive or open archive |
52062
8dbf1a13af49
8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents:
51332
diff
changeset
|
275 |
static inline bool is_archived_object(oop object); |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
276 |
|
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
277 |
private: |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
278 |
static bool _archive_check_enabled; |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
279 |
static G1ArchiveRegionMap _closed_archive_region_map; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
280 |
static G1ArchiveRegionMap _open_archive_region_map; |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
281 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
282 |
// Check if an object is in a closed archive region using the _closed_archive_region_map. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
283 |
static inline bool in_closed_archive_range(oop object); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
284 |
// Check if an object is in open archive region using the _open_archive_region_map. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
285 |
static inline bool in_open_archive_range(oop object); |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
286 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
287 |
// Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
288 |
// unnecessarily. |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
34146
diff
changeset
|
289 |
static inline bool archive_check_enabled(); |
31346
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
290 |
}; |
a70d45c06136
8042668: GC Support for shared heap ranges in CDS
jiangli
parents:
30764
diff
changeset
|
291 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52674
diff
changeset
|
292 |
#endif // SHARE_GC_G1_G1ALLOCATOR_HPP |