annotate src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents 148e5441d916
children a93a9eda13f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 989
diff changeset
2 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_psTasks.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 //
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // ScavengeRootsTask
a61af66fc99e Initial load
duke
parents:
diff changeset
30 //
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Define before use
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class PSScavengeRootsClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 PSPromotionManager* _promotion_manager;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
37 protected:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
38 template <class T> void do_oop_work(T *p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
39 if (PSScavenge::should_scavenge(p)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // We never card mark roots, maybe call a func without test?
a61af66fc99e Initial load
duke
parents:
diff changeset
41 PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
44 public:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
45 PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
46 void do_oop(oop* p) { PSScavengeRootsClosure::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
47 void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 };
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 assert(Universe::heap()->is_gc_active(), "called outside gc");
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 PSScavengeRootsClosure roots_closure(pm);
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 switch (_root_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 case universe:
a61af66fc99e Initial load
duke
parents:
diff changeset
58 Universe::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 ReferenceProcessor::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 case jni_handles:
a61af66fc99e Initial load
duke
parents:
diff changeset
63 JNIHandles::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 case threads:
a61af66fc99e Initial load
duke
parents:
diff changeset
67 {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 ResourceMark rm;
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
69 Threads::oops_do(&roots_closure, NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 case object_synchronizer:
a61af66fc99e Initial load
duke
parents:
diff changeset
74 ObjectSynchronizer::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 case flat_profiler:
a61af66fc99e Initial load
duke
parents:
diff changeset
78 FlatProfiler::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 case system_dictionary:
a61af66fc99e Initial load
duke
parents:
diff changeset
82 SystemDictionary::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 case management:
a61af66fc99e Initial load
duke
parents:
diff changeset
86 Management::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 case jvmti:
a61af66fc99e Initial load
duke
parents:
diff changeset
90 JvmtiExport::oops_do(&roots_closure);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
92
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
93
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
94 case code_cache:
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
95 {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
96 CodeBlobToOopClosure each_scavengable_code_blob(&roots_closure, /*do_marking=*/ true);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
97 CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
98 }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
99 break;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
100
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
102 fatal("Unknown root type");
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Do the real work
a61af66fc99e Initial load
duke
parents:
diff changeset
106 pm->drain_stacks(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 //
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // ThreadRootsTask
a61af66fc99e Initial load
duke
parents:
diff changeset
111 //
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 assert(Universe::heap()->is_gc_active(), "called outside gc");
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 PSScavengeRootsClosure roots_closure(pm);
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
118 CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (_java_thread != NULL)
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
121 _java_thread->oops_do(&roots_closure, &roots_in_blobs);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 if (_vm_thread != NULL)
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 196
diff changeset
124 _vm_thread->oops_do(&roots_closure, &roots_in_blobs);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Do the real work
a61af66fc99e Initial load
duke
parents:
diff changeset
127 pm->drain_stacks(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 //
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // StealTask
a61af66fc99e Initial load
duke
parents:
diff changeset
132 //
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 StealTask::StealTask(ParallelTaskTerminator* t) :
a61af66fc99e Initial load
duke
parents:
diff changeset
135 _terminator(t) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 void StealTask::do_it(GCTaskManager* manager, uint which) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 assert(Universe::heap()->is_gc_active(), "called outside gc");
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 PSPromotionManager* pm =
a61af66fc99e Initial load
duke
parents:
diff changeset
141 PSPromotionManager::gc_thread_promotion_manager(which);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 pm->drain_stacks(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 guarantee(pm->stacks_empty(),
a61af66fc99e Initial load
duke
parents:
diff changeset
144 "stacks should be empty at this point");
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 int random_seed = 17;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (pm->depth_first()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 while(true) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
149 StarTask p;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
150 if (PSPromotionManager::steal_depth(which, &random_seed, p)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 #if PS_PM_STATS
a61af66fc99e Initial load
duke
parents:
diff changeset
152 pm->increment_steals(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 #endif // PS_PM_STATS
a61af66fc99e Initial load
duke
parents:
diff changeset
154 pm->process_popped_location_depth(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 pm->drain_stacks_depth(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (terminator()->offer_termination()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 while(true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 oop obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (PSPromotionManager::steal_breadth(which, &random_seed, obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 #if PS_PM_STATS
a61af66fc99e Initial load
duke
parents:
diff changeset
167 pm->increment_steals();
a61af66fc99e Initial load
duke
parents:
diff changeset
168 #endif // PS_PM_STATS
a61af66fc99e Initial load
duke
parents:
diff changeset
169 obj->copy_contents(pm);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 pm->drain_stacks_breadth(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (terminator()->offer_termination()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
178 guarantee(pm->stacks_empty(), "stacks should be empty at this point");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 //
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // SerialOldToYoungRootsTask
a61af66fc99e Initial load
duke
parents:
diff changeset
183 //
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 assert(_gen != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
187 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
193 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // FIX ME! Assert that card_table is the type we believe it to be.
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 card_table->scavenge_contents(_gen->start_array(),
a61af66fc99e Initial load
duke
parents:
diff changeset
197 _gen->object_space(),
a61af66fc99e Initial load
duke
parents:
diff changeset
198 _gen_top,
a61af66fc99e Initial load
duke
parents:
diff changeset
199 pm);
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Do the real work
a61af66fc99e Initial load
duke
parents:
diff changeset
202 pm->drain_stacks(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 //
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // OldToYoungRootsTask
a61af66fc99e Initial load
duke
parents:
diff changeset
208 //
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 assert(_gen != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
212 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
213 assert(_stripe_number < ParallelGCThreads, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which);
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
219 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // FIX ME! Assert that card_table is the type we believe it to be.
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 card_table->scavenge_contents_parallel(_gen->start_array(),
a61af66fc99e Initial load
duke
parents:
diff changeset
223 _gen->object_space(),
a61af66fc99e Initial load
duke
parents:
diff changeset
224 _gen_top,
a61af66fc99e Initial load
duke
parents:
diff changeset
225 pm,
a61af66fc99e Initial load
duke
parents:
diff changeset
226 _stripe_number);
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // Do the real work
a61af66fc99e Initial load
duke
parents:
diff changeset
229 pm->drain_stacks(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }