author | jcoomes |
Wed, 03 Mar 2010 14:48:26 -0800 | |
changeset 5076 | 8b74a4b60b31 |
parent 3908 | 24b55ad4c228 |
child 5547 | f4b087cbb361 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
670 | 2 |
* Copyright 2002-2008 Sun Microsystems, Inc. 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 |
* |
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "incls/_precompiled.incl" |
|
26 |
#include "incls/_psTasks.cpp.incl" |
|
27 |
||
28 |
// |
|
29 |
// ScavengeRootsTask |
|
30 |
// |
|
31 |
||
32 |
// Define before use |
|
33 |
class PSScavengeRootsClosure: public OopClosure { |
|
34 |
private: |
|
35 |
PSPromotionManager* _promotion_manager; |
|
36 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
37 |
protected: |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
38 |
template <class T> void do_oop_work(T *p) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
39 |
if (PSScavenge::should_scavenge(p)) { |
1 | 40 |
// We never card mark roots, maybe call a func without test? |
41 |
PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); |
|
42 |
} |
|
43 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
44 |
public: |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
45 |
PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
46 |
void do_oop(oop* p) { PSScavengeRootsClosure::do_oop_work(p); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
47 |
void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); } |
1 | 48 |
}; |
49 |
||
50 |
void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) { |
|
51 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
52 |
||
53 |
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); |
|
54 |
PSScavengeRootsClosure roots_closure(pm); |
|
55 |
||
56 |
switch (_root_type) { |
|
57 |
case universe: |
|
58 |
Universe::oops_do(&roots_closure); |
|
59 |
ReferenceProcessor::oops_do(&roots_closure); |
|
60 |
break; |
|
61 |
||
62 |
case jni_handles: |
|
63 |
JNIHandles::oops_do(&roots_closure); |
|
64 |
break; |
|
65 |
||
66 |
case threads: |
|
67 |
{ |
|
68 |
ResourceMark rm; |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
69 |
Threads::oops_do(&roots_closure, NULL); |
1 | 70 |
} |
71 |
break; |
|
72 |
||
73 |
case object_synchronizer: |
|
74 |
ObjectSynchronizer::oops_do(&roots_closure); |
|
75 |
break; |
|
76 |
||
77 |
case flat_profiler: |
|
78 |
FlatProfiler::oops_do(&roots_closure); |
|
79 |
break; |
|
80 |
||
81 |
case system_dictionary: |
|
82 |
SystemDictionary::oops_do(&roots_closure); |
|
83 |
break; |
|
84 |
||
85 |
case management: |
|
86 |
Management::oops_do(&roots_closure); |
|
87 |
break; |
|
88 |
||
89 |
case jvmti: |
|
90 |
JvmtiExport::oops_do(&roots_closure); |
|
91 |
break; |
|
92 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
93 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
94 |
case code_cache: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
95 |
{ |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
96 |
CodeBlobToOopClosure each_scavengable_code_blob(&roots_closure, /*do_marking=*/ true); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
97 |
CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
98 |
} |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
99 |
break; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
100 |
|
1 | 101 |
default: |
102 |
fatal("Unknown root type"); |
|
103 |
} |
|
104 |
||
105 |
// Do the real work |
|
106 |
pm->drain_stacks(false); |
|
107 |
} |
|
108 |
||
109 |
// |
|
110 |
// ThreadRootsTask |
|
111 |
// |
|
112 |
||
113 |
void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) { |
|
114 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
115 |
||
116 |
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); |
|
117 |
PSScavengeRootsClosure roots_closure(pm); |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
118 |
CodeBlobToOopClosure roots_in_blobs(&roots_closure, /*do_marking=*/ true); |
1 | 119 |
|
120 |
if (_java_thread != NULL) |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
121 |
_java_thread->oops_do(&roots_closure, &roots_in_blobs); |
1 | 122 |
|
123 |
if (_vm_thread != NULL) |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
670
diff
changeset
|
124 |
_vm_thread->oops_do(&roots_closure, &roots_in_blobs); |
1 | 125 |
|
126 |
// Do the real work |
|
127 |
pm->drain_stacks(false); |
|
128 |
} |
|
129 |
||
130 |
// |
|
131 |
// StealTask |
|
132 |
// |
|
133 |
||
134 |
StealTask::StealTask(ParallelTaskTerminator* t) : |
|
135 |
_terminator(t) {} |
|
136 |
||
137 |
void StealTask::do_it(GCTaskManager* manager, uint which) { |
|
138 |
assert(Universe::heap()->is_gc_active(), "called outside gc"); |
|
139 |
||
140 |
PSPromotionManager* pm = |
|
141 |
PSPromotionManager::gc_thread_promotion_manager(which); |
|
142 |
pm->drain_stacks(true); |
|
143 |
guarantee(pm->stacks_empty(), |
|
144 |
"stacks should be empty at this point"); |
|
145 |
||
146 |
int random_seed = 17; |
|
147 |
if (pm->depth_first()) { |
|
148 |
while(true) { |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
149 |
StarTask p; |
1 | 150 |
if (PSPromotionManager::steal_depth(which, &random_seed, p)) { |
151 |
#if PS_PM_STATS |
|
152 |
pm->increment_steals(p); |
|
153 |
#endif // PS_PM_STATS |
|
154 |
pm->process_popped_location_depth(p); |
|
155 |
pm->drain_stacks_depth(true); |
|
156 |
} else { |
|
157 |
if (terminator()->offer_termination()) { |
|
158 |
break; |
|
159 |
} |
|
160 |
} |
|
161 |
} |
|
162 |
} else { |
|
163 |
while(true) { |
|
164 |
oop obj; |
|
165 |
if (PSPromotionManager::steal_breadth(which, &random_seed, obj)) { |
|
166 |
#if PS_PM_STATS |
|
167 |
pm->increment_steals(); |
|
168 |
#endif // PS_PM_STATS |
|
169 |
obj->copy_contents(pm); |
|
170 |
pm->drain_stacks_breadth(true); |
|
171 |
} else { |
|
172 |
if (terminator()->offer_termination()) { |
|
173 |
break; |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
} |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
178 |
guarantee(pm->stacks_empty(), "stacks should be empty at this point"); |
1 | 179 |
} |
180 |
||
181 |
// |
|
182 |
// SerialOldToYoungRootsTask |
|
183 |
// |
|
184 |
||
185 |
void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) { |
|
186 |
assert(_gen != NULL, "Sanity"); |
|
187 |
assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity"); |
|
188 |
||
189 |
{ |
|
190 |
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); |
|
191 |
||
192 |
assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
|
193 |
CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set(); |
|
194 |
// FIX ME! Assert that card_table is the type we believe it to be. |
|
195 |
||
196 |
card_table->scavenge_contents(_gen->start_array(), |
|
197 |
_gen->object_space(), |
|
198 |
_gen_top, |
|
199 |
pm); |
|
200 |
||
201 |
// Do the real work |
|
202 |
pm->drain_stacks(false); |
|
203 |
} |
|
204 |
} |
|
205 |
||
206 |
// |
|
207 |
// OldToYoungRootsTask |
|
208 |
// |
|
209 |
||
210 |
void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) { |
|
211 |
assert(_gen != NULL, "Sanity"); |
|
212 |
assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity"); |
|
213 |
assert(_stripe_number < ParallelGCThreads, "Sanity"); |
|
214 |
||
215 |
{ |
|
216 |
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); |
|
217 |
||
218 |
assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
|
219 |
CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set(); |
|
220 |
// FIX ME! Assert that card_table is the type we believe it to be. |
|
221 |
||
222 |
card_table->scavenge_contents_parallel(_gen->start_array(), |
|
223 |
_gen->object_space(), |
|
224 |
_gen_top, |
|
225 |
pm, |
|
226 |
_stripe_number); |
|
227 |
||
228 |
// Do the real work |
|
229 |
pm->drain_stacks(false); |
|
230 |
} |
|
231 |
} |