author | coleenp |
Thu, 11 Dec 2014 21:34:43 -0500 | |
changeset 28163 | 322d55d167be |
parent 27898 | 813ad96387b3 |
child 28217 | 57791914628c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24092
diff
changeset
|
2 |
* Copyright (c) 2000, 2014, 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:
3908
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3908
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:
3908
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
24426
0a69c8cdfca9
8038654: Separate SymbolTable and StringTable code
gziemski
parents:
24092
diff
changeset
|
26 |
#include "classfile/stringTable.hpp" |
7397 | 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" |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
32 |
#include "runtime/atomic.inline.hpp" |
7397 | 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" |
|
1 | 38 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24092
diff
changeset
|
39 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24092
diff
changeset
|
40 |
|
1 | 41 |
SharedHeap* SharedHeap::_sh; |
42 |
||
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
43 |
// 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
|
44 |
enum SH_process_roots_tasks { |
1 | 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, |
|
17844
28ca9179db98
8015268: NPG: 2.5% regression in young GC times on CRM Sales Opty
stefank
parents:
17625
diff
changeset
|
51 |
SH_PS_ClassLoaderDataGraph_oops_do, |
1 | 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_), |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11396
diff
changeset
|
61 |
_rem_set(NULL), |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
62 |
_strong_roots_scope(NULL), |
1 | 63 |
_strong_roots_parity(0), |
64 |
_process_strong_tasks(new SubTasksDone(SH_PS_NumElements)), |
|
6759
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
5547
diff
changeset
|
65 |
_workers(NULL) |
1 | 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. |
|
27898
813ad96387b3
8065972: Remove support for ParNew+SerialOld and DefNew+CMS
brutisso
parents:
27251
diff
changeset
|
71 |
if (UseConcMarkSweepGC || UseG1GC) { |
6759
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
5547
diff
changeset
|
72 |
_workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads, |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
73 |
/* are_GC_task_threads */true, |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
74 |
/* are_ConcurrentGC_threads */false); |
1 | 75 |
if (_workers == NULL) { |
76 |
vm_exit_during_initialization("Failed necessary allocation."); |
|
6759
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
5547
diff
changeset
|
77 |
} else { |
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
5547
diff
changeset
|
78 |
_workers->initialize_workers(); |
1 | 79 |
} |
80 |
} |
|
81 |
} |
|
82 |
||
11174
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
83 |
int SharedHeap::n_termination() { |
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
84 |
return _process_strong_tasks->n_threads(); |
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
85 |
} |
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
86 |
|
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
87 |
void SharedHeap::set_n_termination(int t) { |
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
88 |
_process_strong_tasks->set_n_threads(t); |
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
89 |
} |
fccee5238e70
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents:
10524
diff
changeset
|
90 |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
91 |
bool SharedHeap::heap_lock_held_for_gc() { |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
92 |
Thread* t = Thread::current(); |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
93 |
return Heap_lock->owned_by_self() |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
94 |
|| ( (t->is_GC_task_thread() || t->is_VM_thread()) |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
95 |
&& _thread_holds_heap_lock_for_gc); |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
96 |
} |
1 | 97 |
|
11396
917d8673b5ef
7121618: Change type of number of GC workers to unsigned int.
jmasa
parents:
11174
diff
changeset
|
98 |
void SharedHeap::set_par_threads(uint t) { |
6759
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
5547
diff
changeset
|
99 |
assert(t == 0 || !UseSerialGC, "Cannot have parallel threads"); |
1 | 100 |
_n_par_threads = t; |
6759
67b1a69ef5aa
6984287: Regularize how GC parallel workers are specified.
jmasa
parents:
5547
diff
changeset
|
101 |
_process_strong_tasks->set_n_threads(t); |
1 | 102 |
} |
103 |
||
9935
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
104 |
#ifdef ASSERT |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
105 |
class AssertNonScavengableClosure: public OopClosure { |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
106 |
public: |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
107 |
virtual void do_oop(oop* p) { |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
108 |
assert(!Universe::heap()->is_in_partial_collection(*p), |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
109 |
"Referent should not be scavengable."); } |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
110 |
virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); } |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
111 |
}; |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
112 |
static AssertNonScavengableClosure assert_is_non_scavengable_closure; |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
113 |
#endif |
51267b5e1a3d
7041789: 30% perf regression with c2/arm following 7017732
jmasa
parents:
9342
diff
changeset
|
114 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
115 |
SharedHeap::StrongRootsScope* SharedHeap::active_strong_roots_scope() const { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
116 |
return _strong_roots_scope; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
117 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
118 |
void SharedHeap::register_strong_roots_scope(SharedHeap::StrongRootsScope* scope) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
119 |
assert(_strong_roots_scope == NULL, "Should only have one StrongRootsScope active"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
120 |
assert(scope != NULL, "Illegal argument"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
121 |
_strong_roots_scope = scope; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
122 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
123 |
void SharedHeap::unregister_strong_roots_scope(SharedHeap::StrongRootsScope* scope) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
124 |
assert(_strong_roots_scope == scope, "Wrong scope unregistered"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
125 |
_strong_roots_scope = NULL; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
126 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
127 |
|
1 | 128 |
void SharedHeap::change_strong_roots_parity() { |
129 |
// Also set the new collection parity. |
|
130 |
assert(_strong_roots_parity >= 0 && _strong_roots_parity <= 2, |
|
131 |
"Not in range."); |
|
132 |
_strong_roots_parity++; |
|
133 |
if (_strong_roots_parity == 3) _strong_roots_parity = 1; |
|
134 |
assert(_strong_roots_parity >= 1 && _strong_roots_parity <= 2, |
|
135 |
"Not in range."); |
|
136 |
} |
|
137 |
||
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
138 |
SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* heap, bool activate) |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
139 |
: MarkScope(activate), _sh(heap), _n_workers_done_with_threads(0) |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
2105
diff
changeset
|
140 |
{ |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
2105
diff
changeset
|
141 |
if (_active) { |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
142 |
_sh->register_strong_roots_scope(this); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
143 |
_sh->change_strong_roots_parity(); |
18091
ddde9f0f414d
8015237: Parallelize string table scanning during strong root processing
johnc
parents:
17844
diff
changeset
|
144 |
// Zero the claimed high water mark in the StringTable |
ddde9f0f414d
8015237: Parallelize string table scanning during strong root processing
johnc
parents:
17844
diff
changeset
|
145 |
StringTable::clear_parallel_claimed_index(); |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
2105
diff
changeset
|
146 |
} |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
2105
diff
changeset
|
147 |
} |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
2105
diff
changeset
|
148 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
2105
diff
changeset
|
149 |
SharedHeap::StrongRootsScope::~StrongRootsScope() { |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
150 |
if (_active) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
151 |
_sh->unregister_strong_roots_scope(this); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
152 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
153 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
154 |
|
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
27898
diff
changeset
|
155 |
Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false, Monitor::_safepoint_check_never); |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
156 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
157 |
void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) { |
25908
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
25492
diff
changeset
|
158 |
// The Thread work barrier is only needed by G1 Class Unloading. |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
159 |
// No need to use the barrier if this is single-threaded code. |
25908
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
25492
diff
changeset
|
160 |
if (UseG1GC && ClassUnloadingWithConcurrentMark && n_workers > 0) { |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
161 |
uint new_value = (uint)Atomic::add(1, &_n_workers_done_with_threads); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
162 |
if (new_value == n_workers) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
163 |
// This thread is last. Notify the others. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
164 |
MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
165 |
_lock->notify_all(); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
166 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
167 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
168 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
169 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
170 |
void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) { |
25908
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
25492
diff
changeset
|
171 |
assert(UseG1GC, "Currently only used by G1"); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
25492
diff
changeset
|
172 |
assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading"); |
8adb2fb6fc3c
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
25492
diff
changeset
|
173 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
174 |
// No need to use the barrier if this is single-threaded code. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
175 |
if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
176 |
MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
177 |
while ((uint)_n_workers_done_with_threads != n_workers) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
178 |
_lock->wait(Mutex::_no_safepoint_check_flag, 0, false); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
179 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
180 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
181 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
182 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
183 |
void SharedHeap::process_roots(bool activate_scope, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
184 |
ScanningOption so, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
185 |
OopClosure* strong_roots, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
186 |
OopClosure* weak_roots, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
187 |
CLDClosure* strong_cld_closure, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
188 |
CLDClosure* weak_cld_closure, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
189 |
CodeBlobClosure* code_roots) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
190 |
StrongRootsScope srs(this, activate_scope); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
191 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
192 |
// General roots. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
193 |
assert(_strong_roots_parity != 0, "must have called prologue code"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
194 |
assert(code_roots != NULL, "code root closure should always be set"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
195 |
// _n_termination for _process_strong_tasks should be set up stream |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
196 |
// in a method not running in a GC worker. Otherwise the GC worker |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
197 |
// could be trying to change the termination condition while the task |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
198 |
// is executing in another GC worker. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
199 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
200 |
// Iterating over the CLDG and the Threads are done early to allow G1 to |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
201 |
// first process the strong CLDs and nmethods and then, after a barrier, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
202 |
// let the thread process the weak CLDs and nmethods. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
203 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
204 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
205 |
ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
206 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
207 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
208 |
// Some CLDs contained in the thread frames should be considered strong. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
209 |
// Don't process them if they will be processed during the ClassLoaderDataGraph phase. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
210 |
CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
211 |
// Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
212 |
CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
213 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
214 |
Threads::possibly_parallel_oops_do(strong_roots, roots_from_clds_p, roots_from_code_p); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
215 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
216 |
// This is the point where this worker thread will not find more strong CLDs/nmethods. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
217 |
// Report this so G1 can synchronize the strong and weak CLDs/nmethods processing. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
218 |
active_strong_roots_scope()->mark_worker_done_with_threads(n_par_threads()); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
219 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
220 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
221 |
Universe::oops_do(strong_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
222 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
223 |
// Global (strong) JNI handles |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
224 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do)) |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
225 |
JNIHandles::oops_do(strong_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
226 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
227 |
if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do)) |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
228 |
ObjectSynchronizer::oops_do(strong_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
229 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_FlatProfiler_oops_do)) |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
230 |
FlatProfiler::oops_do(strong_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
231 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_Management_oops_do)) |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
232 |
Management::oops_do(strong_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
233 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_jvmti_oops_do)) |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
234 |
JvmtiExport::oops_do(strong_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
235 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
236 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_SystemDictionary_oops_do)) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
237 |
SystemDictionary::roots_oops_do(strong_roots, weak_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
238 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
239 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
240 |
// All threads execute the following. A specific chunk of buckets |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
241 |
// from the StringTable are the individual tasks. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
242 |
if (weak_roots != NULL) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
243 |
if (CollectedHeap::use_parallel_gc_threads()) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
244 |
StringTable::possibly_parallel_oops_do(weak_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
245 |
} else { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
246 |
StringTable::oops_do(weak_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
247 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
248 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
249 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
250 |
if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
251 |
if (so & SO_ScavengeCodeCache) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
252 |
assert(code_roots != NULL, "must supply closure for code cache"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
253 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
254 |
// We only visit parts of the CodeCache when scavenging. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
255 |
CodeCache::scavenge_root_nmethods_do(code_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
256 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
257 |
if (so & SO_AllCodeCache) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
258 |
assert(code_roots != NULL, "must supply closure for code cache"); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
259 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
260 |
// CMSCollector uses this to do intermediate-strength collections. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
261 |
// We scan the entire code cache, since CodeCache::do_unloading is not called. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
262 |
CodeCache::blobs_do(code_roots); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
263 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
264 |
// Verify that the code cache contents are not subject to |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
265 |
// movement by a scavenging collection. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
266 |
DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations)); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
267 |
DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable)); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
268 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
269 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
270 |
_process_strong_tasks->all_tasks_completed(); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
271 |
} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
272 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
273 |
void SharedHeap::process_all_roots(bool activate_scope, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
274 |
ScanningOption so, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
275 |
OopClosure* roots, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
276 |
CLDClosure* cld_closure, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
277 |
CodeBlobClosure* code_closure) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
278 |
process_roots(activate_scope, so, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
279 |
roots, roots, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
280 |
cld_closure, cld_closure, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
281 |
code_closure); |
25490
59f226da8d81
8048248: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
24429
diff
changeset
|
282 |
} |
59f226da8d81
8048248: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
24429
diff
changeset
|
283 |
|
25491 | 284 |
void SharedHeap::process_strong_roots(bool activate_scope, |
285 |
ScanningOption so, |
|
286 |
OopClosure* roots, |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
287 |
CLDClosure* cld_closure, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
288 |
CodeBlobClosure* code_closure) { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
289 |
process_roots(activate_scope, so, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
290 |
roots, NULL, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
291 |
cld_closure, NULL, |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
292 |
code_closure); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
293 |
} |
25490
59f226da8d81
8048248: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
24429
diff
changeset
|
294 |
|
59f226da8d81
8048248: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
24429
diff
changeset
|
295 |
|
1 | 296 |
class AlwaysTrueClosure: public BoolObjectClosure { |
297 |
public: |
|
298 |
bool do_object_b(oop p) { return true; } |
|
299 |
}; |
|
300 |
static AlwaysTrueClosure always_true; |
|
301 |
||
22882
195c8f70d605
8034761: Remove the do_code_roots parameter from process_strong_roots
stefank
parents:
22550
diff
changeset
|
302 |
void SharedHeap::process_weak_roots(OopClosure* root_closure) { |
1 | 303 |
// Global (weak) JNI handles |
304 |
JNIHandles::weak_oops_do(&always_true, root_closure); |
|
17105
25b392a7740d
8012687: Remove unused is_root checks and closures
stefank
parents:
16370
diff
changeset
|
305 |
} |
1 | 306 |
|
307 |
void SharedHeap::set_barrier_set(BarrierSet* bs) { |
|
308 |
_barrier_set = bs; |
|
309 |
// Cached barrier set for fast access in oops |
|
310 |
oopDesc::set_bs(bs); |
|
311 |
} |
|
312 |
||
313 |
void SharedHeap::post_initialize() { |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
18996
diff
changeset
|
314 |
CollectedHeap::post_initialize(); |
1 | 315 |
ref_processing_init(); |
316 |
} |
|
317 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11396
diff
changeset
|
318 |
void SharedHeap::ref_processing_init() {} |
1 | 319 |
|
320 |
// Some utilities. |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
321 |
void SharedHeap::print_size_transition(outputStream* out, |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
322 |
size_t bytes_before, |
1 | 323 |
size_t bytes_after, |
324 |
size_t capacity) { |
|
24092
e274d864545a
8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents:
22883
diff
changeset
|
325 |
out->print(" " SIZE_FORMAT "%s->" SIZE_FORMAT "%s(" SIZE_FORMAT "%s)", |
1 | 326 |
byte_size_in_proper_unit(bytes_before), |
327 |
proper_unit_for_byte_size(bytes_before), |
|
328 |
byte_size_in_proper_unit(bytes_after), |
|
329 |
proper_unit_for_byte_size(bytes_after), |
|
330 |
byte_size_in_proper_unit(capacity), |
|
331 |
proper_unit_for_byte_size(capacity)); |
|
332 |
} |