author | david |
Wed, 14 Oct 2015 09:33:45 +0200 | |
changeset 33212 | 906b3d079b13 |
parent 33146 | 77349b58b4c0 |
child 33229 | 51173444fdd5 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
28939 | 2 |
* Copyright (c) 2000, 2015, 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" |
26 |
#include "classfile/symbolTable.hpp" |
|
27 |
#include "classfile/systemDictionary.hpp" |
|
28 |
#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
|
29 |
#include "code/codeCache.hpp" |
7397 | 30 |
#include "code/icBuffer.hpp" |
30764 | 31 |
#include "gc/shared/collectedHeap.inline.hpp" |
32 |
#include "gc/shared/collectorCounters.hpp" |
|
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
33 |
#include "gc/shared/gcId.hpp" |
30764 | 34 |
#include "gc/shared/gcLocker.inline.hpp" |
35 |
#include "gc/shared/gcTrace.hpp" |
|
36 |
#include "gc/shared/gcTraceTime.hpp" |
|
37 |
#include "gc/shared/genCollectedHeap.hpp" |
|
38 |
#include "gc/shared/genOopClosures.inline.hpp" |
|
39 |
#include "gc/shared/generationSpec.hpp" |
|
40 |
#include "gc/shared/space.hpp" |
|
41 |
#include "gc/shared/strongRootsScope.hpp" |
|
42 |
#include "gc/shared/vmGCOperations.hpp" |
|
43 |
#include "gc/shared/workgroup.hpp" |
|
7397 | 44 |
#include "memory/filemap.hpp" |
45 |
#include "memory/resourceArea.hpp" |
|
46 |
#include "oops/oop.inline.hpp" |
|
47 |
#include "runtime/biasedLocking.hpp" |
|
48 |
#include "runtime/fprofiler.hpp" |
|
49 |
#include "runtime/handles.hpp" |
|
50 |
#include "runtime/handles.inline.hpp" |
|
51 |
#include "runtime/java.hpp" |
|
52 |
#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
|
53 |
#include "services/management.hpp" |
7397 | 54 |
#include "services/memoryService.hpp" |
30175 | 55 |
#include "utilities/macros.hpp" |
56 |
#include "utilities/stack.inline.hpp" |
|
7397 | 57 |
#include "utilities/vmError.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
58 |
#if INCLUDE_ALL_GCS |
30764 | 59 |
#include "gc/cms/concurrentMarkSweepThread.hpp" |
60 |
#include "gc/cms/vmCMSOperations.hpp" |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
61 |
#endif // INCLUDE_ALL_GCS |
1 | 62 |
|
63 |
NOT_PRODUCT(size_t GenCollectedHeap::_skip_header_HeapWords = 0;) |
|
64 |
||
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
65 |
// The set of potentially parallel tasks in root scanning. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
66 |
enum GCH_strong_roots_tasks { |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
GCH_PS_FlatProfiler_oops_do, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
GCH_PS_CodeCache_oops_do, |
1 | 76 |
GCH_PS_younger_gens, |
77 |
// Leave this one last. |
|
78 |
GCH_PS_NumElements |
|
79 |
}; |
|
80 |
||
81 |
GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy) : |
|
30154 | 82 |
CollectedHeap(), |
28217
57791914628c
8067499: G1SATBCardTableModRefBS should not inherit from CardTableModRefBSForCTRS
kbarrett
parents:
28212
diff
changeset
|
83 |
_rem_set(NULL), |
1 | 84 |
_gen_policy(policy), |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
85 |
_process_strong_tasks(new SubTasksDone(GCH_PS_NumElements)), |
1 | 86 |
_full_collections_completed(0) |
87 |
{ |
|
88 |
assert(policy != NULL, "Sanity check"); |
|
30152 | 89 |
if (UseConcMarkSweepGC) { |
32360 | 90 |
_workers = new WorkGang("GC Thread", ParallelGCThreads, |
30152 | 91 |
/* are_GC_task_threads */true, |
92 |
/* are_ConcurrentGC_threads */false); |
|
93 |
_workers->initialize_workers(); |
|
94 |
} else { |
|
95 |
// Serial GC does not use workers. |
|
96 |
_workers = NULL; |
|
97 |
} |
|
1 | 98 |
} |
99 |
||
100 |
jint GenCollectedHeap::initialize() { |
|
4637 | 101 |
CollectedHeap::pre_initialize(); |
102 |
||
1 | 103 |
// While there are no constraints in the GC code that HeapWordSize |
104 |
// be any particular value, there are multiple other areas in the |
|
105 |
// system which believe this to be true (e.g. oop->object_size in some |
|
106 |
// cases incorrectly returns the size in wordSize units rather than |
|
107 |
// HeapWordSize). |
|
108 |
guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize"); |
|
109 |
||
110 |
// Allocate space for the heap. |
|
111 |
||
112 |
char* heap_address; |
|
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
113 |
ReservedSpace heap_rs; |
1 | 114 |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21560
diff
changeset
|
115 |
size_t heap_alignment = collector_policy()->heap_alignment(); |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
116 |
|
28939 | 117 |
heap_address = allocate(heap_alignment, &heap_rs); |
1 | 118 |
|
119 |
if (!heap_rs.is_reserved()) { |
|
120 |
vm_shutdown_during_initialization( |
|
121 |
"Could not reserve enough space for object heap"); |
|
122 |
return JNI_ENOMEM; |
|
123 |
} |
|
124 |
||
26829
26315213bab8
8055091: CollectedHeap::_reserved usage should be cleaned up
mlarsson
parents:
26183
diff
changeset
|
125 |
initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); |
1 | 126 |
|
27687
3a6367d7110b
8064721: The card tables only ever need two covering regions
ehelin
parents:
27252
diff
changeset
|
127 |
_rem_set = collector_policy()->create_rem_set(reserved_region()); |
1 | 128 |
set_barrier_set(rem_set()->bs()); |
4637 | 129 |
|
29794 | 130 |
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
|
131 |
_young_gen = gen_policy()->young_gen_spec()->init(young_rs, rem_set()); |
29794 | 132 |
heap_rs = heap_rs.last_part(gen_policy()->young_gen_spec()->max_size()); |
29200 | 133 |
|
29794 | 134 |
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
|
135 |
_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
|
136 |
clear_incremental_collection_failed(); |
1 | 137 |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
138 |
#if INCLUDE_ALL_GCS |
1 | 139 |
// If we are running CMS, create the collector responsible |
140 |
// for collecting the CMS generations. |
|
141 |
if (collector_policy()->is_concurrent_mark_sweep_policy()) { |
|
142 |
bool success = create_cms_collector(); |
|
143 |
if (!success) return JNI_ENOMEM; |
|
144 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
145 |
#endif // INCLUDE_ALL_GCS |
1 | 146 |
|
147 |
return JNI_OK; |
|
148 |
} |
|
149 |
||
150 |
char* GenCollectedHeap::allocate(size_t alignment, |
|
151 |
ReservedSpace* heap_rs){ |
|
152 |
// Now figure out the total size. |
|
29794 | 153 |
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
|
154 |
assert(alignment % pageSize == 0, "Must be"); |
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
155 |
|
29794 | 156 |
GenerationSpec* young_spec = gen_policy()->young_gen_spec(); |
157 |
GenerationSpec* old_spec = gen_policy()->old_gen_spec(); |
|
158 |
||
159 |
// Check for overflow. |
|
160 |
size_t total_reserved = young_spec->max_size() + old_spec->max_size(); |
|
161 |
if (total_reserved < young_spec->max_size()) { |
|
162 |
vm_exit_during_initialization("The size of the object heap + VM data exceeds " |
|
163 |
"the maximum representable size"); |
|
1 | 164 |
} |
19546
f6b7c9e96ea3
8007074: SIGSEGV at ParMarkBitMap::verify_clear()
stefank
parents:
19322
diff
changeset
|
165 |
assert(total_reserved % alignment == 0, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32735
diff
changeset
|
166 |
"Gen size; total_reserved=" SIZE_FORMAT ", alignment=" |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32735
diff
changeset
|
167 |
SIZE_FORMAT, total_reserved, alignment); |
1 | 168 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
169 |
*heap_rs = Universe::reserve_heap(total_reserved, alignment); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
170 |
return heap_rs->base(); |
1 | 171 |
} |
172 |
||
173 |
void GenCollectedHeap::post_initialize() { |
|
30152 | 174 |
CollectedHeap::post_initialize(); |
175 |
ref_processing_init(); |
|
29684
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
176 |
assert((_young_gen->kind() == Generation::DefNew) || |
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
177 |
(_young_gen->kind() == Generation::ParNew), |
27903
14c6e2f23fa0
8065992: Change CMSCollector::_young_gen to be a ParNewGeneration*
brutisso
parents:
27898
diff
changeset
|
178 |
"Wrong youngest generation type"); |
29684
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
179 |
DefNewGeneration* def_new_gen = (DefNewGeneration*)_young_gen; |
1 | 180 |
|
29684
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
181 |
assert(_old_gen->kind() == Generation::ConcurrentMarkSweep || |
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
182 |
_old_gen->kind() == Generation::MarkSweepCompact, |
1 | 183 |
"Wrong generation kind"); |
184 |
||
32735
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
185 |
_gen_policy->initialize_size_policy(def_new_gen->eden()->capacity(), |
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
186 |
_old_gen->capacity(), |
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
187 |
def_new_gen->from()->capacity()); |
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
188 |
_gen_policy->initialize_gc_policy_counters(); |
1 | 189 |
} |
190 |
||
191 |
void GenCollectedHeap::ref_processing_init() { |
|
29200 | 192 |
_young_gen->ref_processor_init(); |
193 |
_old_gen->ref_processor_init(); |
|
1 | 194 |
} |
195 |
||
196 |
size_t GenCollectedHeap::capacity() const { |
|
29200 | 197 |
return _young_gen->capacity() + _old_gen->capacity(); |
1 | 198 |
} |
199 |
||
200 |
size_t GenCollectedHeap::used() const { |
|
29200 | 201 |
return _young_gen->used() + _old_gen->used(); |
1 | 202 |
} |
203 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
204 |
void GenCollectedHeap::save_used_regions() { |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
205 |
_old_gen->save_used_region(); |
29200 | 206 |
_young_gen->save_used_region(); |
1 | 207 |
} |
208 |
||
209 |
size_t GenCollectedHeap::max_capacity() const { |
|
29200 | 210 |
return _young_gen->max_capacity() + _old_gen->max_capacity(); |
1 | 211 |
} |
212 |
||
213 |
// Update the _full_collections_completed counter |
|
214 |
// at the end of a stop-world full GC. |
|
215 |
unsigned int GenCollectedHeap::update_full_collections_completed() { |
|
216 |
MonitorLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag); |
|
217 |
assert(_full_collections_completed <= _total_full_collections, |
|
218 |
"Can't complete more collections than were started"); |
|
219 |
_full_collections_completed = _total_full_collections; |
|
220 |
ml.notify_all(); |
|
221 |
return _full_collections_completed; |
|
222 |
} |
|
223 |
||
224 |
// Update the _full_collections_completed counter, as appropriate, |
|
225 |
// at the end of a concurrent GC cycle. Note the conditional update |
|
226 |
// below to allow this method to be called by a concurrent collector |
|
227 |
// without synchronizing in any manner with the VM thread (which |
|
228 |
// may already have initiated a STW full collection "concurrently"). |
|
229 |
unsigned int GenCollectedHeap::update_full_collections_completed(unsigned int count) { |
|
230 |
MonitorLockerEx ml(FullGCCount_lock, Mutex::_no_safepoint_check_flag); |
|
231 |
assert((_full_collections_completed <= _total_full_collections) && |
|
232 |
(count <= _total_full_collections), |
|
233 |
"Can't complete more collections than were started"); |
|
234 |
if (count > _full_collections_completed) { |
|
235 |
_full_collections_completed = count; |
|
236 |
ml.notify_all(); |
|
237 |
} |
|
238 |
return _full_collections_completed; |
|
239 |
} |
|
240 |
||
241 |
||
242 |
#ifndef PRODUCT |
|
243 |
// Override of memory state checking method in CollectedHeap: |
|
244 |
// Some collectors (CMS for example) can't have badHeapWordVal written |
|
245 |
// in the first two words of an object. (For instance , in the case of |
|
246 |
// CMS these words hold state used to synchronize between certain |
|
247 |
// (concurrent) GC steps and direct allocating mutators.) |
|
248 |
// The skip_header_HeapWords() method below, allows us to skip |
|
249 |
// over the requisite number of HeapWord's. Note that (for |
|
250 |
// generational collectors) this means that those many words are |
|
251 |
// skipped in each object, irrespective of the generation in which |
|
252 |
// that object lives. The resultant loss of precision seems to be |
|
253 |
// harmless and the pain of avoiding that imprecision appears somewhat |
|
254 |
// higher than we are prepared to pay for such rudimentary debugging |
|
255 |
// support. |
|
256 |
void GenCollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, |
|
257 |
size_t size) { |
|
258 |
if (CheckMemoryInitialization && ZapUnusedHeapArea) { |
|
259 |
// We are asked to check a size in HeapWords, |
|
260 |
// but the memory is mangled in juint words. |
|
261 |
juint* start = (juint*) (addr + skip_header_HeapWords()); |
|
262 |
juint* end = (juint*) (addr + size); |
|
263 |
for (juint* slot = start; slot < end; slot += 1) { |
|
264 |
assert(*slot == badHeapWordVal, |
|
265 |
"Found non badHeapWordValue in pre-allocation check"); |
|
266 |
} |
|
267 |
} |
|
268 |
} |
|
269 |
#endif |
|
270 |
||
271 |
HeapWord* GenCollectedHeap::attempt_allocation(size_t size, |
|
272 |
bool is_tlab, |
|
273 |
bool first_only) { |
|
29200 | 274 |
HeapWord* res = NULL; |
275 |
||
276 |
if (_young_gen->should_allocate(size, is_tlab)) { |
|
277 |
res = _young_gen->allocate(size, is_tlab); |
|
278 |
if (res != NULL || first_only) { |
|
279 |
return res; |
|
1 | 280 |
} |
281 |
} |
|
29200 | 282 |
|
283 |
if (_old_gen->should_allocate(size, is_tlab)) { |
|
284 |
res = _old_gen->allocate(size, is_tlab); |
|
285 |
} |
|
286 |
||
287 |
return res; |
|
1 | 288 |
} |
289 |
||
290 |
HeapWord* GenCollectedHeap::mem_allocate(size_t size, |
|
291 |
bool* gc_overhead_limit_was_exceeded) { |
|
292 |
return collector_policy()->mem_allocate_work(size, |
|
9997
b75b7939f448
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
9995
diff
changeset
|
293 |
false /* is_tlab */, |
1 | 294 |
gc_overhead_limit_was_exceeded); |
295 |
} |
|
296 |
||
297 |
bool GenCollectedHeap::must_clear_all_soft_refs() { |
|
298 |
return _gc_cause == GCCause::_last_ditch_collection; |
|
299 |
} |
|
300 |
||
301 |
bool GenCollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { |
|
31032
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
302 |
if (!UseConcMarkSweepGC) { |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
303 |
return false; |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
304 |
} |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
305 |
|
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
306 |
switch (cause) { |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
307 |
case GCCause::_gc_locker: return GCLockerInvokesConcurrent; |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
308 |
case GCCause::_java_lang_system_gc: |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
309 |
case GCCause::_dcmd_gc_run: return ExplicitGCInvokesConcurrent; |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
310 |
default: return false; |
8e72621ca186
8072913: [REDO] GCCause should distinguish jcmd GC.run from System.gc()
ysuenaga
parents:
30871
diff
changeset
|
311 |
} |
1 | 312 |
} |
313 |
||
29200 | 314 |
void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t size, |
315 |
bool is_tlab, bool run_verification, bool clear_soft_refs, |
|
316 |
bool restore_marks_for_biased_locking) { |
|
317 |
// Timer for individual generations. Last argument is false: no CR |
|
318 |
// FIXME: We should try to start the timing earlier to cover more of the GC pause |
|
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
319 |
GCTraceTime t1(gen->short_name(), PrintGCDetails, false, NULL); |
29200 | 320 |
TraceCollectorStats tcs(gen->counters()); |
321 |
TraceMemoryManagerStats tmms(gen->kind(),gc_cause()); |
|
322 |
||
323 |
size_t prev_used = gen->used(); |
|
324 |
gen->stat_record()->invocations++; |
|
325 |
gen->stat_record()->accumulated_time.start(); |
|
326 |
||
327 |
// Must be done anew before each collection because |
|
328 |
// a previous collection will do mangling and will |
|
329 |
// change top of some spaces. |
|
330 |
record_gen_tops_before_GC(); |
|
331 |
||
332 |
if (PrintGC && Verbose) { |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
333 |
// I didn't want to change the logging when removing the level concept, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
334 |
// but I guess this logging could say young/old or something instead of 0/1. |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
335 |
uint level; |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
336 |
if (heap()->is_young_gen(gen)) { |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
337 |
level = 0; |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
338 |
} else { |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
339 |
level = 1; |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
340 |
} |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
341 |
gclog_or_tty->print("level=%u invoke=%d size=" SIZE_FORMAT, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
342 |
level, |
29200 | 343 |
gen->stat_record()->invocations, |
344 |
size * HeapWordSize); |
|
345 |
} |
|
346 |
||
347 |
if (run_verification && VerifyBeforeGC) { |
|
348 |
HandleMark hm; // Discard invalid handles created during verification |
|
349 |
Universe::verify(" VerifyBeforeGC:"); |
|
350 |
} |
|
351 |
COMPILER2_PRESENT(DerivedPointerTable::clear()); |
|
352 |
||
353 |
if (restore_marks_for_biased_locking) { |
|
354 |
// We perform this mark word preservation work lazily |
|
355 |
// because it's only at this point that we know whether we |
|
356 |
// absolutely have to do it; we want to avoid doing it for |
|
357 |
// scavenge-only collections where it's unnecessary |
|
358 |
BiasedLocking::preserve_marks(); |
|
359 |
} |
|
360 |
||
361 |
// Do collection work |
|
362 |
{ |
|
363 |
// Note on ref discovery: For what appear to be historical reasons, |
|
364 |
// GCH enables and disabled (by enqueing) refs discovery. |
|
365 |
// In the future this should be moved into the generation's |
|
366 |
// collect method so that ref discovery and enqueueing concerns |
|
367 |
// are local to a generation. The collect method could return |
|
368 |
// an appropriate indication in the case that notification on |
|
369 |
// the ref lock was needed. This will make the treatment of |
|
370 |
// weak refs more uniform (and indeed remove such concerns |
|
371 |
// from GCH). XXX |
|
372 |
||
373 |
HandleMark hm; // Discard invalid handles created during gc |
|
374 |
save_marks(); // save marks for all gens |
|
375 |
// We want to discover references, but not process them yet. |
|
376 |
// This mode is disabled in process_discovered_references if the |
|
377 |
// generation does some collection work, or in |
|
378 |
// enqueue_discovered_references if the generation returns |
|
379 |
// without doing any work. |
|
380 |
ReferenceProcessor* rp = gen->ref_processor(); |
|
381 |
// If the discovery of ("weak") refs in this generation is |
|
382 |
// atomic wrt other collectors in this configuration, we |
|
383 |
// are guaranteed to have empty discovered ref lists. |
|
384 |
if (rp->discovery_is_atomic()) { |
|
385 |
rp->enable_discovery(); |
|
386 |
rp->setup_policy(clear_soft_refs); |
|
387 |
} else { |
|
388 |
// collect() below will enable discovery as appropriate |
|
389 |
} |
|
390 |
gen->collect(full, clear_soft_refs, size, is_tlab); |
|
391 |
if (!rp->enqueuing_is_done()) { |
|
392 |
rp->enqueue_discovered_references(); |
|
393 |
} else { |
|
394 |
rp->set_enqueuing_is_done(false); |
|
395 |
} |
|
396 |
rp->verify_no_references_recorded(); |
|
397 |
} |
|
398 |
||
399 |
COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); |
|
400 |
||
401 |
gen->stat_record()->accumulated_time.stop(); |
|
402 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
403 |
update_gc_stats(gen, full); |
29200 | 404 |
|
405 |
if (run_verification && VerifyAfterGC) { |
|
406 |
HandleMark hm; // Discard invalid handles created during verification |
|
407 |
Universe::verify(" VerifyAfterGC:"); |
|
408 |
} |
|
409 |
||
410 |
if (PrintGCDetails) { |
|
411 |
gclog_or_tty->print(":"); |
|
412 |
gen->print_heap_change(prev_used); |
|
413 |
} |
|
414 |
} |
|
415 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
416 |
void GenCollectedHeap::do_collection(bool full, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
417 |
bool clear_all_soft_refs, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
418 |
size_t size, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
419 |
bool is_tlab, |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
420 |
GenerationType max_generation) { |
1 | 421 |
ResourceMark rm; |
422 |
DEBUG_ONLY(Thread* my_thread = Thread::current();) |
|
423 |
||
424 |
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); |
|
425 |
assert(my_thread->is_VM_thread() || |
|
426 |
my_thread->is_ConcurrentGC_thread(), |
|
427 |
"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
|
428 |
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
|
429 |
"the requesting thread should have the Heap_lock"); |
1 | 430 |
guarantee(!is_gc_active(), "collection is not reentrant"); |
431 |
||
432 |
if (GC_locker::check_active_before_gc()) { |
|
433 |
return; // GC is disabled (e.g. JNI GetXXXCritical operation) |
|
434 |
} |
|
435 |
||
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
436 |
GCIdMark gc_id_mark; |
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
437 |
|
5343
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
438 |
const bool do_clear_all_soft_refs = clear_all_soft_refs || |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
439 |
collector_policy()->should_clear_all_soft_refs(); |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
440 |
|
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
441 |
ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy()); |
95a5c4b89273
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
jmasa
parents:
4641
diff
changeset
|
442 |
|
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23508
diff
changeset
|
443 |
const size_t metadata_prev_used = MetaspaceAux::used_bytes(); |
1 | 444 |
|
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11396
diff
changeset
|
445 |
print_heap_before_gc(); |
1 | 446 |
|
447 |
{ |
|
448 |
FlagSetting fl(_is_gc_active, true); |
|
449 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
450 |
bool complete = full && (max_generation == OldGen); |
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
12379
diff
changeset
|
451 |
const char* gc_cause_prefix = complete ? "Full GC" : "GC"; |
1 | 452 |
TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); |
33107
77bf0d2069a3
8134953: Make the GC ID available in a central place
brutisso
parents:
33105
diff
changeset
|
453 |
GCTraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, NULL); |
1 | 454 |
|
455 |
gc_prologue(complete); |
|
456 |
increment_total_collections(complete); |
|
457 |
||
458 |
size_t gch_prev_used = used(); |
|
29200 | 459 |
bool run_verification = total_collections() >= VerifyGCStartAt; |
1 | 460 |
|
29200 | 461 |
bool prepared_for_verification = false; |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
462 |
bool collected_old = false; |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
463 |
bool old_collects_young = complete && |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
464 |
_old_gen->full_collects_young_generation(); |
29200 | 465 |
if (!old_collects_young && |
466 |
_young_gen->should_collect(full, size, is_tlab)) { |
|
467 |
if (run_verification && VerifyGCLevel <= 0 && VerifyBeforeGC) { |
|
468 |
prepare_for_verify(); |
|
469 |
prepared_for_verification = true; |
|
470 |
} |
|
471 |
||
472 |
assert(!_young_gen->performs_in_place_marking(), "No young generation do in place marking"); |
|
473 |
collect_generation(_young_gen, |
|
474 |
full, |
|
475 |
size, |
|
476 |
is_tlab, |
|
477 |
run_verification && VerifyGCLevel <= 0, |
|
478 |
do_clear_all_soft_refs, |
|
479 |
false); |
|
480 |
||
481 |
if (size > 0 && (!is_tlab || _young_gen->supports_tlab_allocation()) && |
|
482 |
size * HeapWordSize <= _young_gen->unsafe_max_alloc_nogc()) { |
|
483 |
// Allocation request was met by young GC. |
|
484 |
size = 0; |
|
27252 | 485 |
} |
1 | 486 |
} |
487 |
||
27252 | 488 |
bool must_restore_marks_for_biased_locking = false; |
489 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
490 |
if (max_generation == OldGen && _old_gen->should_collect(full, size, is_tlab)) { |
33146
77349b58b4c0
8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents:
33107
diff
changeset
|
491 |
GCIdMarkAndRestore gc_id_mark; |
29200 | 492 |
if (!complete) { |
493 |
// The full_collections increment was missed above. |
|
494 |
increment_total_full_collections(); |
|
495 |
} |
|
27252 | 496 |
|
29200 | 497 |
pre_full_gc_dump(NULL); // do any pre full gc dumps |
27252 | 498 |
|
29200 | 499 |
if (!prepared_for_verification && run_verification && |
500 |
VerifyGCLevel <= 1 && VerifyBeforeGC) { |
|
501 |
prepare_for_verify(); |
|
502 |
} |
|
27252 | 503 |
|
29200 | 504 |
assert(_old_gen->performs_in_place_marking(), "All old generations do in place marking"); |
505 |
collect_generation(_old_gen, |
|
506 |
full, |
|
507 |
size, |
|
508 |
is_tlab, |
|
509 |
run_verification && VerifyGCLevel <= 1, |
|
510 |
do_clear_all_soft_refs, |
|
511 |
true); |
|
27252 | 512 |
|
29200 | 513 |
must_restore_marks_for_biased_locking = true; |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
514 |
collected_old = true; |
1 | 515 |
} |
516 |
||
517 |
// Update "complete" boolean wrt what actually transpired -- |
|
518 |
// for instance, a promotion failure could have led to |
|
519 |
// a whole heap collection. |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
520 |
complete = complete || collected_old; |
1 | 521 |
|
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
522 |
if (complete) { // We did a full collection |
18025 | 523 |
// FIXME: See comment at pre_full_gc_dump call |
524 |
post_full_gc_dump(NULL); // do any post full gc dumps |
|
2141
e9a644aaff87
6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
ysr
parents:
2010
diff
changeset
|
525 |
} |
e9a644aaff87
6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
ysr
parents:
2010
diff
changeset
|
526 |
|
1 | 527 |
if (PrintGCDetails) { |
528 |
print_heap_change(gch_prev_used); |
|
529 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
530 |
// Print metaspace info for full GC with PrintGCDetails flag. |
1 | 531 |
if (complete) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
532 |
MetaspaceAux::print_metaspace_change(metadata_prev_used); |
1 | 533 |
} |
534 |
} |
|
535 |
||
29200 | 536 |
// Adjust generation sizes. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
537 |
if (collected_old) { |
29200 | 538 |
_old_gen->compute_new_size(); |
1 | 539 |
} |
29200 | 540 |
_young_gen->compute_new_size(); |
1 | 541 |
|
542 |
if (complete) { |
|
16385
4a05c6d94b04
8005602: NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
mgerdin
parents:
15482
diff
changeset
|
543 |
// 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
|
544 |
ClassLoaderDataGraph::purge(); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17105
diff
changeset
|
545 |
MetaspaceAux::verify_metrics(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
546 |
// Resize the metaspace capacity after full collections |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
547 |
MetaspaceGC::compute_new_size(); |
1 | 548 |
update_full_collections_completed(); |
549 |
} |
|
550 |
||
551 |
// Track memory usage and detect low memory after GC finishes |
|
552 |
MemoryService::track_memory_usage(); |
|
553 |
||
554 |
gc_epilogue(complete); |
|
555 |
||
556 |
if (must_restore_marks_for_biased_locking) { |
|
557 |
BiasedLocking::restore_marks(); |
|
558 |
} |
|
559 |
} |
|
560 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11396
diff
changeset
|
561 |
print_heap_after_gc(); |
1 | 562 |
|
2010
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1893
diff
changeset
|
563 |
#ifdef TRACESPINNING |
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1893
diff
changeset
|
564 |
ParallelTaskTerminator::print_termination_counts(); |
c13462bbad17
6690928: Use spinning in combination with yields for workstealing termination.
jmasa
parents:
1893
diff
changeset
|
565 |
#endif |
1 | 566 |
} |
567 |
||
568 |
HeapWord* GenCollectedHeap::satisfy_failed_allocation(size_t size, bool is_tlab) { |
|
569 |
return collector_policy()->satisfy_failed_allocation(size, is_tlab); |
|
570 |
} |
|
571 |
||
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
572 |
#ifdef ASSERT |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
573 |
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
|
574 |
public: |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
575 |
virtual void do_oop(oop* p) { |
29803 | 576 |
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
|
577 |
"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
|
578 |
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
|
579 |
}; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
580 |
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
|
581 |
#endif |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
582 |
|
30868
c1b24f26deed
8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents:
30867
diff
changeset
|
583 |
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
|
584 |
ScanningOption so, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
585 |
OopClosure* strong_roots, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
586 |
OopClosure* weak_roots, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
587 |
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
|
588 |
CLDClosure* weak_cld_closure, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
589 |
CodeBlobClosure* code_roots) { |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
590 |
// General roots. |
29802
d485440c958a
8076225: Move the thread claim parity from SharedHeap to Thread
mgerdin
parents:
29800
diff
changeset
|
591 |
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
|
592 |
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
|
593 |
// _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
|
594 |
// 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
|
595 |
// 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
|
596 |
// 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
|
597 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
598 |
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
|
599 |
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
|
600 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
601 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
602 |
// Some CLDs contained in the thread frames should be considered strong. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
603 |
// Don't process them if they will be processed during the ClassLoaderDataGraph phase. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
604 |
CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
605 |
// Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
606 |
CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
607 |
|
30868
c1b24f26deed
8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents:
30867
diff
changeset
|
608 |
bool is_par = scope->n_threads() > 1; |
30147
af9a41999c6e
8076314: Remove the static instance variable SharedHeap:: _sh
brutisso
parents:
29804
diff
changeset
|
609 |
Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_clds_p, 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
|
610 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
611 |
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
|
612 |
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
|
613 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
614 |
// 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
|
615 |
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
|
616 |
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
|
617 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
618 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
619 |
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
|
620 |
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
|
621 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
622 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_FlatProfiler_oops_do)) { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
623 |
FlatProfiler::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
|
624 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
625 |
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
|
626 |
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
|
627 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
628 |
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
|
629 |
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
|
630 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
631 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
632 |
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
|
633 |
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
|
634 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
635 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
636 |
// All threads execute the following. A specific chunk of buckets |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
637 |
// from the StringTable are the individual tasks. |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
638 |
if (weak_roots != NULL) { |
30581
a91d6c47f076
8079275: Remove CollectedHeap::use_parallel_gc_threads
stefank
parents:
30258
diff
changeset
|
639 |
if (is_par) { |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
640 |
StringTable::possibly_parallel_oops_do(weak_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
641 |
} else { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
642 |
StringTable::oops_do(weak_roots); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
643 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
644 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
645 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
646 |
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
|
647 |
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
|
648 |
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
|
649 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
650 |
// 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
|
651 |
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
|
652 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
653 |
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
|
654 |
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
|
655 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
656 |
// 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
|
657 |
// 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
|
658 |
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
|
659 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
660 |
// 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
|
661 |
// 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
|
662 |
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
|
663 |
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
|
664 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
665 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
666 |
|
30868
c1b24f26deed
8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents:
30867
diff
changeset
|
667 |
void GenCollectedHeap::gen_process_roots(StrongRootsScope* scope, |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
668 |
GenerationType type, |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
669 |
bool young_gen_as_roots, |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
670 |
ScanningOption so, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
671 |
bool only_strong_roots, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
672 |
OopsInGenClosure* not_older_gens, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
673 |
OopsInGenClosure* older_gens, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
674 |
CLDClosure* cld_closure) { |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
675 |
const bool is_adjust_phase = !only_strong_roots && !young_gen_as_roots; |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
676 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
677 |
bool is_moving_collection = false; |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
678 |
if (type == YoungGen || is_adjust_phase) { |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
679 |
// young collections are always moving |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
680 |
is_moving_collection = true; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
681 |
} |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
682 |
|
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
683 |
MarkingCodeBlobClosure mark_code_closure(not_older_gens, is_moving_collection); |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
684 |
OopsInGenClosure* weak_roots = only_strong_roots ? NULL : not_older_gens; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
685 |
CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
686 |
|
30868
c1b24f26deed
8080110: Remove usage of CollectedHeap::n_par_threads() from root processing
stefank
parents:
30867
diff
changeset
|
687 |
process_roots(scope, so, |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
688 |
not_older_gens, weak_roots, |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
689 |
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
|
690 |
&mark_code_closure); |
1 | 691 |
|
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
692 |
if (young_gen_as_roots) { |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
693 |
if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
694 |
if (type == OldGen) { |
29200 | 695 |
not_older_gens->set_generation(_young_gen); |
696 |
_young_gen->oop_iterate(not_older_gens); |
|
1 | 697 |
} |
698 |
not_older_gens->reset_generation(); |
|
699 |
} |
|
700 |
} |
|
701 |
// When collection is parallel, all threads get to cooperate to do |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
702 |
// old generation scanning. |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
703 |
if (type == YoungGen) { |
29200 | 704 |
older_gens->set_generation(_old_gen); |
30870
3050fdcdc60b
8080112: Replace and remove the last usages of CollectedHeap::n_par_threads()
stefank
parents:
30869
diff
changeset
|
705 |
rem_set()->younger_refs_iterate(_old_gen, older_gens, scope->n_threads()); |
1 | 706 |
older_gens->reset_generation(); |
707 |
} |
|
708 |
||
30869 | 709 |
_process_strong_tasks->all_tasks_completed(scope->n_threads()); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
710 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
711 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
712 |
|
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
713 |
class AlwaysTrueClosure: public BoolObjectClosure { |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
714 |
public: |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
715 |
bool do_object_b(oop p) { return true; } |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
716 |
}; |
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
717 |
static AlwaysTrueClosure always_true; |
1 | 718 |
|
22882
195c8f70d605
8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents:
22552
diff
changeset
|
719 |
void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) { |
29693
fac175f7a466
8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap
mgerdin
parents:
29684
diff
changeset
|
720 |
JNIHandles::weak_oops_do(&always_true, root_closure); |
29200 | 721 |
_young_gen->ref_processor()->weak_oops_do(root_closure); |
722 |
_old_gen->ref_processor()->weak_oops_do(root_closure); |
|
1 | 723 |
} |
724 |
||
725 |
#define GCH_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
|
726 |
void GenCollectedHeap:: \ |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
727 |
oop_since_save_marks_iterate(GenerationType gen, \ |
1 | 728 |
OopClosureType* cur, \ |
729 |
OopClosureType* older) { \ |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
730 |
if (gen == YoungGen) { \ |
29200 | 731 |
_young_gen->oop_since_save_marks_iterate##nv_suffix(cur); \ |
732 |
_old_gen->oop_since_save_marks_iterate##nv_suffix(older); \ |
|
733 |
} else { \ |
|
734 |
_old_gen->oop_since_save_marks_iterate##nv_suffix(cur); \ |
|
1 | 735 |
} \ |
736 |
} |
|
737 |
||
738 |
ALL_SINCE_SAVE_MARKS_CLOSURES(GCH_SINCE_SAVE_MARKS_ITERATE_DEFN) |
|
739 |
||
740 |
#undef GCH_SINCE_SAVE_MARKS_ITERATE_DEFN |
|
741 |
||
31780 | 742 |
bool GenCollectedHeap::no_allocs_since_save_marks() { |
743 |
return _young_gen->no_allocs_since_save_marks() && |
|
744 |
_old_gen->no_allocs_since_save_marks(); |
|
1 | 745 |
} |
746 |
||
747 |
bool GenCollectedHeap::supports_inline_contig_alloc() const { |
|
29200 | 748 |
return _young_gen->supports_inline_contig_alloc(); |
1 | 749 |
} |
750 |
||
751 |
HeapWord** GenCollectedHeap::top_addr() const { |
|
29200 | 752 |
return _young_gen->top_addr(); |
1 | 753 |
} |
754 |
||
755 |
HeapWord** GenCollectedHeap::end_addr() const { |
|
29200 | 756 |
return _young_gen->end_addr(); |
1 | 757 |
} |
758 |
||
759 |
// public collection interfaces |
|
760 |
||
761 |
void GenCollectedHeap::collect(GCCause::Cause cause) { |
|
762 |
if (should_do_concurrent_full_gc(cause)) { |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
763 |
#if INCLUDE_ALL_GCS |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
764 |
// Mostly concurrent full collection. |
1 | 765 |
collect_mostly_concurrent(cause); |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
766 |
#else // INCLUDE_ALL_GCS |
1 | 767 |
ShouldNotReachHere(); |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
768 |
#endif // INCLUDE_ALL_GCS |
26183
bbe259d3c8bc
8055098: WB API should be extended to provide information about size and age of object.
tschatzl
parents:
25730
diff
changeset
|
769 |
} else if (cause == GCCause::_wb_young_gc) { |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
770 |
// Young collection for the WhiteBox API. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
771 |
collect(cause, YoungGen); |
1 | 772 |
} else { |
773 |
#ifdef ASSERT |
|
26183
bbe259d3c8bc
8055098: WB API should be extended to provide information about size and age of object.
tschatzl
parents:
25730
diff
changeset
|
774 |
if (cause == GCCause::_scavenge_alot) { |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
775 |
// Young collection only. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
776 |
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
|
777 |
} else { |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
778 |
// Stop-the-world full collection. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
779 |
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
|
780 |
} |
1 | 781 |
#else |
32623
390a27af5657
8134626: Misc cleanups after generation array removal
jwilhelm
parents:
32360
diff
changeset
|
782 |
// Stop-the-world full collection. |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
783 |
collect(cause, OldGen); |
1 | 784 |
#endif |
785 |
} |
|
786 |
} |
|
787 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
788 |
void GenCollectedHeap::collect(GCCause::Cause cause, GenerationType max_generation) { |
1 | 789 |
// The caller doesn't have the Heap_lock |
790 |
assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock"); |
|
791 |
MutexLocker ml(Heap_lock); |
|
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
792 |
collect_locked(cause, max_generation); |
1 | 793 |
} |
794 |
||
795 |
void GenCollectedHeap::collect_locked(GCCause::Cause cause) { |
|
796 |
// The caller has the Heap_lock |
|
797 |
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
|
798 |
collect_locked(cause, OldGen); |
1 | 799 |
} |
800 |
||
801 |
// this is the private collection interface |
|
802 |
// The Heap_lock is expected to be held on entry. |
|
803 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
804 |
void GenCollectedHeap::collect_locked(GCCause::Cause cause, GenerationType max_generation) { |
1 | 805 |
// Read the GC count while holding the Heap_lock |
806 |
unsigned int gc_count_before = total_collections(); |
|
807 |
unsigned int full_gc_count_before = total_full_collections(); |
|
808 |
{ |
|
809 |
MutexUnlocker mu(Heap_lock); // give up heap lock, execute gets it back |
|
810 |
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
|
811 |
cause, max_generation); |
1 | 812 |
VMThread::execute(&op); |
813 |
} |
|
814 |
} |
|
815 |
||
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
816 |
#if INCLUDE_ALL_GCS |
1 | 817 |
bool GenCollectedHeap::create_cms_collector() { |
818 |
||
29200 | 819 |
assert(_old_gen->kind() == Generation::ConcurrentMarkSweep, |
1 | 820 |
"Unexpected generation kinds"); |
821 |
// Skip two header words in the block content verification |
|
822 |
NOT_PRODUCT(_skip_header_HeapWords = CMSCollector::skip_header_HeapWords();) |
|
32735
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
823 |
assert(_gen_policy->is_concurrent_mark_sweep_policy(), "Unexpected policy type"); |
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
824 |
CMSCollector* collector = |
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
825 |
new CMSCollector((ConcurrentMarkSweepGeneration*)_old_gen, |
33212 | 826 |
_rem_set, |
32735
c6063d028c3c
8134797: Remove explicit casts in CollectorPolicy hierarchy
kbarrett
parents:
32623
diff
changeset
|
827 |
_gen_policy->as_concurrent_mark_sweep_policy()); |
1 | 828 |
|
829 |
if (collector == NULL || !collector->completed_initialization()) { |
|
830 |
if (collector) { |
|
831 |
delete collector; // Be nice in embedded situation |
|
832 |
} |
|
833 |
vm_shutdown_during_initialization("Could not create CMS collector"); |
|
834 |
return false; |
|
835 |
} |
|
836 |
return true; // success |
|
837 |
} |
|
838 |
||
839 |
void GenCollectedHeap::collect_mostly_concurrent(GCCause::Cause cause) { |
|
840 |
assert(!Heap_lock->owned_by_self(), "Should not own Heap_lock"); |
|
841 |
||
842 |
MutexLocker ml(Heap_lock); |
|
843 |
// Read the GC counts while holding the Heap_lock |
|
844 |
unsigned int full_gc_count_before = total_full_collections(); |
|
845 |
unsigned int gc_count_before = total_collections(); |
|
846 |
{ |
|
847 |
MutexUnlocker mu(Heap_lock); |
|
848 |
VM_GenCollectFullConcurrent op(gc_count_before, full_gc_count_before, cause); |
|
849 |
VMThread::execute(&op); |
|
850 |
} |
|
851 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
852 |
#endif // INCLUDE_ALL_GCS |
1 | 853 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
854 |
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
|
855 |
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
|
856 |
} |
1 | 857 |
|
858 |
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
|
859 |
GenerationType last_generation) { |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
860 |
GenerationType local_last_generation; |
7419
263dd4e89b9d
7001033: assert(gch->gc_cause() == GCCause::_scavenge_alot || !gch->incremental_collection_failed())
ysr
parents:
7397
diff
changeset
|
861 |
if (!incremental_collection_will_fail(false /* don't consult_young */) && |
1 | 862 |
gc_cause() == GCCause::_gc_locker) { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
863 |
local_last_generation = YoungGen; |
1 | 864 |
} else { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
865 |
local_last_generation = last_generation; |
1 | 866 |
} |
867 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
868 |
do_collection(true, // full |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
869 |
clear_all_soft_refs, // clear_all_soft_refs |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
870 |
0, // size |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
871 |
false, // is_tlab |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
872 |
local_last_generation); // last_generation |
1 | 873 |
// Hack XXX FIX ME !!! |
874 |
// A scavenge may not have been attempted, or may have |
|
875 |
// 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
|
876 |
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
|
877 |
incremental_collection_will_fail(false /* don't consult_young */)) { |
1 | 878 |
if (PrintGCDetails) { |
879 |
gclog_or_tty->print_cr("GC locker: Trying a full collection " |
|
880 |
"because scavenge failed"); |
|
881 |
} |
|
882 |
// 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
|
883 |
do_collection(true, // full |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
884 |
clear_all_soft_refs, // clear_all_soft_refs |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
885 |
0, // size |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
886 |
false, // is_tlab |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
887 |
OldGen); // last_generation |
1 | 888 |
} |
889 |
} |
|
890 |
||
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
891 |
bool GenCollectedHeap::is_in_young(oop p) { |
29200 | 892 |
bool result = ((HeapWord*)p) < _old_gen->reserved().start(); |
893 |
assert(result == _young_gen->is_in_reserved(p), |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32735
diff
changeset
|
894 |
"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
|
895 |
return result; |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
896 |
} |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
897 |
|
11247 | 898 |
// Returns "TRUE" iff "p" points into the committed areas of the heap. |
1 | 899 |
bool GenCollectedHeap::is_in(const void* p) const { |
29200 | 900 |
return _young_gen->is_in(p) || _old_gen->is_in(p); |
1 | 901 |
} |
902 |
||
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
903 |
#ifdef ASSERT |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
904 |
// 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
|
905 |
// 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
|
906 |
bool GenCollectedHeap::is_in_partial_collection(const void* p) { |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
907 |
assert(is_in_reserved(p) || p == NULL, |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
908 |
"Does not work if address is non-null and outside of the heap"); |
29200 | 909 |
return p < _young_gen->reserved().end() && p != NULL; |
1 | 910 |
} |
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9623
diff
changeset
|
911 |
#endif |
1 | 912 |
|
30152 | 913 |
void GenCollectedHeap::oop_iterate_no_header(OopClosure* cl) { |
914 |
NoHeaderExtendedOopClosure no_header_cl(cl); |
|
915 |
oop_iterate(&no_header_cl); |
|
916 |
} |
|
917 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
918 |
void GenCollectedHeap::oop_iterate(ExtendedOopClosure* cl) { |
29200 | 919 |
_young_gen->oop_iterate(cl); |
920 |
_old_gen->oop_iterate(cl); |
|
1 | 921 |
} |
922 |
||
923 |
void GenCollectedHeap::object_iterate(ObjectClosure* cl) { |
|
29200 | 924 |
_young_gen->object_iterate(cl); |
925 |
_old_gen->object_iterate(cl); |
|
1 | 926 |
} |
927 |
||
1893
c82e388e17c5
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
1610
diff
changeset
|
928 |
void GenCollectedHeap::safe_object_iterate(ObjectClosure* cl) { |
29200 | 929 |
_young_gen->safe_object_iterate(cl); |
930 |
_old_gen->safe_object_iterate(cl); |
|
1893
c82e388e17c5
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
1610
diff
changeset
|
931 |
} |
c82e388e17c5
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
1610
diff
changeset
|
932 |
|
1 | 933 |
Space* GenCollectedHeap::space_containing(const void* addr) const { |
29200 | 934 |
Space* res = _young_gen->space_containing(addr); |
935 |
if (res != NULL) { |
|
936 |
return res; |
|
1 | 937 |
} |
29200 | 938 |
res = _old_gen->space_containing(addr); |
939 |
assert(res != NULL, "Could not find containing space"); |
|
940 |
return res; |
|
1 | 941 |
} |
942 |
||
943 |
HeapWord* GenCollectedHeap::block_start(const void* addr) const { |
|
944 |
assert(is_in_reserved(addr), "block_start of address outside of heap"); |
|
29200 | 945 |
if (_young_gen->is_in_reserved(addr)) { |
946 |
assert(_young_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
947 |
return _young_gen->block_start(addr); |
|
1 | 948 |
} |
29200 | 949 |
|
950 |
assert(_old_gen->is_in_reserved(addr), "Some generation should contain the address"); |
|
951 |
assert(_old_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
952 |
return _old_gen->block_start(addr); |
|
1 | 953 |
} |
954 |
||
955 |
size_t GenCollectedHeap::block_size(const HeapWord* addr) const { |
|
956 |
assert(is_in_reserved(addr), "block_size of address outside of heap"); |
|
29200 | 957 |
if (_young_gen->is_in_reserved(addr)) { |
958 |
assert(_young_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
959 |
return _young_gen->block_size(addr); |
|
1 | 960 |
} |
29200 | 961 |
|
962 |
assert(_old_gen->is_in_reserved(addr), "Some generation should contain the address"); |
|
963 |
assert(_old_gen->is_in(addr), "addr should be in allocated part of generation"); |
|
964 |
return _old_gen->block_size(addr); |
|
1 | 965 |
} |
966 |
||
967 |
bool GenCollectedHeap::block_is_obj(const HeapWord* addr) const { |
|
968 |
assert(is_in_reserved(addr), "block_is_obj of address outside of heap"); |
|
969 |
assert(block_start(addr) == addr, "addr must be a block start"); |
|
29200 | 970 |
if (_young_gen->is_in_reserved(addr)) { |
971 |
return _young_gen->block_is_obj(addr); |
|
1 | 972 |
} |
29200 | 973 |
|
974 |
assert(_old_gen->is_in_reserved(addr), "Some generation should contain the address"); |
|
975 |
return _old_gen->block_is_obj(addr); |
|
1 | 976 |
} |
977 |
||
978 |
bool GenCollectedHeap::supports_tlab_allocation() const { |
|
29200 | 979 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
980 |
return _young_gen->supports_tlab_allocation(); |
|
1 | 981 |
} |
982 |
||
983 |
size_t GenCollectedHeap::tlab_capacity(Thread* thr) const { |
|
29200 | 984 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
985 |
if (_young_gen->supports_tlab_allocation()) { |
|
986 |
return _young_gen->tlab_capacity(); |
|
1 | 987 |
} |
29200 | 988 |
return 0; |
1 | 989 |
} |
990 |
||
22552 | 991 |
size_t GenCollectedHeap::tlab_used(Thread* thr) const { |
29200 | 992 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
993 |
if (_young_gen->supports_tlab_allocation()) { |
|
994 |
return _young_gen->tlab_used(); |
|
22552 | 995 |
} |
29200 | 996 |
return 0; |
22552 | 997 |
} |
998 |
||
1 | 999 |
size_t GenCollectedHeap::unsafe_max_tlab_alloc(Thread* thr) const { |
29200 | 1000 |
assert(!_old_gen->supports_tlab_allocation(), "Old gen supports TLAB allocation?!"); |
1001 |
if (_young_gen->supports_tlab_allocation()) { |
|
1002 |
return _young_gen->unsafe_max_tlab_alloc(); |
|
1 | 1003 |
} |
29200 | 1004 |
return 0; |
1 | 1005 |
} |
1006 |
||
1007 |
HeapWord* GenCollectedHeap::allocate_new_tlab(size_t size) { |
|
1008 |
bool gc_overhead_limit_was_exceeded; |
|
9997
b75b7939f448
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
9995
diff
changeset
|
1009 |
return collector_policy()->mem_allocate_work(size /* size */, |
b75b7939f448
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
9995
diff
changeset
|
1010 |
true /* is_tlab */, |
b75b7939f448
6994322: Remove the is_tlab and is_noref / is_large_noref parameters from the CollectedHeap
tonyp
parents:
9995
diff
changeset
|
1011 |
&gc_overhead_limit_was_exceeded); |
1 | 1012 |
} |
1013 |
||
1014 |
// Requires "*prev_ptr" to be non-NULL. Deletes and a block of minimal size |
|
1015 |
// from the list headed by "*prev_ptr". |
|
1016 |
static ScratchBlock *removeSmallestScratch(ScratchBlock **prev_ptr) { |
|
1017 |
bool first = true; |
|
1018 |
size_t min_size = 0; // "first" makes this conceptually infinite. |
|
1019 |
ScratchBlock **smallest_ptr, *smallest; |
|
1020 |
ScratchBlock *cur = *prev_ptr; |
|
1021 |
while (cur) { |
|
1022 |
assert(*prev_ptr == cur, "just checking"); |
|
1023 |
if (first || cur->num_words < min_size) { |
|
1024 |
smallest_ptr = prev_ptr; |
|
1025 |
smallest = cur; |
|
1026 |
min_size = smallest->num_words; |
|
1027 |
first = false; |
|
1028 |
} |
|
1029 |
prev_ptr = &cur->next; |
|
1030 |
cur = cur->next; |
|
1031 |
} |
|
1032 |
smallest = *smallest_ptr; |
|
1033 |
*smallest_ptr = smallest->next; |
|
1034 |
return smallest; |
|
1035 |
} |
|
1036 |
||
1037 |
// Sort the scratch block list headed by res into decreasing size order, |
|
1038 |
// and set "res" to the result. |
|
1039 |
static void sort_scratch_list(ScratchBlock*& list) { |
|
1040 |
ScratchBlock* sorted = NULL; |
|
1041 |
ScratchBlock* unsorted = list; |
|
1042 |
while (unsorted) { |
|
1043 |
ScratchBlock *smallest = removeSmallestScratch(&unsorted); |
|
1044 |
smallest->next = sorted; |
|
1045 |
sorted = smallest; |
|
1046 |
} |
|
1047 |
list = sorted; |
|
1048 |
} |
|
1049 |
||
1050 |
ScratchBlock* GenCollectedHeap::gather_scratch(Generation* requestor, |
|
1051 |
size_t max_alloc_words) { |
|
1052 |
ScratchBlock* res = NULL; |
|
29200 | 1053 |
_young_gen->contribute_scratch(res, requestor, max_alloc_words); |
1054 |
_old_gen->contribute_scratch(res, requestor, max_alloc_words); |
|
1 | 1055 |
sort_scratch_list(res); |
1056 |
return res; |
|
1057 |
} |
|
1058 |
||
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1059 |
void GenCollectedHeap::release_scratch() { |
29200 | 1060 |
_young_gen->reset_scratch(); |
1061 |
_old_gen->reset_scratch(); |
|
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1062 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1063 |
|
1 | 1064 |
class GenPrepareForVerifyClosure: public GenCollectedHeap::GenClosure { |
1065 |
void do_generation(Generation* gen) { |
|
1066 |
gen->prepare_for_verify(); |
|
1067 |
} |
|
1068 |
}; |
|
1069 |
||
1070 |
void GenCollectedHeap::prepare_for_verify() { |
|
1071 |
ensure_parsability(false); // no need to retire TLABs |
|
1072 |
GenPrepareForVerifyClosure blk; |
|
1073 |
generation_iterate(&blk, false); |
|
1074 |
} |
|
1075 |
||
1076 |
void GenCollectedHeap::generation_iterate(GenClosure* cl, |
|
1077 |
bool old_to_young) { |
|
1078 |
if (old_to_young) { |
|
29200 | 1079 |
cl->do_generation(_old_gen); |
1080 |
cl->do_generation(_young_gen); |
|
1 | 1081 |
} else { |
29200 | 1082 |
cl->do_generation(_young_gen); |
1083 |
cl->do_generation(_old_gen); |
|
1 | 1084 |
} |
1085 |
} |
|
1086 |
||
1087 |
bool GenCollectedHeap::is_maximal_no_gc() const { |
|
29200 | 1088 |
return _young_gen->is_maximal_no_gc() && _old_gen->is_maximal_no_gc(); |
1 | 1089 |
} |
1090 |
||
1091 |
void GenCollectedHeap::save_marks() { |
|
29200 | 1092 |
_young_gen->save_marks(); |
1093 |
_old_gen->save_marks(); |
|
1 | 1094 |
} |
1095 |
||
1096 |
GenCollectedHeap* GenCollectedHeap::heap() { |
|
30258
413e15d1b146
8077415: Remove duplicate variables holding the CollectedHeap
pliden
parents:
30177
diff
changeset
|
1097 |
CollectedHeap* heap = Universe::heap(); |
413e15d1b146
8077415: Remove duplicate variables holding the CollectedHeap
pliden
parents:
30177
diff
changeset
|
1098 |
assert(heap != NULL, "Uninitialized access to GenCollectedHeap::heap()"); |
413e15d1b146
8077415: Remove duplicate variables holding the CollectedHeap
pliden
parents:
30177
diff
changeset
|
1099 |
assert(heap->kind() == CollectedHeap::GenCollectedHeap, "Not a GenCollectedHeap"); |
413e15d1b146
8077415: Remove duplicate variables holding the CollectedHeap
pliden
parents:
30177
diff
changeset
|
1100 |
return (GenCollectedHeap*)heap; |
1 | 1101 |
} |
1102 |
||
1103 |
void GenCollectedHeap::prepare_for_compaction() { |
|
1104 |
// Start by compacting into same gen. |
|
29200 | 1105 |
CompactPoint cp(_old_gen); |
1106 |
_old_gen->prepare_for_compaction(&cp); |
|
1107 |
_young_gen->prepare_for_compaction(&cp); |
|
1 | 1108 |
} |
1109 |
||
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1110 |
GCStats* GenCollectedHeap::gc_stats(Generation* gen) const { |
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1111 |
return gen->gc_stats(); |
1 | 1112 |
} |
1113 |
||
12379 | 1114 |
void GenCollectedHeap::verify(bool silent, VerifyOption option /* ignored */) { |
29200 | 1115 |
if (!silent) { |
1116 |
gclog_or_tty->print("%s", _old_gen->name()); |
|
1117 |
gclog_or_tty->print(" "); |
|
1 | 1118 |
} |
29200 | 1119 |
_old_gen->verify(); |
1120 |
||
1121 |
if (!silent) { |
|
1122 |
gclog_or_tty->print("%s", _young_gen->name()); |
|
1123 |
gclog_or_tty->print(" "); |
|
1124 |
} |
|
1125 |
_young_gen->verify(); |
|
1126 |
||
1 | 1127 |
if (!silent) { |
1128 |
gclog_or_tty->print("remset "); |
|
1129 |
} |
|
1130 |
rem_set()->verify(); |
|
1131 |
} |
|
1132 |
||
1133 |
void GenCollectedHeap::print_on(outputStream* st) const { |
|
29200 | 1134 |
_young_gen->print_on(st); |
1135 |
_old_gen->print_on(st); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
1136 |
MetaspaceAux::print_on(st); |
1 | 1137 |
} |
1138 |
||
1139 |
void GenCollectedHeap::gc_threads_do(ThreadClosure* tc) const { |
|
1140 |
if (workers() != NULL) { |
|
1141 |
workers()->threads_do(tc); |
|
1142 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
1143 |
#if INCLUDE_ALL_GCS |
1 | 1144 |
if (UseConcMarkSweepGC) { |
1145 |
ConcurrentMarkSweepThread::threads_do(tc); |
|
1146 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
1147 |
#endif // INCLUDE_ALL_GCS |
1 | 1148 |
} |
1149 |
||
1150 |
void GenCollectedHeap::print_gc_threads_on(outputStream* st) const { |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
1151 |
#if INCLUDE_ALL_GCS |
27898
813ad96387b3
8065972: Remove support for ParNew+SerialOld and DefNew+CMS
brutisso
parents:
27887
diff
changeset
|
1152 |
if (UseConcMarkSweepGC) { |
1 | 1153 |
workers()->print_worker_threads_on(st); |
1154 |
ConcurrentMarkSweepThread::print_all_on(st); |
|
1155 |
} |
|
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14076
diff
changeset
|
1156 |
#endif // INCLUDE_ALL_GCS |
1 | 1157 |
} |
1158 |
||
16685
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1159 |
void GenCollectedHeap::print_on_error(outputStream* st) const { |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1160 |
this->CollectedHeap::print_on_error(st); |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1161 |
|
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1162 |
#if INCLUDE_ALL_GCS |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1163 |
if (UseConcMarkSweepGC) { |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1164 |
st->cr(); |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1165 |
CMSCollector::print_on_error(st); |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1166 |
} |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1167 |
#endif // INCLUDE_ALL_GCS |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1168 |
} |
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
16680
diff
changeset
|
1169 |
|
1 | 1170 |
void GenCollectedHeap::print_tracing_info() const { |
24941
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
24424
diff
changeset
|
1171 |
if (TraceYoungGenTime) { |
29684
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
1172 |
_young_gen->print_summary_info(); |
1 | 1173 |
} |
24941
4ebbe176a7b1
8042298: Remove the names gen0 and gen1 from the GC code
jwilhelm
parents:
24424
diff
changeset
|
1174 |
if (TraceOldGenTime) { |
29684
a36d90acae41
8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents:
29200
diff
changeset
|
1175 |
_old_gen->print_summary_info(); |
1 | 1176 |
} |
1177 |
} |
|
1178 |
||
1179 |
void GenCollectedHeap::print_heap_change(size_t prev_used) const { |
|
1180 |
if (PrintGCDetails && Verbose) { |
|
1181 |
gclog_or_tty->print(" " SIZE_FORMAT |
|
1182 |
"->" SIZE_FORMAT |
|
1183 |
"(" SIZE_FORMAT ")", |
|
1184 |
prev_used, used(), capacity()); |
|
1185 |
} else { |
|
1186 |
gclog_or_tty->print(" " SIZE_FORMAT "K" |
|
1187 |
"->" SIZE_FORMAT "K" |
|
1188 |
"(" SIZE_FORMAT "K)", |
|
1189 |
prev_used / K, used() / K, capacity() / K); |
|
1190 |
} |
|
1191 |
} |
|
1192 |
||
1193 |
class GenGCPrologueClosure: public GenCollectedHeap::GenClosure { |
|
1194 |
private: |
|
1195 |
bool _full; |
|
1196 |
public: |
|
1197 |
void do_generation(Generation* gen) { |
|
1198 |
gen->gc_prologue(_full); |
|
1199 |
} |
|
1200 |
GenGCPrologueClosure(bool full) : _full(full) {}; |
|
1201 |
}; |
|
1202 |
||
1203 |
void GenCollectedHeap::gc_prologue(bool full) { |
|
1204 |
assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer"); |
|
1205 |
||
1206 |
always_do_update_barrier = false; |
|
1207 |
// Fill TLAB's and such |
|
1208 |
CollectedHeap::accumulate_statistics_all_tlabs(); |
|
1209 |
ensure_parsability(true); // retire TLABs |
|
1210 |
||
1211 |
// Walk generations |
|
1212 |
GenGCPrologueClosure blk(full); |
|
1213 |
generation_iterate(&blk, false); // not old-to-young. |
|
1214 |
}; |
|
1215 |
||
1216 |
class GenGCEpilogueClosure: public GenCollectedHeap::GenClosure { |
|
1217 |
private: |
|
1218 |
bool _full; |
|
1219 |
public: |
|
1220 |
void do_generation(Generation* gen) { |
|
1221 |
gen->gc_epilogue(_full); |
|
1222 |
} |
|
1223 |
GenGCEpilogueClosure(bool full) : _full(full) {}; |
|
1224 |
}; |
|
1225 |
||
1226 |
void GenCollectedHeap::gc_epilogue(bool full) { |
|
1227 |
#ifdef COMPILER2 |
|
1228 |
assert(DerivedPointerTable::is_empty(), "derived pointer present"); |
|
1229 |
size_t actual_gap = pointer_delta((HeapWord*) (max_uintx-3), *(end_addr())); |
|
1230 |
guarantee(actual_gap > (size_t)FastAllocateSizeLimit, "inline allocation wraps"); |
|
1231 |
#endif /* COMPILER2 */ |
|
1232 |
||
1233 |
resize_all_tlabs(); |
|
1234 |
||
1235 |
GenGCEpilogueClosure blk(full); |
|
1236 |
generation_iterate(&blk, false); // not old-to-young. |
|
1237 |
||
10022
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1238 |
if (!CleanChunkPoolAsync) { |
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1239 |
Chunk::clean_chunk_pool(); |
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1240 |
} |
377345fb5fb5
7061204: clean the chunk table synchronously in embedded builds
jcoomes
parents:
9997
diff
changeset
|
1241 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
1242 |
MetaspaceCounters::update_performance_counters(); |
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19286
diff
changeset
|
1243 |
CompressedClassSpaceCounters::update_performance_counters(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12781
diff
changeset
|
1244 |
|
1 | 1245 |
always_do_update_barrier = UseConcMarkSweepGC; |
1246 |
}; |
|
1247 |
||
971
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1248 |
#ifndef PRODUCT |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1249 |
class GenGCSaveTopsBeforeGCClosure: public GenCollectedHeap::GenClosure { |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1250 |
private: |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1251 |
public: |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1252 |
void do_generation(Generation* gen) { |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1253 |
gen->record_spaces_top(); |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1254 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1255 |
}; |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1256 |
|
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1257 |
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
|
1258 |
if (ZapUnusedHeapArea) { |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1259 |
GenGCSaveTopsBeforeGCClosure blk; |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1260 |
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
|
1261 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1262 |
} |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1263 |
#endif // not PRODUCT |
f0b20be4165d
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
360
diff
changeset
|
1264 |
|
1 | 1265 |
class GenEnsureParsabilityClosure: public GenCollectedHeap::GenClosure { |
1266 |
public: |
|
1267 |
void do_generation(Generation* gen) { |
|
1268 |
gen->ensure_parsability(); |
|
1269 |
} |
|
1270 |
}; |
|
1271 |
||
1272 |
void GenCollectedHeap::ensure_parsability(bool retire_tlabs) { |
|
1273 |
CollectedHeap::ensure_parsability(retire_tlabs); |
|
1274 |
GenEnsureParsabilityClosure ep_cl; |
|
1275 |
generation_iterate(&ep_cl, false); |
|
1276 |
} |
|
1277 |
||
19286
48394008c803
8022800: Use specific generations rather than generation iteration
brutisso
parents:
18687
diff
changeset
|
1278 |
oop GenCollectedHeap::handle_failed_promotion(Generation* old_gen, |
1 | 1279 |
oop obj, |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
1280 |
size_t obj_size) { |
31358
693058672cc6
8077842: Remove the level parameter passed around in GenCollectedHeap
jwilhelm
parents:
31032
diff
changeset
|
1281 |
guarantee(old_gen == _old_gen, "We only get here with an old generation"); |
1 | 1282 |
assert(obj_size == (size_t)obj->size(), "bad obj_size passed in"); |
1283 |
HeapWord* result = NULL; |
|
1284 |
||
19286
48394008c803
8022800: Use specific generations rather than generation iteration
brutisso
parents:
18687
diff
changeset
|
1285 |
result = old_gen->expand_and_allocate(obj_size, false); |
1 | 1286 |
|
1287 |
if (result != NULL) { |
|
1288 |
Copy::aligned_disjoint_words((HeapWord*)obj, result, obj_size); |
|
1289 |
} |
|
1290 |
return oop(result); |
|
1291 |
} |
|
1292 |
||
1293 |
class GenTimeOfLastGCClosure: public GenCollectedHeap::GenClosure { |
|
1294 |
jlong _time; // in ms |
|
1295 |
jlong _now; // in ms |
|
1296 |
||
1297 |
public: |
|
1298 |
GenTimeOfLastGCClosure(jlong now) : _time(now), _now(now) { } |
|
1299 |
||
1300 |
jlong time() { return _time; } |
|
1301 |
||
1302 |
void do_generation(Generation* gen) { |
|
1303 |
_time = MIN2(_time, gen->time_of_last_gc(_now)); |
|
1304 |
} |
|
1305 |
}; |
|
1306 |
||
1307 |
jlong GenCollectedHeap::millis_since_last_gc() { |
|
22551 | 1308 |
// We need a monotonically non-decreasing time in ms but |
11251
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1309 |
// os::javaTimeMillis() does not guarantee monotonicity. |
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1310 |
jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; |
1 | 1311 |
GenTimeOfLastGCClosure tolgc_cl(now); |
1312 |
// iterate over generations getting the oldest |
|
1313 |
// time that a generation was collected |
|
1314 |
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
|
1315 |
|
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1316 |
// javaTimeNanos() is guaranteed to be monotonically non-decreasing |
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1317 |
// provided the underlying platform provides such a time source |
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1318 |
// (and it is bug free). So we still have to guard against getting |
e29da6b5622b
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
johnc
parents:
11247
diff
changeset
|
1319 |
// back a time later than 'now'. |
1 | 1320 |
jlong retVal = now - tolgc_cl.time(); |
1321 |
if (retVal < 0) { |
|
29800
fa5f7a2bf717
8076073: shared: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
29794
diff
changeset
|
1322 |
NOT_PRODUCT(warning("time warp: " JLONG_FORMAT, retVal);) |
1 | 1323 |
return 0; |
1324 |
} |
|
1325 |
return retVal; |
|
1326 |
} |