Mercurial > hg > truffle
annotate src/share/vm/memory/sharedHeap.cpp @ 20543:e7d0505c8a30
8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso
author | tschatzl |
---|---|
date | Fri, 10 Oct 2014 15:51:58 +0200 |
parents | f3aeae1f9fc5 |
children | 7848fc12602b |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13060
diff
changeset
|
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
989
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
989
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
989
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/symbolTable.hpp" | |
27 #include "classfile/systemDictionary.hpp" | |
28 #include "code/codeCache.hpp" | |
29 #include "gc_interface/collectedHeap.inline.hpp" | |
30 #include "memory/sharedHeap.hpp" | |
31 #include "oops/oop.inline.hpp" | |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
32 #include "runtime/atomic.inline.hpp" |
1972 | 33 #include "runtime/fprofiler.hpp" |
34 #include "runtime/java.hpp" | |
35 #include "services/management.hpp" | |
36 #include "utilities/copy.hpp" | |
37 #include "utilities/workgroup.hpp" | |
0 | 38 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13060
diff
changeset
|
39 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13060
diff
changeset
|
40 |
0 | 41 SharedHeap* SharedHeap::_sh; |
42 | |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
43 // The set of potentially parallel tasks in root scanning. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
44 enum SH_process_roots_tasks { |
0 | 45 SH_PS_Universe_oops_do, |
46 SH_PS_JNIHandles_oops_do, | |
47 SH_PS_ObjectSynchronizer_oops_do, | |
48 SH_PS_FlatProfiler_oops_do, | |
49 SH_PS_Management_oops_do, | |
50 SH_PS_SystemDictionary_oops_do, | |
10361
eda078b01c65
8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents:
10327
diff
changeset
|
51 SH_PS_ClassLoaderDataGraph_oops_do, |
0 | 52 SH_PS_jvmti_oops_do, |
53 SH_PS_CodeCache_oops_do, | |
54 // Leave this one last. | |
55 SH_PS_NumElements | |
56 }; | |
57 | |
58 SharedHeap::SharedHeap(CollectorPolicy* policy_) : | |
59 CollectedHeap(), | |
60 _collector_policy(policy_), | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4728
diff
changeset
|
61 _rem_set(NULL), |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
62 _strong_roots_scope(NULL), |
0 | 63 _strong_roots_parity(0), |
64 _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)), | |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
65 _workers(NULL) |
0 | 66 { |
67 if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) { | |
68 vm_exit_during_initialization("Failed necessary allocation."); | |
69 } | |
70 _sh = this; // ch is static, should be set only once. | |
71 if ((UseParNewGC || | |
11975 | 72 (UseConcMarkSweepGC && (CMSParallelInitialMarkEnabled || |
73 CMSParallelRemarkEnabled)) || | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
74 UseG1GC) && |
0 | 75 ParallelGCThreads > 0) { |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
76 _workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads, |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
77 /* are_GC_task_threads */true, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
78 /* are_ConcurrentGC_threads */false); |
0 | 79 if (_workers == NULL) { |
80 vm_exit_during_initialization("Failed necessary allocation."); | |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
81 } else { |
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
82 _workers->initialize_workers(); |
0 | 83 } |
84 } | |
85 } | |
86 | |
4095
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
87 int SharedHeap::n_termination() { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
88 return _process_strong_tasks->n_threads(); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
89 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
90 |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
91 void SharedHeap::set_n_termination(int t) { |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
92 _process_strong_tasks->set_n_threads(t); |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
93 } |
bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
3915
diff
changeset
|
94 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
95 bool SharedHeap::heap_lock_held_for_gc() { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
96 Thread* t = Thread::current(); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
97 return Heap_lock->owned_by_self() |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
98 || ( (t->is_GC_task_thread() || t->is_VM_thread()) |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
99 && _thread_holds_heap_lock_for_gc); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
100 } |
0 | 101 |
4728
441e946dc1af
7121618: Change type of number of GC workers to unsigned int.
jmasa
parents:
4095
diff
changeset
|
102 void SharedHeap::set_par_threads(uint t) { |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
103 assert(t == 0 || !UseSerialGC, "Cannot have parallel threads"); |
0 | 104 _n_par_threads = t; |
1833
8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
1552
diff
changeset
|
105 _process_strong_tasks->set_n_threads(t); |
0 | 106 } |
107 | |
3377
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
108 #ifdef ASSERT |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
109 class AssertNonScavengableClosure: public OopClosure { |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
110 public: |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
111 virtual void do_oop(oop* p) { |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
112 assert(!Universe::heap()->is_in_partial_collection(*p), |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
113 "Referent should not be scavengable."); } |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
114 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); } |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
115 }; |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
116 static AssertNonScavengableClosure assert_is_non_scavengable_closure; |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
117 #endif |
2aa9ddbb9e60
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
3293
diff
changeset
|
118 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
119 SharedHeap::StrongRootsScope* SharedHeap::active_strong_roots_scope() const { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
120 return _strong_roots_scope; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
121 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
122 void SharedHeap::register_strong_roots_scope(SharedHeap::StrongRootsScope* scope) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
123 assert(_strong_roots_scope == NULL, "Should only have one StrongRootsScope active"); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
124 assert(scope != NULL, "Illegal argument"); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
125 _strong_roots_scope = scope; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
126 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
127 void SharedHeap::unregister_strong_roots_scope(SharedHeap::StrongRootsScope* scope) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
128 assert(_strong_roots_scope == scope, "Wrong scope unregistered"); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
129 _strong_roots_scope = NULL; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
130 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
131 |
0 | 132 void SharedHeap::change_strong_roots_parity() { |
133 // Also set the new collection parity. | |
134 assert(_strong_roots_parity >= 0 && _strong_roots_parity <= 2, | |
135 "Not in range."); | |
136 _strong_roots_parity++; | |
137 if (_strong_roots_parity == 3) _strong_roots_parity = 1; | |
138 assert(_strong_roots_parity >= 1 && _strong_roots_parity <= 2, | |
139 "Not in range."); | |
140 } | |
141 | |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
142 SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* heap, bool activate) |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
143 : MarkScope(activate), _sh(heap), _n_workers_done_with_threads(0) |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
144 { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
145 if (_active) { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
146 _sh->register_strong_roots_scope(this); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
147 _sh->change_strong_roots_parity(); |
10991
01522ca68fc7
8015237: Parallelize string table scanning during strong root processing
johnc
parents:
10361
diff
changeset
|
148 // Zero the claimed high water mark in the StringTable |
01522ca68fc7
8015237: Parallelize string table scanning during strong root processing
johnc
parents:
10361
diff
changeset
|
149 StringTable::clear_parallel_claimed_index(); |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
150 } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
151 } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
152 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
153 SharedHeap::StrongRootsScope::~StrongRootsScope() { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
154 if (_active) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
155 _sh->unregister_strong_roots_scope(this); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
156 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
157 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
158 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
159 Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
160 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
161 void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) { |
20282
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
20278
diff
changeset
|
162 // The Thread work barrier is only needed by G1 Class Unloading. |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
163 // No need to use the barrier if this is single-threaded code. |
20282
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
20278
diff
changeset
|
164 if (UseG1GC && ClassUnloadingWithConcurrentMark && n_workers > 0) { |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
165 uint new_value = (uint)Atomic::add(1, &_n_workers_done_with_threads); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
166 if (new_value == n_workers) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
167 // This thread is last. Notify the others. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
168 MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
169 _lock->notify_all(); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
170 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
171 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
172 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
173 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
174 void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) { |
20282
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
20278
diff
changeset
|
175 assert(UseG1GC, "Currently only used by G1"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
20278
diff
changeset
|
176 assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
20278
diff
changeset
|
177 |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
178 // No need to use the barrier if this is single-threaded code. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
179 if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
180 MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
181 while ((uint)_n_workers_done_with_threads != n_workers) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
182 _lock->wait(Mutex::_no_safepoint_check_flag, 0, false); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
183 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
184 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
185 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
186 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
187 void SharedHeap::process_roots(bool activate_scope, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
188 ScanningOption so, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
189 OopClosure* strong_roots, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
190 OopClosure* weak_roots, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
191 CLDClosure* strong_cld_closure, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
192 CLDClosure* weak_cld_closure, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
193 CodeBlobClosure* code_roots) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
194 StrongRootsScope srs(this, activate_scope); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
195 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
196 // General roots. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
197 assert(_strong_roots_parity != 0, "must have called prologue code"); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
198 assert(code_roots != NULL, "code root closure should always be set"); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
199 // _n_termination for _process_strong_tasks should be set up stream |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
200 // in a method not running in a GC worker. Otherwise the GC worker |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
201 // could be trying to change the termination condition while the task |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
202 // is executing in another GC worker. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
203 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
204 // Iterating over the CLDG and the Threads are done early to allow G1 to |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
205 // first process the strong CLDs and nmethods and then, after a barrier, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
206 // let the thread process the weak CLDs and nmethods. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
207 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
208 if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
209 ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
210 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
211 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
212 // Some CLDs contained in the thread frames should be considered strong. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
213 // Don't process them if they will be processed during the ClassLoaderDataGraph phase. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
214 CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
215 // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
216 CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots; |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
217 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
218 Threads::possibly_parallel_oops_do(strong_roots, roots_from_clds_p, roots_from_code_p); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
219 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
220 // This is the point where this worker thread will not find more strong CLDs/nmethods. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
221 // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
222 active_strong_roots_scope()->mark_worker_done_with_threads(n_par_threads()); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
223 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
224 if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
225 Universe::oops_do(strong_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
226 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
227 // Global (strong) JNI handles |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
228 if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do)) |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
229 JNIHandles::oops_do(strong_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
230 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
231 if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do)) |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
232 ObjectSynchronizer::oops_do(strong_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
233 if (!_process_strong_tasks->is_task_claimed(SH_PS_FlatProfiler_oops_do)) |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
234 FlatProfiler::oops_do(strong_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
235 if (!_process_strong_tasks->is_task_claimed(SH_PS_Management_oops_do)) |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
236 Management::oops_do(strong_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
237 if (!_process_strong_tasks->is_task_claimed(SH_PS_jvmti_oops_do)) |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
238 JvmtiExport::oops_do(strong_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
239 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
240 if (!_process_strong_tasks->is_task_claimed(SH_PS_SystemDictionary_oops_do)) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
241 SystemDictionary::roots_oops_do(strong_roots, weak_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
242 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
243 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
244 // All threads execute the following. A specific chunk of buckets |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
245 // from the StringTable are the individual tasks. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
246 if (weak_roots != NULL) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
247 if (CollectedHeap::use_parallel_gc_threads()) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
248 StringTable::possibly_parallel_oops_do(weak_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
249 } else { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
250 StringTable::oops_do(weak_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
251 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
252 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
253 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
254 if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
255 if (so & SO_ScavengeCodeCache) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
256 assert(code_roots != NULL, "must supply closure for code cache"); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
257 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
258 // We only visit parts of the CodeCache when scavenging. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
259 CodeCache::scavenge_root_nmethods_do(code_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
260 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
261 if (so & SO_AllCodeCache) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
262 assert(code_roots != NULL, "must supply closure for code cache"); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
263 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
264 // CMSCollector uses this to do intermediate-strength collections. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
265 // We scan the entire code cache, since CodeCache::do_unloading is not called. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
266 CodeCache::blobs_do(code_roots); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
267 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
268 // Verify that the code cache contents are not subject to |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
269 // movement by a scavenging collection. |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
270 DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations)); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
271 DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable)); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
272 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
273 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
274 _process_strong_tasks->all_tasks_completed(); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
275 } |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
276 |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
277 void SharedHeap::process_all_roots(bool activate_scope, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
278 ScanningOption so, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
279 OopClosure* roots, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
280 CLDClosure* cld_closure, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
281 CodeBlobClosure* code_closure) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
282 process_roots(activate_scope, so, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
283 roots, roots, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
284 cld_closure, cld_closure, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
285 code_closure); |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
286 } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
287 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
579
diff
changeset
|
288 void SharedHeap::process_strong_roots(bool activate_scope, |
0 | 289 ScanningOption so, |
290 OopClosure* roots, | |
20278
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
291 CLDClosure* cld_closure, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
292 CodeBlobClosure* code_closure) { |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
293 process_roots(activate_scope, so, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
294 roots, NULL, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
295 cld_closure, NULL, |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
296 code_closure); |
2c6ef90f030a
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
20258
diff
changeset
|
297 } |
0 | 298 |
299 | |
300 class AlwaysTrueClosure: public BoolObjectClosure { | |
301 public: | |
302 bool do_object_b(oop p) { return true; } | |
303 }; | |
304 static AlwaysTrueClosure always_true; | |
305 | |
20257
7426d8d76305
8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents:
20254
diff
changeset
|
306 void SharedHeap::process_weak_roots(OopClosure* root_closure) { |
0 | 307 // Global (weak) JNI handles |
308 JNIHandles::weak_oops_do(&always_true, root_closure); | |
10179
a08c80e9e1e5
8012687: Remove unused is_root checks and closures
stefank
parents:
8769
diff
changeset
|
309 } |
0 | 310 |
311 void SharedHeap::set_barrier_set(BarrierSet* bs) { | |
312 _barrier_set = bs; | |
313 // Cached barrier set for fast access in oops | |
314 oopDesc::set_bs(bs); | |
315 } | |
316 | |
317 void SharedHeap::post_initialize() { | |
13060
8f07aa079343
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
11975
diff
changeset
|
318 CollectedHeap::post_initialize(); |
0 | 319 ref_processing_init(); |
320 } | |
321 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
4728
diff
changeset
|
322 void SharedHeap::ref_processing_init() {} |
0 | 323 |
324 // Some utilities. | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
325 void SharedHeap::print_size_transition(outputStream* out, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
326 size_t bytes_before, |
0 | 327 size_t bytes_after, |
328 size_t capacity) { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
329 out->print(" %d%s->%d%s(%d%s)", |
0 | 330 byte_size_in_proper_unit(bytes_before), |
331 proper_unit_for_byte_size(bytes_before), | |
332 byte_size_in_proper_unit(bytes_after), | |
333 proper_unit_for_byte_size(bytes_after), | |
334 byte_size_in_proper_unit(capacity), | |
335 proper_unit_for_byte_size(capacity)); | |
336 } |