author | stefank |
Thu, 22 Feb 2018 18:36:32 +0100 | |
changeset 49048 | 4e8c86b75428 |
parent 49047 | 8f004146e407 |
child 49049 | effb50eeea4e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
48961
120b61d50f85
8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
48168
diff
changeset
|
2 |
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5433
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5433
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5433
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
42650 | 26 |
#include "aot/aotLoader.hpp" |
7397 | 27 |
#include "classfile/symbolTable.hpp" |
46742 | 28 |
#include "classfile/stringTable.hpp" |
7397 | 29 |
#include "classfile/systemDictionary.hpp" |
30 |
#include "classfile/vmSymbols.hpp" |
|
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
31 |
#include "code/codeCache.hpp" |
7397 | 32 |
#include "code/icBuffer.hpp" |
49048
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
33 |
#include "gc/shared/adaptiveSizePolicy.hpp" |
49044 | 34 |
#include "gc/shared/cardTableRS.hpp" |
30764 | 35 |
#include "gc/shared/collectedHeap.inline.hpp" |
36 |
#include "gc/shared/collectorCounters.hpp" |
|
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
37 |
#include "gc/shared/gcId.hpp" |
30764 | 38 |
#include "gc/shared/gcLocker.inline.hpp" |
39 |
#include "gc/shared/gcTrace.hpp" |
|
35061 | 40 |
#include "gc/shared/gcTraceTime.inline.hpp" |
30764 | 41 |
#include "gc/shared/genCollectedHeap.hpp" |
42 |
#include "gc/shared/genOopClosures.inline.hpp" |
|
43 |
#include "gc/shared/generationSpec.hpp" |
|
44 |
#include "gc/shared/space.hpp" |
|
45 |
#include "gc/shared/strongRootsScope.hpp" |
|
46 |
#include "gc/shared/vmGCOperations.hpp" |
|
47648
226b1fc611b9
8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
47624
diff
changeset
|
47 |
#include "gc/shared/weakProcessor.hpp" |
30764 | 48 |
#include "gc/shared/workgroup.hpp" |
7397 | 49 |
#include "memory/filemap.hpp" |
50 |
#include "memory/resourceArea.hpp" |
|
51 |
#include "oops/oop.inline.hpp" |
|
52 |
#include "runtime/biasedLocking.hpp" |
|
53 |
#include "runtime/handles.hpp" |
|
54 |
#include "runtime/handles.inline.hpp" |
|
55 |
#include "runtime/java.hpp" |
|
56 |
#include "runtime/vmThread.hpp" |
|
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
57 |
#include "services/management.hpp" |
7397 | 58 |
#include "services/memoryService.hpp" |
46560
388aa8d67c80
8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
43455
diff
changeset
|
59 |
#include "utilities/debug.hpp" |
388aa8d67c80
8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents:
43455
diff
changeset
|
60 |
#include "utilities/formatBuffer.hpp" |
30175 | 61 |
#include "utilities/macros.hpp" |
62 |
#include "utilities/stack.inline.hpp" |
|
7397 | 63 |
#include "utilities/vmError.hpp" |
1 | 64 |
|
65 |
GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy) : |
|
30154 | 66 |
CollectedHeap(), |
28217
57791914628c
8067499: G1SATBCardTableModRefBS should not inherit from CardTableModRefBSForCTRS
kbarrett
parents:
28212
diff
changeset
|
67 |
_rem_set(NULL), |
1 | 68 |
_gen_policy(policy), |
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
49046
diff
changeset
|
69 |
_soft_ref_gen_policy(), |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
70 |
_process_strong_tasks(new SubTasksDone(GCH_PS_NumElements)), |
1 | 71 |
_full_collections_completed(0) |
72 |
{ |
|
73 |
assert(policy != NULL, "Sanity check"); |
|
74 |
} |
|
75 |
||
76 |
jint GenCollectedHeap::initialize() { |
|
77 |
// While there are no constraints in the GC code that HeapWordSize |
|
78 |
// be any particular value, there are multiple other areas in the |
|
79 |
// system which believe this to be true (e.g. oop->object_size in some |
|
80 |
// cases incorrectly returns the size in wordSize units rather than |
|
81 |
// HeapWordSize). |
|
82 |
guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize"); |
|
83 |
||
84 |
// Allocate space for the heap. |
|
85 |
||
86 |
char* heap_address; |
|
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
87 |
ReservedSpace heap_rs; |
1 | 88 |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
89 |
size_t heap_alignment = collector_policy()->heap_alignment(); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
90 |
|
28939 | 91 |
heap_address = allocate(heap_alignment, &heap_rs); |
1 | 92 |
|
93 |
if (!heap_rs.is_reserved()) { |
|
94 |
vm_shutdown_during_initialization( |
|
95 |
"Could not reserve enough space for object heap"); |
|
96 |
return JNI_ENOMEM; |
|
97 |
} |
|
98 |
||
26829
26315213bab8
8055091: CollectedHeap::_reserved usage should be cleaned up
mlarsson
parents:
26183
diff
changeset
|
99 |
initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); |
1 | 100 |
|
49044 | 101 |
_rem_set = new CardTableRS(reserved_region()); |
1 | 102 |
set_barrier_set(rem_set()->bs()); |
4637 | 103 |
|
29794 | 104 |
ReservedSpace young_rs = heap_rs.first_part(gen_policy()->young_gen_spec()->max_size(), false, false); |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
105 |
_young_gen = gen_policy()->young_gen_spec()->init(young_rs, rem_set()); |
29794 | 106 |
heap_rs = heap_rs.last_part(gen_policy()->young_gen_spec()->max_size()); |
29200 | 107 |
|
29794 | 108 |
ReservedSpace old_rs = heap_rs.first_part(gen_policy()->old_gen_spec()->max_size(), false, false); |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
109 |
_old_gen = gen_policy()->old_gen_spec()->init(old_rs, rem_set()); |
6985
e9364ec299ac
6896603: CMS/GCH: collection_attempt_is_safe() ergo should use more recent data
ysr
parents:
6759
diff
changeset
|
110 |
clear_incremental_collection_failed(); |
1 | 111 |
|
112 |
return JNI_OK; |
|
113 |
} |
|
114 |
||
49048
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
115 |
void GenCollectedHeap::initialize_size_policy(size_t init_eden_size, |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
116 |
size_t init_promo_size, |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
117 |
size_t init_survivor_size) { |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
118 |
const double max_gc_pause_sec = ((double) MaxGCPauseMillis) / 1000.0; |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
119 |
_size_policy = new AdaptiveSizePolicy(init_eden_size, |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
120 |
init_promo_size, |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
121 |
init_survivor_size, |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
122 |
max_gc_pause_sec, |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
123 |
GCTimeRatio); |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
124 |
} |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
125 |
|
1 | 126 |
char* GenCollectedHeap::allocate(size_t alignment, |
127 |
ReservedSpace* heap_rs){ |
|
128 |
// Now figure out the total size. |
|
29794 | 129 |
const size_t pageSize = UseLargePages ? os::large_page_size() : os::vm_page_size(); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
130 |
assert(alignment % pageSize == 0, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
131 |
|
29794 | 132 |
GenerationSpec* young_spec = gen_policy()->young_gen_spec(); |
133 |
GenerationSpec* old_spec = gen_policy()->old_gen_spec(); |
|
134 |
||
135 |
// Check for overflow. |
|
136 |
size_t total_reserved = young_spec->max_size() + old_spec->max_size(); |
|
137 |
if (total_reserved < young_spec->max_size()) { |
|
138 |
vm_exit_during_initialization("The size of the object heap + VM data exceeds " |
|
139 |
"the maximum representable size"); |
|
1 | 140 |
} |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
141 |
assert(total_reserved % alignment == 0, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32735
diff
changeset
|
142 |
"Gen size; total_reserved=" SIZE_FORMAT ", alignment=" |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32735
diff
changeset
|
143 |
SIZE_FORMAT, total_reserved, alignment); |
1 | 144 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
145 |
*heap_rs = Universe::reserve_heap(total_reserved, alignment); |
37462 | 146 |
|
147 |
os::trace_page_sizes("Heap", |
|
148 |
collector_policy()->min_heap_byte_size(), |
|
149 |
total_reserved, |
|
150 |
alignment, |
|
151 |
heap_rs->base(), |
|
152 |
heap_rs->size()); |
|
153 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
154 |
return heap_rs->base(); |
1 | 155 |
} |
156 |
||
157 |
void GenCollectedHeap::post_initialize() { |
|
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47819
diff
changeset
|
158 |
CollectedHeap::post_initialize(); |
30152 | 159 |
ref_processing_init(); |
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47546
diff
changeset
|
160 |
check_gen_kinds(); |
29684
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
161 |
DefNewGeneration* def_new_gen = (DefNewGeneration*)_young_gen; |
1 | 162 |
|
49048
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
163 |
initialize_size_policy(def_new_gen->eden()->capacity(), |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
164 |
_old_gen->capacity(), |
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
165 |
def_new_gen->from()->capacity()); |
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
49046
diff
changeset
|
166 |
|
32735
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
167 |
_gen_policy->initialize_gc_policy_counters(); |
1 | 168 |
} |
169 |
||
170 |
void GenCollectedHeap::ref_processing_init() { |
|
29200 | 171 |
_young_gen->ref_processor_init(); |
172 |
_old_gen->ref_processor_init(); |
|
1 | 173 |
} |
174 |
||
175 |
size_t GenCollectedHeap::capacity() const { |
|
29200 | 176 |
return _young_gen->capacity() + _old_gen->capacity(); |
1 | 177 |
} |
178 |
||
179 |
size_t GenCollectedHeap::used() const { |
|
29200 | 180 |
return _young_gen->used() + _old_gen->used(); |
1 | 181 |
} |
182 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
183 |
void GenCollectedHeap::save_used_regions() { |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
184 |
_old_gen->save_used_region(); |
29200 | 185 |
_young_gen->save_used_region(); |
1 | 186 |
} |
187 |
||
188 |
size_t GenCollectedHeap::max_capacity() const { |
|
29200 | 189 |
return _young_gen->max_capacity() + _old_gen->max_capacity(); |
1 | 190 |
} |
191 |
||
192 |
// Update the _full_collections_completed counter |
|
193 |
// at the end of a stop-world full GC. |
|
194 |
unsigned int GenCollectedHeap::update_full_collections_completed() { |
|
195 |
MonitorLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag); |
|
196 |
assert(_full_collections_completed <= _total_full_collections, |
|
197 |
"Can't complete more collections than were started"); |
|
198 |
_full_collections_completed = _total_full_collections; |
|
199 |
ml.notify_all(); |
|
200 |
return _full_collections_completed; |
|
201 |
} |
|
202 |
||
203 |
// Update the _full_collections_completed counter, as appropriate, |
|
204 |
// at the end of a concurrent GC cycle. Note the conditional update |
|
205 |
// below to allow this method to be called by a concurrent collector |
|
206 |
// without synchronizing in any manner with the VM thread (which |
|
207 |
// may already have initiated a STW full collection "concurrently"). |
|
208 |
unsigned int GenCollectedHeap::update_full_collections_completed(unsigned int count) { |
|
209 |
MonitorLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag); |
|
210 |
assert((_full_collections_completed <= _total_full_collections) && |
|
211 |
(count <= _total_full_collections), |
|
212 |
"Can't complete more collections than were started"); |
|
213 |
if (count > _full_collections_completed) { |
|
214 |
_full_collections_completed = count; |
|
215 |
ml.notify_all(); |
|
216 |
} |
|
217 |
return _full_collections_completed; |
|
218 |
} |
|
219 |
||
49046
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
220 |
// Return true if any of the following is true: |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
221 |
// . the allocation won't fit into the current young gen heap |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
222 |
// . gc locker is occupied (jni critical section) |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
223 |
// . heap memory is tight -- the most recent previous collection |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
224 |
// was a full collection because a partial collection (would |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
225 |
// have) failed and is likely to fail again |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
226 |
bool GenCollectedHeap::should_try_older_generation_allocation(size_t word_size) const { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
227 |
size_t young_capacity = young_gen()->capacity_before_gc(); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
228 |
return (word_size > heap_word_size(young_capacity)) |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
229 |
|| GCLocker::is_active_and_needs_gc() |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
230 |
|| incremental_collection_failed(); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
231 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
232 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
233 |
HeapWord* GenCollectedHeap::expand_heap_and_allocate(size_t size, bool is_tlab) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
234 |
HeapWord* result = NULL; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
235 |
if (old_gen()->should_allocate(size, is_tlab)) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
236 |
result = old_gen()->expand_and_allocate(size, is_tlab); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
237 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
238 |
if (result == NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
239 |
if (young_gen()->should_allocate(size, is_tlab)) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
240 |
result = young_gen()->expand_and_allocate(size, is_tlab); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
241 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
242 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
243 |
assert(result == NULL || is_in_reserved(result), "result not in heap"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
244 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
245 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
246 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
247 |
HeapWord* GenCollectedHeap::mem_allocate_work(size_t size, |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
248 |
bool is_tlab, |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
249 |
bool* gc_overhead_limit_was_exceeded) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
250 |
debug_only(check_for_valid_allocation_state()); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
251 |
assert(no_gc_in_progress(), "Allocation during gc not allowed"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
252 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
253 |
// In general gc_overhead_limit_was_exceeded should be false so |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
254 |
// set it so here and reset it to true only if the gc time |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
255 |
// limit is being exceeded as checked below. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
256 |
*gc_overhead_limit_was_exceeded = false; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
257 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
258 |
HeapWord* result = NULL; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
259 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
260 |
// Loop until the allocation is satisfied, or unsatisfied after GC. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
261 |
for (uint try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
262 |
HandleMark hm; // Discard any handles allocated in each iteration. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
263 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
264 |
// First allocation attempt is lock-free. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
265 |
Generation *young = young_gen(); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
266 |
assert(young->supports_inline_contig_alloc(), |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
267 |
"Otherwise, must do alloc within heap lock"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
268 |
if (young->should_allocate(size, is_tlab)) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
269 |
result = young->par_allocate(size, is_tlab); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
270 |
if (result != NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
271 |
assert(is_in_reserved(result), "result not in heap"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
272 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
273 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
274 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
275 |
uint gc_count_before; // Read inside the Heap_lock locked region. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
276 |
{ |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
277 |
MutexLocker ml(Heap_lock); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
278 |
log_trace(gc, alloc)("GenCollectedHeap::mem_allocate_work: attempting locked slow path allocation"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
279 |
// Note that only large objects get a shot at being |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
280 |
// allocated in later generations. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
281 |
bool first_only = !should_try_older_generation_allocation(size); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
282 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
283 |
result = attempt_allocation(size, is_tlab, first_only); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
284 |
if (result != NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
285 |
assert(is_in_reserved(result), "result not in heap"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
286 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
287 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
288 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
289 |
if (GCLocker::is_active_and_needs_gc()) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
290 |
if (is_tlab) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
291 |
return NULL; // Caller will retry allocating individual object. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
292 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
293 |
if (!is_maximal_no_gc()) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
294 |
// Try and expand heap to satisfy request. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
295 |
result = expand_heap_and_allocate(size, is_tlab); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
296 |
// Result could be null if we are out of space. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
297 |
if (result != NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
298 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
299 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
300 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
301 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
302 |
if (gclocker_stalled_count > GCLockerRetryAllocationCount) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
303 |
return NULL; // We didn't get to do a GC and we didn't get any memory. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
304 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
305 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
306 |
// If this thread is not in a jni critical section, we stall |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
307 |
// the requestor until the critical section has cleared and |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
308 |
// GC allowed. When the critical section clears, a GC is |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
309 |
// initiated by the last thread exiting the critical section; so |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
310 |
// we retry the allocation sequence from the beginning of the loop, |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
311 |
// rather than causing more, now probably unnecessary, GC attempts. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
312 |
JavaThread* jthr = JavaThread::current(); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
313 |
if (!jthr->in_critical()) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
314 |
MutexUnlocker mul(Heap_lock); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
315 |
// Wait for JNI critical section to be exited |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
316 |
GCLocker::stall_until_clear(); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
317 |
gclocker_stalled_count += 1; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
318 |
continue; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
319 |
} else { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
320 |
if (CheckJNICalls) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
321 |
fatal("Possible deadlock due to allocating while" |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
322 |
" in jni critical section"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
323 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
324 |
return NULL; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
325 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
326 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
327 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
328 |
// Read the gc count while the heap lock is held. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
329 |
gc_count_before = total_collections(); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
330 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
331 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
332 |
VM_GenCollectForAllocation op(size, is_tlab, gc_count_before); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
333 |
VMThread::execute(&op); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
334 |
if (op.prologue_succeeded()) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
335 |
result = op.result(); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
336 |
if (op.gc_locked()) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
337 |
assert(result == NULL, "must be NULL if gc_locked() is true"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
338 |
continue; // Retry and/or stall as necessary. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
339 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
340 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
341 |
// Allocation has failed and a collection |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
342 |
// has been done. If the gc time limit was exceeded the |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
343 |
// this time, return NULL so that an out-of-memory |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
344 |
// will be thrown. Clear gc_overhead_limit_exceeded |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
345 |
// so that the overhead exceeded does not persist. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
346 |
|
49048
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
347 |
const bool limit_exceeded = size_policy()->gc_overhead_limit_exceeded(); |
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
49046
diff
changeset
|
348 |
const bool softrefs_clear = soft_ref_policy()->all_soft_refs_clear(); |
49046
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
349 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
350 |
if (limit_exceeded && softrefs_clear) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
351 |
*gc_overhead_limit_was_exceeded = true; |
49048
4e8c86b75428
8198525: Move _size_policy out of GenCollectorPolicy into GenCollectedHeap
stefank
parents:
49047
diff
changeset
|
352 |
size_policy()->set_gc_overhead_limit_exceeded(false); |
49046
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
353 |
if (op.result() != NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
354 |
CollectedHeap::fill_with_object(op.result(), size); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
355 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
356 |
return NULL; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
357 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
358 |
assert(result == NULL || is_in_reserved(result), |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
359 |
"result not in heap"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
360 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
361 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
362 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
363 |
// Give a warning if we seem to be looping forever. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
364 |
if ((QueuedAllocationWarningCount > 0) && |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
365 |
(try_count % QueuedAllocationWarningCount == 0)) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
366 |
log_warning(gc, ergo)("GenCollectedHeap::mem_allocate_work retries %d times," |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
367 |
" size=" SIZE_FORMAT " %s", try_count, size, is_tlab ? "(TLAB)" : ""); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
368 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
369 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
370 |
} |
1 | 371 |
|
372 |
#ifndef PRODUCT |
|
373 |
// Override of memory state checking method in CollectedHeap: |
|
374 |
// Some collectors (CMS for example) can't have badHeapWordVal written |
|
375 |
// in the first two words of an object. (For instance , in the case of |
|
376 |
// CMS these words hold state used to synchronize between certain |
|
377 |
// (concurrent) GC steps and direct allocating mutators.) |
|
378 |
// The skip_header_HeapWords() method below, allows us to skip |
|
379 |
// over the requisite number of HeapWord's. Note that (for |
|
380 |
// generational collectors) this means that those many words are |
|
381 |
// skipped in each object, irrespective of the generation in which |
|
382 |
// that object lives. The resultant loss of precision seems to be |
|
383 |
// harmless and the pain of avoiding that imprecision appears somewhat |
|
384 |
// higher than we are prepared to pay for such rudimentary debugging |
|
385 |
// support. |
|
386 |
void GenCollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, |
|
387 |
size_t size) { |
|
388 |
if (CheckMemoryInitialization && ZapUnusedHeapArea) { |
|
389 |
// We are asked to check a size in HeapWords, |
|
390 |
// but the memory is mangled in juint words. |
|
391 |
juint* start = (juint*) (addr + skip_header_HeapWords()); |
|
392 |
juint* end = (juint*) (addr + size); |
|
393 |
for (juint* slot = start; slot < end; slot += 1) { |
|
394 |
assert(*slot == badHeapWordVal, |
|
395 |
"Found non badHeapWordValue in pre-allocation check"); |
|
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
#endif |
|
400 |
||
401 |
HeapWord* GenCollectedHeap::attempt_allocation(size_t size, |
|
402 |
bool is_tlab, |
|
403 |
bool first_only) { |
|
29200 | 404 |
HeapWord* res = NULL; |
405 |
||
406 |
if (_young_gen->should_allocate(size, is_tlab)) { |
|
407 |
res = _young_gen->allocate(size, is_tlab); |
|
408 |
if (res != NULL || first_only) { |
|
409 |
return res; |
|
1 | 410 |
} |
411 |
} |
|
29200 | 412 |
|
413 |
if (_old_gen->should_allocate(size, is_tlab)) { |
|
414 |
res = _old_gen->allocate(size, is_tlab); |
|
415 |
} |
|
416 |
||
417 |
return res; |
|
1 | 418 |
} |
419 |
||
420 |
HeapWord* GenCollectedHeap::mem_allocate(size_t size, |
|
421 |
bool* gc_overhead_limit_was_exceeded) { |
|
49046
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
422 |
return mem_allocate_work(size, |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
423 |
false /* is_tlab */, |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
424 |
gc_overhead_limit_was_exceeded); |
1 | 425 |
} |
426 |
||
427 |
bool GenCollectedHeap::must_clear_all_soft_refs() { |
|
37149
f025738bbada
8152113: Remove _last_ditch_collection GC-cause and avoid expanding heap on Metaspace OOM
sjohanss
parents:
37146
diff
changeset
|
428 |
return _gc_cause == GCCause::_metadata_GC_clear_soft_refs || |
f025738bbada
8152113: Remove _last_ditch_collection GC-cause and avoid expanding heap on Metaspace OOM
sjohanss
parents:
37146
diff
changeset
|
429 |
_gc_cause == GCCause::_wb_full_gc; |
1 | 430 |
} |
431 |
||
29200 | 432 |
void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t size, |
433 |
bool is_tlab, bool run_verification, bool clear_soft_refs, |
|
434 |
bool restore_marks_for_biased_locking) { |
|
35061 | 435 |
FormatBuffer<> title("Collect gen: %s", gen->short_name()); |
37146 | 436 |
GCTraceTime(Trace, gc, phases) t1(title); |
29200 | 437 |
TraceCollectorStats tcs(gen->counters()); |
48168
cb5d2d4453d0
8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents:
47819
diff
changeset
|
438 |
TraceMemoryManagerStats tmms(gen->gc_manager(), gc_cause()); |
29200 | 439 |
|
440 |
gen->stat_record()->invocations++; |
|
441 |
gen->stat_record()->accumulated_time.start(); |
|
442 |
||
443 |
// Must be done anew before each collection because |
|
444 |
// a previous collection will do mangling and will |
|
445 |
// change top of some spaces. |
|
446 |
record_gen_tops_before_GC(); |
|
447 |
||
35061 | 448 |
log_trace(gc)("%s invoke=%d size=" SIZE_FORMAT, heap()->is_young_gen(gen) ? "Young" : "Old", gen->stat_record()->invocations, size * HeapWordSize); |
29200 | 449 |
|
450 |
if (run_verification && VerifyBeforeGC) { |
|
451 |
HandleMark hm; // Discard invalid handles created during verification |
|
35061 | 452 |
Universe::verify("Before GC"); |
29200 | 453 |
} |
454 |
COMPILER2_PRESENT(DerivedPointerTable::clear()); |
|
455 |
||
456 |
if (restore_marks_for_biased_locking) { |
|
457 |
// We perform this mark word preservation work lazily |
|
458 |
// because it's only at this point that we know whether we |
|
459 |
// absolutely have to do it; we want to avoid doing it for |
|
460 |
// scavenge-only collections where it's unnecessary |
|
461 |
BiasedLocking::preserve_marks(); |
|
462 |
} |
|
463 |
||
464 |
// Do collection work |
|
465 |
{ |
|
466 |
// Note on ref discovery: For what appear to be historical reasons, |
|
467 |
// GCH enables and disabled (by enqueing) refs discovery. |
|
468 |
// In the future this should be moved into the generation's |
|
469 |
// collect method so that ref discovery and enqueueing concerns |
|
470 |
// are local to a generation. The collect method could return |
|
471 |
// an appropriate indication in the case that notification on |
|
472 |
// the ref lock was needed. This will make the treatment of |
|
473 |
// weak refs more uniform (and indeed remove such concerns |
|
474 |
// from GCH). XXX |
|
475 |
||
476 |
HandleMark hm; // Discard invalid handles created during gc |
|
477 |
save_marks(); // save marks for all gens |
|
478 |
// We want to discover references, but not process them yet. |
|
479 |
// This mode is disabled in process_discovered_references if the |
|
480 |
// generation does some collection work, or in |
|
481 |
// enqueue_discovered_references if the generation returns |
|
482 |
// without doing any work. |
|
483 |
ReferenceProcessor* rp = gen->ref_processor(); |
|
484 |
// If the discovery of ("weak") refs in this generation is |
|
485 |
// atomic wrt other collectors in this configuration, we |
|
486 |
// are guaranteed to have empty discovered ref lists. |
|
487 |
if (rp->discovery_is_atomic()) { |
|
488 |
rp->enable_discovery(); |
|
489 |
rp->setup_policy(clear_soft_refs); |
|
490 |
} else { |
|
491 |
// collect() below will enable discovery as appropriate |
|
492 |
} |
|
493 |
gen->collect(full, clear_soft_refs, size, is_tlab); |
|
494 |
if (!rp->enqueuing_is_done()) { |
|
46795
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
46742
diff
changeset
|
495 |
ReferenceProcessorPhaseTimes pt(NULL, rp->num_q()); |
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
46742
diff
changeset
|
496 |
rp->enqueue_discovered_references(NULL, &pt); |
623a5e42deb6
8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
46742
diff
changeset
|
497 |
pt.print_enqueue_phase(); |
29200 | 498 |
} else { |
499 |
rp->set_enqueuing_is_done(false); |
|
500 |
} |
|
501 |
rp->verify_no_references_recorded(); |
|
502 |
} |
|
503 |
||
504 |
COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); |
|
505 |
||
506 |
gen->stat_record()->accumulated_time.stop(); |
|
507 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
508 |
update_gc_stats(gen, full); |
29200 | 509 |
|
510 |
if (run_verification && VerifyAfterGC) { |
|
511 |
HandleMark hm; // Discard invalid handles created during verification |
|
35061 | 512 |
Universe::verify("After GC"); |
29200 | 513 |
} |
514 |
} |
|
515 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
516 |
void GenCollectedHeap::do_collection(bool full, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
517 |
bool clear_all_soft_refs, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
518 |
size_t size, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
519 |
bool is_tlab, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
520 |
GenerationType max_generation) { |
1 | 521 |
ResourceMark rm; |
522 |
DEBUG_ONLY(Thread* my_thread = Thread::current();) |
|
523 |
||
524 |
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); |
|
525 |
assert(my_thread->is_VM_thread() || |
|
526 |
my_thread->is_ConcurrentGC_thread(), |
|
527 |
"incorrect thread type capability"); |
|
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
528 |
assert(Heap_lock->is_locked(), |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
529 |
"the requesting thread should have the Heap_lock"); |
1 | 530 |
guarantee(!is_gc_active(), "collection is not reentrant"); |
531 |
||
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
35061
diff
changeset
|
532 |
if (GCLocker::check_active_before_gc()) { |
1 | 533 |
return; // GC is disabled (e.g. JNI GetXXXCritical operation) |
534 |
} |
|
535 |
||
49031 | 536 |
GCIdMark gc_id_mark; |
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
537 |
|
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
538 |
const bool do_clear_all_soft_refs = clear_all_soft_refs || |
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
49046
diff
changeset
|
539 |
soft_ref_policy()->should_clear_all_soft_refs(); |
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
540 |
|
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
49046
diff
changeset
|
541 |
ClearedAllSoftRefs casr(do_clear_all_soft_refs, soft_ref_policy()); |
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
542 |
|
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23508
diff
changeset
|
543 |
const size_t metadata_prev_used = MetaspaceAux::used_bytes(); |
1 | 544 |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11396
diff
changeset
|
545 |
print_heap_before_gc(); |
1 | 546 |
|
547 |
{ |
|
548 |
FlagSetting fl(_is_gc_active, true); |
|
549 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
550 |
bool complete = full && (max_generation == OldGen); |
35061 | 551 |
bool old_collects_young = complete && !ScavengeBeforeFullGC; |
552 |
bool do_young_collection = !old_collects_young && _young_gen->should_collect(full, size, is_tlab); |
|
553 |
||
554 |
FormatBuffer<> gc_string("%s", "Pause "); |
|
555 |
if (do_young_collection) { |
|
556 |
gc_string.append("Young"); |
|
557 |
} else { |
|
558 |
gc_string.append("Full"); |
|
559 |
} |
|
560 |
||
561 |
GCTraceCPUTime tcpu; |
|
562 |
GCTraceTime(Info, gc) t(gc_string, NULL, gc_cause(), true); |
|
1 | 563 |
|
564 |
gc_prologue(complete); |
|
565 |
increment_total_collections(complete); |
|
566 |
||
35061 | 567 |
size_t young_prev_used = _young_gen->used(); |
568 |
size_t old_prev_used = _old_gen->used(); |
|
569 |
||
29200 | 570 |
bool run_verification = total_collections() >= VerifyGCStartAt; |
1 | 571 |
|
29200 | 572 |
bool prepared_for_verification = false; |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
573 |
bool collected_old = false; |
33580 | 574 |
|
35061 | 575 |
if (do_young_collection) { |
29200 | 576 |
if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) { |
577 |
prepare_for_verify(); |
|
578 |
prepared_for_verification = true; |
|
579 |
} |
|
580 |
||
581 |
collect_generation(_young_gen, |
|
582 |
full, |
|
583 |
size, |
|
584 |
is_tlab, |
|
585 |
run_verification && VerifyGCLevel <= 0, |
|
586 |
do_clear_all_soft_refs, |
|
587 |
false); |
|
588 |
||
589 |
if (size > 0 && (!is_tlab || _young_gen->supports_tlab_allocation()) && |
|
590 |
size * HeapWordSize <= _young_gen->unsafe_max_alloc_nogc()) { |
|
591 |
// Allocation request was met by young GC. |
|
592 |
size = 0; |
|
27252 | 593 |
} |
1 | 594 |
} |
595 |
||
27252 | 596 |
bool must_restore_marks_for_biased_locking = false; |
597 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
598 |
if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) { |
29200 | 599 |
if (!complete) { |
600 |
// The full_collections increment was missed above. |
|
601 |
increment_total_full_collections(); |
|
602 |
} |
|
27252 | 603 |
|
29200 | 604 |
if (!prepared_for_verification && run_verification && |
605 |
VerifyGCLevel <= 1 && VerifyBeforeGC) { |
|
606 |
prepare_for_verify(); |
|
607 |
} |
|
27252 | 608 |
|
35061 | 609 |
if (do_young_collection) { |
610 |
// We did a young GC. Need a new GC id for the old GC. |
|
49031 | 611 |
GCIdMark gc_id_mark; |
35061 | 612 |
GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true); |
613 |
collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true); |
|
614 |
} else { |
|
615 |
// No young GC done. Use the same GC id as was set up earlier in this method. |
|
616 |
collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true); |
|
617 |
} |
|
27252 | 618 |
|
29200 | 619 |
must_restore_marks_for_biased_locking = true; |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
620 |
collected_old = true; |
1 | 621 |
} |
622 |
||
623 |
// Update "complete" boolean wrt what actually transpired -- |
|
624 |
// for instance, a promotion failure could have led to |
|
625 |
// a whole heap collection. |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
626 |
complete = complete || collected_old; |
1 | 627 |
|
35061 | 628 |
print_heap_change(young_prev_used, old_prev_used); |
629 |
MetaspaceAux::print_metaspace_change(metadata_prev_used); |
|
1 | 630 |
|
29200 | 631 |
// Adjust generation sizes. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
632 |
if (collected_old) { |
29200 | 633 |
_old_gen->compute_new_size(); |
1 | 634 |
} |
29200 | 635 |
_young_gen->compute_new_size(); |
1 | 636 |
|
637 |
if (complete) { |
|
16385
4a05c6d94b04
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
15482
diff
changeset
|
638 |
// Delete metaspaces for unloaded class loaders and clean up loader_data graph |
4a05c6d94b04
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
15482
diff
changeset
|
639 |
ClassLoaderDataGraph::purge(); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17105
diff
changeset
|
640 |
MetaspaceAux::verify_metrics(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
641 |
// Resize the metaspace capacity after full collections |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
642 |
MetaspaceGC::compute_new_size(); |
1 | 643 |
update_full_collections_completed(); |
644 |
} |
|
645 |
||
646 |
// Track memory usage and detect low memory after GC finishes |
|
647 |
MemoryService::track_memory_usage(); |
|
648 |
||
649 |
gc_epilogue(complete); |
|
650 |
||
651 |
if (must_restore_marks_for_biased_locking) { |
|
652 |
BiasedLocking::restore_marks(); |
|
653 |
} |
|
654 |
} |
|
655 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11396
diff
changeset
|
656 |
print_heap_after_gc(); |
1 | 657 |
|
2010
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1893
diff
changeset
|
658 |
#ifdef TRACESPINNING |
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1893
diff
changeset
|
659 |
ParallelTaskTerminator::print_termination_counts(); |
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1893
diff
changeset
|
660 |
#endif |
1 | 661 |
} |
662 |
||
47624
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
663 |
void GenCollectedHeap::register_nmethod(nmethod* nm) { |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
664 |
CodeCache::register_scavenge_root_nmethod(nm); |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
665 |
} |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
666 |
|
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
667 |
void GenCollectedHeap::verify_nmethod(nmethod* nm) { |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
668 |
CodeCache::verify_scavenge_root_nmethod(nm); |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
669 |
} |
b055cb5170f5
8185141: Generalize scavengeable nmethod root handling
eosterlund
parents:
47622
diff
changeset
|
670 |
|
1 | 671 |
HeapWord* GenCollectedHeap::satisfy_failed_allocation(size_t size, bool is_tlab) { |
49046
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
672 |
GCCauseSetter x(this, GCCause::_allocation_failure); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
673 |
HeapWord* result = NULL; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
674 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
675 |
assert(size != 0, "Precondition violated"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
676 |
if (GCLocker::is_active_and_needs_gc()) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
677 |
// GC locker is active; instead of a collection we will attempt |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
678 |
// to expand the heap, if there's room for expansion. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
679 |
if (!is_maximal_no_gc()) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
680 |
result = expand_heap_and_allocate(size, is_tlab); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
681 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
682 |
return result; // Could be null if we are out of space. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
683 |
} else if (!incremental_collection_will_fail(false /* don't consult_young */)) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
684 |
// Do an incremental collection. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
685 |
do_collection(false, // full |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
686 |
false, // clear_all_soft_refs |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
687 |
size, // size |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
688 |
is_tlab, // is_tlab |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
689 |
GenCollectedHeap::OldGen); // max_generation |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
690 |
} else { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
691 |
log_trace(gc)(" :: Trying full because partial may fail :: "); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
692 |
// Try a full collection; see delta for bug id 6266275 |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
693 |
// for the original code and why this has been simplified |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
694 |
// with from-space allocation criteria modified and |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
695 |
// such allocation moved out of the safepoint path. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
696 |
do_collection(true, // full |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
697 |
false, // clear_all_soft_refs |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
698 |
size, // size |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
699 |
is_tlab, // is_tlab |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
700 |
GenCollectedHeap::OldGen); // max_generation |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
701 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
702 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
703 |
result = attempt_allocation(size, is_tlab, false /*first_only*/); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
704 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
705 |
if (result != NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
706 |
assert(is_in_reserved(result), "result not in heap"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
707 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
708 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
709 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
710 |
// OK, collection failed, try expansion. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
711 |
result = expand_heap_and_allocate(size, is_tlab); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
712 |
if (result != NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
713 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
714 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
715 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
716 |
// If we reach this point, we're really out of memory. Try every trick |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
717 |
// we can to reclaim memory. Force collection of soft references. Force |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
718 |
// a complete compaction of the heap. Any additional methods for finding |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
719 |
// free memory should be here, especially if they are expensive. If this |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
720 |
// attempt fails, an OOM exception will be thrown. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
721 |
{ |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
722 |
UIntFlagSetting flag_change(MarkSweepAlwaysCompactCount, 1); // Make sure the heap is fully compacted |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
723 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
724 |
do_collection(true, // full |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
725 |
true, // clear_all_soft_refs |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
726 |
size, // size |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
727 |
is_tlab, // is_tlab |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
728 |
GenCollectedHeap::OldGen); // max_generation |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
729 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
730 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
731 |
result = attempt_allocation(size, is_tlab, false /* first_only */); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
732 |
if (result != NULL) { |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
733 |
assert(is_in_reserved(result), "result not in heap"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
734 |
return result; |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
735 |
} |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
736 |
|
49047
8f004146e407
8198515: Extract SoftReferencePolicy code out of CollectorPolicy
stefank
parents:
49046
diff
changeset
|
737 |
assert(!soft_ref_policy()->should_clear_all_soft_refs(), |
49046
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
738 |
"Flag should have been handled and cleared prior to this point"); |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
739 |
|
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
740 |
// What else? We might try synchronous finalization later. If the total |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
741 |
// space available is large enough for the allocation, then a more |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
742 |
// complete compaction phase than we've tried so far might be |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
743 |
// appropriate. |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
744 |
return NULL; |
1 | 745 |
} |
746 |
||
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
747 |
#ifdef ASSERT |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
748 |
class AssertNonScavengableClosure: public OopClosure { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
749 |
public: |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
750 |
virtual void do_oop(oop* p) { |
29803 | 751 |
assert(!GenCollectedHeap::heap()->is_in_partial_collection(*p), |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
752 |
"Referent should not be scavengable."); } |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
753 |
virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); } |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
754 |
}; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
755 |
static AssertNonScavengableClosure assert_is_non_scavengable_closure; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
756 |
#endif |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
757 |
|
30868
c1b24f26deed
8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents:
30867
diff
changeset
|
758 |
void GenCollectedHeap::process_roots(StrongRootsScope* scope, |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
759 |
ScanningOption so, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
760 |
OopClosure* strong_roots, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
761 |
OopClosure* weak_roots, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
762 |
CLDClosure* strong_cld_closure, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
763 |
CLDClosure* weak_cld_closure, |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35939
diff
changeset
|
764 |
CodeBlobToOopClosure* code_roots) { |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
765 |
// General roots. |
29802
d485440c958a
8076225: Move the thread claim parity from SharedHeap to Thread
mgerdin
parents:
29800
diff
changeset
|
766 |
assert(Threads::thread_claim_parity() != 0, "must have called prologue code"); |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
767 |
assert(code_roots != NULL, "code root closure should always be set"); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
768 |
// _n_termination for _process_strong_tasks should be set up stream |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
769 |
// in a method not running in a GC worker. Otherwise the GC worker |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
770 |
// could be trying to change the termination condition while the task |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
771 |
// is executing in another GC worker. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
772 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
773 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_ClassLoaderDataGraph_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
774 |
ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
775 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
776 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
777 |
// Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
35939
diff
changeset
|
778 |
CodeBlobToOopClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots; |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
779 |
|
30868
c1b24f26deed
8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents:
30867
diff
changeset
|
780 |
bool is_par = scope->n_threads() > 1; |
38074
8475fdc6dcc3
8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure
coleenp
parents:
38011
diff
changeset
|
781 |
Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_code_p); |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
782 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
783 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_Universe_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
784 |
Universe::oops_do(strong_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
785 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
786 |
// Global (strong) JNI handles |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
787 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_JNIHandles_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
788 |
JNIHandles::oops_do(strong_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
789 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
790 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
791 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_ObjectSynchronizer_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
792 |
ObjectSynchronizer::oops_do(strong_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
793 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
794 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_Management_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
795 |
Management::oops_do(strong_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
796 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
797 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_jvmti_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
798 |
JvmtiExport::oops_do(strong_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
799 |
} |
42650 | 800 |
if (UseAOT && !_process_strong_tasks->is_task_claimed(GCH_PS_aot_oops_do)) { |
801 |
AOTLoader::oops_do(strong_roots); |
|
802 |
} |
|
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
803 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
804 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_SystemDictionary_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
805 |
SystemDictionary::roots_oops_do(strong_roots, weak_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
806 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
807 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
808 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
809 |
if (so & SO_ScavengeCodeCache) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
810 |
assert(code_roots != NULL, "must supply closure for code cache"); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
811 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
812 |
// We only visit parts of the CodeCache when scavenging. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
813 |
CodeCache::scavenge_root_nmethods_do(code_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
814 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
815 |
if (so & SO_AllCodeCache) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
816 |
assert(code_roots != NULL, "must supply closure for code cache"); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
817 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
818 |
// CMSCollector uses this to do intermediate-strength collections. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
819 |
// We scan the entire code cache, since CodeCache::do_unloading is not called. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
820 |
CodeCache::blobs_do(code_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
821 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
822 |
// Verify that the code cache contents are not subject to |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
823 |
// movement by a scavenging collection. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
824 |
DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations)); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
825 |
DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable)); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
826 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
827 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
828 |
|
41683
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
829 |
void GenCollectedHeap::process_string_table_roots(StrongRootsScope* scope, |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
830 |
OopClosure* root_closure) { |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
831 |
assert(root_closure != NULL, "Must be set"); |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
832 |
// All threads execute the following. A specific chunk of buckets |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
833 |
// from the StringTable are the individual tasks. |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
834 |
if (scope->n_threads() > 1) { |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
835 |
StringTable::possibly_parallel_oops_do(root_closure); |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
836 |
} else { |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
837 |
StringTable::oops_do(root_closure); |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
838 |
} |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
839 |
} |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
840 |
|
41682
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
841 |
void GenCollectedHeap::young_process_roots(StrongRootsScope* scope, |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
842 |
OopsInGenClosure* root_closure, |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
843 |
OopsInGenClosure* old_gen_closure, |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
844 |
CLDClosure* cld_closure) { |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
845 |
MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations); |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
846 |
|
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
847 |
process_roots(scope, SO_ScavengeCodeCache, root_closure, root_closure, |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
848 |
cld_closure, cld_closure, &mark_code_closure); |
41683
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
849 |
process_string_table_roots(scope, root_closure); |
41682
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
850 |
|
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
851 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
852 |
root_closure->reset_generation(); |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
853 |
} |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
854 |
|
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
855 |
// When collection is parallel, all threads get to cooperate to do |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
856 |
// old generation scanning. |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
857 |
old_gen_closure->set_generation(_old_gen); |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
858 |
rem_set()->younger_refs_iterate(_old_gen, old_gen_closure, scope->n_threads()); |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
859 |
old_gen_closure->reset_generation(); |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
860 |
|
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
861 |
_process_strong_tasks->all_tasks_completed(scope->n_threads()); |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
862 |
} |
b63330180476
8166276: Refactor gen_process_roots to allow simpler fix for 8165949
jwilhelm
parents:
41286
diff
changeset
|
863 |
|
41683
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
864 |
void GenCollectedHeap::full_process_roots(StrongRootsScope* scope, |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
865 |
bool is_adjust_phase, |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
866 |
ScanningOption so, |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
867 |
bool only_strong_roots, |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
868 |
OopsInGenClosure* root_closure, |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
869 |
CLDClosure* cld_closure) { |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
870 |
MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase); |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
871 |
OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure; |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
872 |
CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure; |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
873 |
|
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
874 |
process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure); |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
875 |
if (is_adjust_phase) { |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
876 |
// We never treat the string table as roots during marking |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
877 |
// for the full gc, so we only need to process it during |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
878 |
// the adjust phase. |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
879 |
process_string_table_roots(scope, root_closure); |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
880 |
} |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
881 |
|
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
882 |
_process_strong_tasks->all_tasks_completed(scope->n_threads()); |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
883 |
} |
cd5d2527e163
8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
sjohanss
parents:
41682
diff
changeset
|
884 |
|
22882
195c8f70d605
8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents:
22552
diff
changeset
|
885 |
void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) { |
47648
226b1fc611b9
8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
47624
diff
changeset
|
886 |
WeakProcessor::oops_do(root_closure); |
29200 | 887 |
_young_gen->ref_processor()->weak_oops_do(root_closure); |
888 |
_old_gen->ref_processor()->weak_oops_do(root_closure); |
|
1 | 889 |
} |
890 |
||
891 |
#define GCH_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
|
892 |
void GenCollectedHeap:: \ |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
893 |
oop_since_save_marks_iterate(GenerationType gen, \ |
1 | 894 |
OopClosureType* cur, \ |
895 |
OopClosureType* older) { \ |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
896 |
if (gen == YoungGen) { \ |
29200 | 897 |
_young_gen->oop_since_save_marks_iterate##nv_suffix(cur); \ |
898 |
_old_gen->oop_since_save_marks_iterate##nv_suffix(older); \ |
|
899 |
} else { \ |
|
900 |
_old_gen->oop_since_save_marks_iterate##nv_suffix(cur); \ |
|
1 | 901 |
} \ |
902 |
} |
|
903 |
||
904 |
ALL_SINCE_SAVE_MARKS_CLOSURES(GCH_SINCE_SAVE_MARKS_ITERATE_DEFN) |
|
905 |
||
906 |
#undef GCH_SINCE_SAVE_MARKS_ITERATE_DEFN |
|
907 |
||
31780 | 908 |
bool GenCollectedHeap::no_allocs_since_save_marks() { |
909 |
return _young_gen->no_allocs_since_save_marks() && |
|
910 |
_old_gen->no_allocs_since_save_marks(); |
|
1 | 911 |
} |
912 |
||
913 |
bool GenCollectedHeap::supports_inline_contig_alloc() const { |
|
29200 | 914 |
return _young_gen->supports_inline_contig_alloc(); |
1 | 915 |
} |
916 |
||
41283
2615c024f3eb
8033552: Fix missing missing volatile specifiers in CAS operations in GC code
eosterlund
parents:
40523
diff
changeset
|
917 |
HeapWord* volatile* GenCollectedHeap::top_addr() const { |
29200 | 918 |
return _young_gen->top_addr(); |
1 | 919 |
} |
920 |
||
921 |
HeapWord** GenCollectedHeap::end_addr() const { |
|
29200 | 922 |
return _young_gen->end_addr(); |
1 | 923 |
} |
924 |
||
925 |
// public collection interfaces |
|
926 |
||
927 |
void GenCollectedHeap::collect(GCCause::Cause cause) { |
|
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47546
diff
changeset
|
928 |
if (cause == GCCause::_wb_young_gc) { |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
929 |
// Young collection for the WhiteBox API. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
930 |
collect(cause, YoungGen); |
1 | 931 |
} else { |
932 |
#ifdef ASSERT |
|
26183
bbe259d3c8bc
8055098: WB API should be extended to provide information about size and age of object.
tschatzl
parents:
25730
diff
changeset
|
933 |
if (cause == GCCause::_scavenge_alot) { |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
934 |
// Young collection only. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
935 |
collect(cause, YoungGen); |
26183
bbe259d3c8bc
8055098: WB API should be extended to provide information about size and age of object.
tschatzl
parents:
25730
diff
changeset
|
936 |
} else { |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
937 |
// Stop-the-world full collection. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
938 |
collect(cause, OldGen); |
26183
bbe259d3c8bc
8055098: WB API should be extended to provide information about size and age of object.
tschatzl
parents:
25730
diff
changeset
|
939 |
} |
1 | 940 |
#else |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
941 |
// Stop-the-world full collection. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
942 |
collect(cause, OldGen); |
1 | 943 |
#endif |
944 |
} |
|
945 |
} |
|
946 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
947 |
void GenCollectedHeap::collect(GCCause::Cause cause, GenerationType max_generation) { |
1 | 948 |
// The caller doesn't have the Heap_lock |
949 |
assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock"); |
|
950 |
MutexLocker ml(Heap_lock); |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
951 |
collect_locked(cause, max_generation); |
1 | 952 |
} |
953 |
||
954 |
void GenCollectedHeap::collect_locked(GCCause::Cause cause) { |
|
955 |
// The caller has the Heap_lock |
|
956 |
assert(Heap_lock->owned_by_self(), "this thread should own the Heap_lock"); |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
957 |
collect_locked(cause, OldGen); |
1 | 958 |
} |
959 |
||
960 |
// this is the private collection interface |
|
961 |
// The Heap_lock is expected to be held on entry. |
|
962 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
963 |
void GenCollectedHeap::collect_locked(GCCause::Cause cause, GenerationType max_generation) { |
1 | 964 |
// Read the GC count while holding the Heap_lock |
965 |
unsigned int gc_count_before = total_collections(); |
|
966 |
unsigned int full_gc_count_before = total_full_collections(); |
|
967 |
{ |
|
968 |
MutexUnlocker mu(Heap_lock); // give up heap lock, execute gets it back |
|
969 |
VM_GenCollectFull op(gc_count_before, full_gc_count_before, |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
970 |
cause, max_generation); |
1 | 971 |
VMThread::execute(&op); |
972 |
} |
|
973 |
} |
|
974 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
975 |
void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs) { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
976 |
do_full_collection(clear_all_soft_refs, OldGen); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
977 |
} |
1 | 978 |
|
979 |
void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs, |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
980 |
GenerationType last_generation) { |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
981 |
GenerationType local_last_generation; |
7419
263dd4e89b9d
7001033: assert(gch->gc_cause() == GCCause::_scavenge_alot || !gch->incremental_collection_failed())
ysr
parents:
7397
diff
changeset
|
982 |
if (!incremental_collection_will_fail(false /* don't consult_young */) && |
1 | 983 |
gc_cause() == GCCause::_gc_locker) { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
984 |
local_last_generation = YoungGen; |
1 | 985 |
} else { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
986 |
local_last_generation = last_generation; |
1 | 987 |
} |
988 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
989 |
do_collection(true, // full |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
990 |
clear_all_soft_refs, // clear_all_soft_refs |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
991 |
0, // size |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
992 |
false, // is_tlab |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
993 |
local_last_generation); // last_generation |
1 | 994 |
// Hack XXX FIX ME !!! |
995 |
// A scavenge may not have been attempted, or may have |
|
996 |
// been attempted and failed, because the old gen was too full |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
997 |
if (local_last_generation == YoungGen && gc_cause() == GCCause::_gc_locker && |
7419
263dd4e89b9d
7001033: assert(gch->gc_cause() == GCCause::_scavenge_alot || !gch->incremental_collection_failed())
ysr
parents:
7397
diff
changeset
|
998 |
incremental_collection_will_fail(false /* don't consult_young */)) { |
35061 | 999 |
log_debug(gc, jni)("GC locker: Trying a full collection because scavenge failed"); |
1 | 1000 |
// This time allow the old gen to be collected as well |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1001 |
do_collection(true, // full |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1002 |
clear_all_soft_refs, // clear_all_soft_refs |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1003 |
0, // size |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1004 |
false, // is_tlab |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1005 |
OldGen); // last_generation |
1 | 1006 |
} |
1007 |
} |
|
1008 |
||
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1009 |
bool GenCollectedHeap::is_in_young(oop p) { |
29200 | 1010 |
bool result = ((HeapWord*)p) < _old_gen->reserved().start(); |
1011 |
assert(result == _young_gen->is_in_reserved(p), |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32735
diff
changeset
|
1012 |
"incorrect test - result=%d, p=" INTPTR_FORMAT, result, p2i((void*)p)); |
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1013 |
return result; |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1014 |
} |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1015 |
|
11247 | 1016 |
// Returns "TRUE" iff "p" points into the committed areas of the heap. |
1 | 1017 |
bool GenCollectedHeap::is_in(const void* p) const { |
29200 | 1018 |
return _young_gen->is_in(p) || _old_gen->is_in(p); |
1 | 1019 |
} |
1020 |
||
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1021 |
#ifdef ASSERT |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1022 |
// Don't implement this by using is_in_young(). This method is used |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1023 |
// in some cases to check that is_in_young() is correct. |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1024 |
bool GenCollectedHeap::is_in_partial_collection(const void* p) { |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1025 |
assert(is_in_reserved(p) || p == NULL, |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1026 |
"Does not work if address is non-null and outside of the heap"); |
29200 | 1027 |
return p < _young_gen->reserved().end() && p != NULL; |
1 | 1028 |
} |
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
1029 |
#endif |
1 | 1030 |
|
30152 | 1031 |
void GenCollectedHeap::oop_iterate_no_header(OopClosure* cl) { |
1032 |
NoHeaderExtendedOopClosure no_header_cl(cl); |
|
1033 |
oop_iterate(&no_header_cl); |
|
1034 |
} |
|
1035 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
1036 |
void GenCollectedHeap::oop_iterate(ExtendedOopClosure* cl) { |
29200 | 1037 |
_young_gen->oop_iterate(cl); |
1038 |
_old_gen->oop_iterate(cl); |
|
1 | 1039 |
} |
1040 |
||
1041 |
void GenCollectedHeap::object_iterate(ObjectClosure* cl) { |
|
29200 | 1042 |
_young_gen->object_iterate(cl); |
1043 |
_old_gen->object_iterate(cl); |
|
1 | 1044 |
} |
1045 |
||
1893
c82e388e17c5
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
1610
diff
changeset
|
1046 |
void GenCollectedHeap::safe_object_iterate(ObjectClosure* cl) { |
29200 | 1047 |
_young_gen->safe_object_iterate(cl); |
1048 |
_old_gen->safe_object_iterate(cl); |
|
1893
c82e388e17c5
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
1610
diff
changeset
|
1049 |
} |
c82e388e17c5
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
1610
diff
changeset
|
1050 |
|
1 | 1051 |
Space* GenCollectedHeap::space_containing(const void* addr) const { |
29200 | 1052 |
Space* res = _young_gen->space_containing(addr); |
1053 |
if (res != NULL) { |
|
1054 |
return res; |
|
1 | 1055 |
} |
29200 | 1056 |
res = _old_gen->space_containing(addr); |
1057 |
assert(res != NULL, "Could not find containing space"); |
|
1058 |
return res; |
|
1 | 1059 |
} |
1060 |
||
1061 |
HeapWord* GenCollectedHeap::block_start(const void* addr) const { |
|
1062 |
assert(is_in_reserved(addr), "block_start of address outside of heap"); |
|
29200 | 1063 |
if (_young_gen->is_in_reserved(addr)) { |
1064 |
assert(_young_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
1065 |
return _young_gen->block_start(addr); |
|
1 | 1066 |
} |
29200 | 1067 |
|
1068 |
assert(_old_gen->is_in_reserved(addr), "Some generation should contain the address"); |
|
1069 |
assert(_old_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
1070 |
return _old_gen->block_start(addr); |
|
1 | 1071 |
} |
1072 |
||
1073 |
size_t GenCollectedHeap::block_size(const HeapWord* addr) const { |
|
1074 |
assert(is_in_reserved(addr), "block_size of address outside of heap"); |
|
29200 | 1075 |
if (_young_gen->is_in_reserved(addr)) { |
1076 |
assert(_young_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
1077 |
return _young_gen->block_size(addr); |
|
1 | 1078 |
} |
29200 | 1079 |
|
1080 |
assert(_old_gen->is_in_reserved(addr), "Some generation should contain the address"); |
|
1081 |
assert(_old_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
1082 |
return _old_gen->block_size(addr); |
|
1 | 1083 |
} |
1084 |
||
1085 |
bool GenCollectedHeap::block_is_obj(const HeapWord* addr) const { |
|
1086 |
assert(is_in_reserved(addr), "block_is_obj of address outside of heap"); |
|
1087 |
assert(block_start(addr) == addr, "addr must be a block start"); |
|
29200 | 1088 |
if (_young_gen->is_in_reserved(addr)) { |
1089 |
return _young_gen->block_is_obj(addr); |
|
1 | 1090 |
} |
29200 | 1091 |
|
1092 |
assert(_old_gen->is_in_reserved(addr), "Some generation should contain the address"); |
|
1093 |
return _old_gen->block_is_obj(addr); |
|
1 | 1094 |
} |
1095 |
||
1096 |
bool GenCollectedHeap::supports_tlab_allocation() const { |
|
29200 | 1097 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
1098 |
return _young_gen->supports_tlab_allocation(); |
|
1 | 1099 |
} |
1100 |
||
1101 |
size_t GenCollectedHeap::tlab_capacity(Thread* thr) const { |
|
29200 | 1102 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
1103 |
if (_young_gen->supports_tlab_allocation()) { |
|
1104 |
return _young_gen->tlab_capacity(); |
|
1 | 1105 |
} |
29200 | 1106 |
return 0; |
1 | 1107 |
} |
1108 |
||
22552 | 1109 |
size_t GenCollectedHeap::tlab_used(Thread* thr) const { |
29200 | 1110 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
1111 |
if (_young_gen->supports_tlab_allocation()) { |
|
1112 |
return _young_gen->tlab_used(); |
|
22552 | 1113 |
} |
29200 | 1114 |
return 0; |
22552 | 1115 |
} |
1116 |
||
1 | 1117 |
size_t GenCollectedHeap::unsafe_max_tlab_alloc(Thread* thr) const { |
29200 | 1118 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
1119 |
if (_young_gen->supports_tlab_allocation()) { |
|
1120 |
return _young_gen->unsafe_max_tlab_alloc(); |
|
1 | 1121 |
} |
29200 | 1122 |
return 0; |
1 | 1123 |
} |
1124 |
||
1125 |
HeapWord* GenCollectedHeap::allocate_new_tlab(size_t size) { |
|
1126 |
bool gc_overhead_limit_was_exceeded; |
|
49046
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
1127 |
return mem_allocate_work(size /* size */, |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
1128 |
true /* is_tlab */, |
c8e4dc1b9e39
8198511: Move allocation functions from GenCollectorPolicy to GenCollectedHeap
stefank
parents:
49044
diff
changeset
|
1129 |
&gc_overhead_limit_was_exceeded); |
1 | 1130 |
} |
1131 |
||
1132 |
// Requires "*prev_ptr" to be non-NULL. Deletes and a block of minimal size |
|
1133 |
// from the list headed by "*prev_ptr". |
|
1134 |
static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) { |
|
1135 |
bool first = true; |
|
1136 |
size_t min_size = 0; // "first" makes this conceptually infinite. |
|
1137 |
ScratchBlock **smallest_ptr, *smallest; |
|
1138 |
ScratchBlock *cur = *prev_ptr; |
|
1139 |
while (cur) { |
|
1140 |
assert(*prev_ptr == cur, "just checking"); |
|
1141 |
if (first || cur->num_words < min_size) { |
|
1142 |
smallest_ptr = prev_ptr; |
|
1143 |
smallest = cur; |
|
1144 |
min_size = smallest->num_words; |
|
1145 |
first = false; |
|
1146 |
} |
|
1147 |
prev_ptr = &cur->next; |
|
1148 |
cur = cur->next; |
|
1149 |
} |
|
1150 |
smallest = *smallest_ptr; |
|
1151 |
*smallest_ptr = smallest->next; |
|
1152 |
return smallest; |
|
1153 |
} |
|
1154 |
||
1155 |
// Sort the scratch block list headed by res into decreasing size order, |
|
1156 |
// and set "res" to the result. |
|
1157 |
static void sort_scratch_list(ScratchBlock*& list) { |
|
1158 |
ScratchBlock* sorted = NULL; |
|
1159 |
ScratchBlock* unsorted = list; |
|
1160 |
while (unsorted) { |
|
1161 |
ScratchBlock *smallest = removeSmallestScratch(&unsorted); |
|
1162 |
smallest->next = sorted; |
|
1163 |
sorted = smallest; |
|
1164 |
} |
|
1165 |
list = sorted; |
|
1166 |
} |
|
1167 |
||
1168 |
ScratchBlock* GenCollectedHeap::gather_scratch(Generation* requestor, |
|
1169 |
size_t max_alloc_words) { |
|
1170 |
ScratchBlock* res = NULL; |
|
29200 | 1171 |
_young_gen->contribute_scratch(res, requestor, max_alloc_words); |
1172 |
_old_gen->contribute_scratch(res, requestor, max_alloc_words); |
|
1 | 1173 |
sort_scratch_list(res); |
1174 |
return res; |
|
1175 |
} |
|
1176 |
||
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1177 |
void GenCollectedHeap::release_scratch() { |
29200 | 1178 |
_young_gen->reset_scratch(); |
1179 |
_old_gen->reset_scratch(); |
|
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1180 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1181 |
|
1 | 1182 |
class GenPrepareForVerifyClosure: public GenCollectedHeap::GenClosure { |
1183 |
void do_generation(Generation* gen) { |
|
1184 |
gen->prepare_for_verify(); |
|
1185 |
} |
|
1186 |
}; |
|
1187 |
||
1188 |
void GenCollectedHeap::prepare_for_verify() { |
|
1189 |
ensure_parsability(false); // no need to retire TLABs |
|
1190 |
GenPrepareForVerifyClosure blk; |
|
1191 |
generation_iterate(&blk, false); |
|
1192 |
} |
|
1193 |
||
1194 |
void GenCollectedHeap::generation_iterate(GenClosure* cl, |
|
1195 |
bool old_to_young) { |
|
1196 |
if (old_to_young) { |
|
29200 | 1197 |
cl->do_generation(_old_gen); |
1198 |
cl->do_generation(_young_gen); |
|
1 | 1199 |
} else { |
29200 | 1200 |
cl->do_generation(_young_gen); |
1201 |
cl->do_generation(_old_gen); |
|
1 | 1202 |
} |
1203 |
} |
|
1204 |
||
1205 |
bool GenCollectedHeap::is_maximal_no_gc() const { |
|
29200 | 1206 |
return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc(); |
1 | 1207 |
} |
1208 |
||
1209 |
void GenCollectedHeap::save_marks() { |
|
29200 | 1210 |
_young_gen->save_marks(); |
1211 |
_old_gen->save_marks(); |
|
1 | 1212 |
} |
1213 |
||
1214 |
GenCollectedHeap* GenCollectedHeap::heap() { |
|
30258
413e15d1b146
8077415: Remove duplicate variables holding the CollectedHeap
pliden
parents:
30177
diff
changeset
|
1215 |
CollectedHeap* heap = Universe::heap(); |
413e15d1b146
8077415: Remove duplicate variables holding the CollectedHeap
pliden
parents:
30177
diff
changeset
|
1216 |
assert(heap != NULL, "Uninitialized access to GenCollectedHeap::heap()"); |
47819
ee36a8e36561
8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47799
diff
changeset
|
1217 |
assert(heap->kind() == CollectedHeap::SerialHeap || |
47622
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47546
diff
changeset
|
1218 |
heap->kind() == CollectedHeap::CMSHeap, "Not a GenCollectedHeap"); |
817f2a7019e4
8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents:
47546
diff
changeset
|
1219 |
return (GenCollectedHeap*) heap; |
1 | 1220 |
} |
1221 |
||
1222 |
void GenCollectedHeap::prepare_for_compaction() { |
|
1223 |
// Start by compacting into same gen. |
|
29200 | 1224 |
CompactPoint cp(_old_gen); |
1225 |
_old_gen->prepare_for_compaction(&cp); |
|
1226 |
_young_gen->prepare_for_compaction(&cp); |
|
1 | 1227 |
} |
1228 |
||
35061 | 1229 |
void GenCollectedHeap::verify(VerifyOption option /* ignored */) { |
1230 |
log_debug(gc, verify)("%s", _old_gen->name()); |
|
29200 | 1231 |
_old_gen->verify(); |
1232 |
||
35061 | 1233 |
log_debug(gc, verify)("%s", _old_gen->name()); |
29200 | 1234 |
_young_gen->verify(); |
1235 |
||
35061 | 1236 |
log_debug(gc, verify)("RemSet"); |
1 | 1237 |
rem_set()->verify(); |
1238 |
} |
|
1239 |
||
1240 |
void GenCollectedHeap::print_on(outputStream* st) const { |
|
29200 | 1241 |
_young_gen->print_on(st); |
1242 |
_old_gen->print_on(st); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
1243 |
MetaspaceAux::print_on(st); |
1 | 1244 |
} |
1245 |
||
1246 |
void GenCollectedHeap::gc_threads_do(ThreadClosure* tc) const { |
|
1247 |
} |
|
1248 |
||
1249 |
void GenCollectedHeap::print_gc_threads_on(outputStream* st) const { |
|
16685
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1250 |
} |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1251 |
|
1 | 1252 |
void GenCollectedHeap::print_tracing_info() const { |
47546
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
1253 |
if (log_is_enabled(Debug, gc, heap, exit)) { |
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
1254 |
LogStreamHandle(Debug, gc, heap, exit) lsh; |
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
1255 |
_young_gen->print_summary_info_on(&lsh); |
64ba55ba8516
8184286: print_tracing_info() does not use Unified Logging for output
sjohanss
parents:
47216
diff
changeset
|
1256 |
_old_gen->print_summary_info_on(&lsh); |
1 | 1257 |
} |
1258 |
} |
|
1259 |
||
35061 | 1260 |
void GenCollectedHeap::print_heap_change(size_t young_prev_used, size_t old_prev_used) const { |
1261 |
log_info(gc, heap)("%s: " SIZE_FORMAT "K->" SIZE_FORMAT "K(" SIZE_FORMAT "K)", |
|
1262 |
_young_gen->short_name(), young_prev_used / K, _young_gen->used() /K, _young_gen->capacity() /K); |
|
1263 |
log_info(gc, heap)("%s: " SIZE_FORMAT "K->" SIZE_FORMAT "K(" SIZE_FORMAT "K)", |
|
1264 |
_old_gen->short_name(), old_prev_used / K, _old_gen->used() /K, _old_gen->capacity() /K); |
|
1 | 1265 |
} |
1266 |
||
1267 |
class GenGCPrologueClosure: public GenCollectedHeap::GenClosure { |
|
1268 |
private: |
|
1269 |
bool _full; |
|
1270 |
public: |
|
1271 |
void do_generation(Generation* gen) { |
|
1272 |
gen->gc_prologue(_full); |
|
1273 |
} |
|
1274 |
GenGCPrologueClosure(bool full) : _full(full) {}; |
|
1275 |
}; |
|
1276 |
||
1277 |
void GenCollectedHeap::gc_prologue(bool full) { |
|
1278 |
assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer"); |
|
1279 |
||
1280 |
// Fill TLAB's and such |
|
1281 |
CollectedHeap::accumulate_statistics_all_tlabs(); |
|
1282 |
ensure_parsability(true); // retire TLABs |
|
1283 |
||
1284 |
// Walk generations |
|
1285 |
GenGCPrologueClosure blk(full); |
|
1286 |
generation_iterate(&blk, false); // not old-to-young. |
|
1287 |
}; |
|
1288 |
||
1289 |
class GenGCEpilogueClosure: public GenCollectedHeap::GenClosure { |
|
1290 |
private: |
|
1291 |
bool _full; |
|
1292 |
public: |
|
1293 |
void do_generation(Generation* gen) { |
|
1294 |
gen->gc_epilogue(_full); |
|
1295 |
} |
|
1296 |
GenGCEpilogueClosure(bool full) : _full(full) {}; |
|
1297 |
}; |
|
1298 |
||
1299 |
void GenCollectedHeap::gc_epilogue(bool full) { |
|
47799 | 1300 |
#if COMPILER2_OR_JVMCI |
1 | 1301 |
assert(DerivedPointerTable::is_empty(), "derived pointer present"); |
1302 |
size_t actual_gap = pointer_delta((HeapWord*) (max_uintx-3), *(end_addr())); |
|
43455
96560cffef4d
8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents:
42650
diff
changeset
|
1303 |
guarantee(is_client_compilation_mode_vm() || actual_gap > (size_t)FastAllocateSizeLimit, "inline allocation wraps"); |
47799 | 1304 |
#endif // COMPILER2_OR_JVMCI |
1 | 1305 |
|
1306 |
resize_all_tlabs(); |
|
1307 |
||
1308 |
GenGCEpilogueClosure blk(full); |
|
1309 |
generation_iterate(&blk, false); // not old-to-young. |
|
1310 |
||
10022
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1311 |
if (!CleanChunkPoolAsync) { |
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1312 |
Chunk::clean_chunk_pool(); |
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1313 |
} |
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1314 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
1315 |
MetaspaceCounters::update_performance_counters(); |
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19286
diff
changeset
|
1316 |
CompressedClassSpaceCounters::update_performance_counters(); |
1 | 1317 |
}; |
1318 |
||
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1319 |
#ifndef PRODUCT |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1320 |
class GenGCSaveTopsBeforeGCClosure: public GenCollectedHeap::GenClosure { |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1321 |
private: |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1322 |
public: |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1323 |
void do_generation(Generation* gen) { |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1324 |
gen->record_spaces_top(); |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1325 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1326 |
}; |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1327 |
|
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1328 |
void GenCollectedHeap::record_gen_tops_before_GC() { |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1329 |
if (ZapUnusedHeapArea) { |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1330 |
GenGCSaveTopsBeforeGCClosure blk; |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1331 |
generation_iterate(&blk, false); // not old-to-young. |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1332 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1333 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1334 |
#endif // not PRODUCT |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1335 |
|
1 | 1336 |
class GenEnsureParsabilityClosure: public GenCollectedHeap::GenClosure { |
1337 |
public: |
|
1338 |
void do_generation(Generation* gen) { |
|
1339 |
gen->ensure_parsability(); |
|
1340 |
} |
|
1341 |
}; |
|
1342 |
||
1343 |
void GenCollectedHeap::ensure_parsability(bool retire_tlabs) { |
|
1344 |
CollectedHeap::ensure_parsability(retire_tlabs); |
|
1345 |
GenEnsureParsabilityClosure ep_cl; |
|
1346 |
generation_iterate(&ep_cl, false); |
|
1347 |
} |
|
1348 |
||
19286
48394008c803
8022800: Use specific generations rather than generation iteration
brutisso
parents:
18687
diff
changeset
|
1349 |
oop GenCollectedHeap::handle_failed_promotion(Generation* old_gen, |
1 | 1350 |
oop obj, |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
1351 |
size_t obj_size) { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1352 |
guarantee(old_gen == _old_gen, "We only get here with an old generation"); |
1 | 1353 |
assert(obj_size == (size_t)obj->size(), "bad obj_size passed in"); |
1354 |
HeapWord* result = NULL; |
|
1355 |
||
19286
48394008c803
8022800: Use specific generations rather than generation iteration
brutisso
parents:
18687
diff
changeset
|
1356 |
result = old_gen->expand_and_allocate(obj_size, false); |
1 | 1357 |
|
1358 |
if (result != NULL) { |
|
1359 |
Copy::aligned_disjoint_words((HeapWord*)obj, result, obj_size); |
|
1360 |
} |
|
1361 |
return oop(result); |
|
1362 |
} |
|
1363 |
||
1364 |
class GenTimeOfLastGCClosure: public GenCollectedHeap::GenClosure { |
|
1365 |
jlong _time; // in ms |
|
1366 |
jlong _now; // in ms |
|
1367 |
||
1368 |
public: |
|
1369 |
GenTimeOfLastGCClosure(jlong now) : _time(now), _now(now) { } |
|
1370 |
||
1371 |
jlong time() { return _time; } |
|
1372 |
||
1373 |
void do_generation(Generation* gen) { |
|
1374 |
_time = MIN2(_time, gen->time_of_last_gc(_now)); |
|
1375 |
} |
|
1376 |
}; |
|
1377 |
||
1378 |
jlong GenCollectedHeap::millis_since_last_gc() { |
|
41284
b4276ec89d0d
8164482: [REDO] G1 does not implement millis_since_last_gc which is needed by RMI GC
jprovino
parents:
40523
diff
changeset
|
1379 |
// javaTimeNanos() is guaranteed to be monotonically non-decreasing |
b4276ec89d0d
8164482: [REDO] G1 does not implement millis_since_last_gc which is needed by RMI GC
jprovino
parents:
40523
diff
changeset
|
1380 |
// provided the underlying platform provides such a time source |
b4276ec89d0d
8164482: [REDO] G1 does not implement millis_since_last_gc which is needed by RMI GC
jprovino
parents:
40523
diff
changeset
|
1381 |
// (and it is bug free). So we still have to guard against getting |
b4276ec89d0d
8164482: [REDO] G1 does not implement millis_since_last_gc which is needed by RMI GC
jprovino
parents:
40523
diff
changeset
|
1382 |
// back a time later than 'now'. |
11251
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1383 |
jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; |
1 | 1384 |
GenTimeOfLastGCClosure tolgc_cl(now); |
1385 |
// iterate over generations getting the oldest |
|
1386 |
// time that a generation was collected |
|
1387 |
generation_iterate(&tolgc_cl, false); |
|
11251
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1388 |
|
1 | 1389 |
jlong retVal = now - tolgc_cl.time(); |
1390 |
if (retVal < 0) { |
|
41284
b4276ec89d0d
8164482: [REDO] G1 does not implement millis_since_last_gc which is needed by RMI GC
jprovino
parents:
40523
diff
changeset
|
1391 |
log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT |
b4276ec89d0d
8164482: [REDO] G1 does not implement millis_since_last_gc which is needed by RMI GC
jprovino
parents:
40523
diff
changeset
|
1392 |
". returning zero instead.", retVal); |
1 | 1393 |
return 0; |
1394 |
} |
|
1395 |
return retVal; |
|
1396 |
} |