Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | ba764ed4b6f2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved. | |
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 | |
37 public: | |
38 PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { } | |
39 | |
40 virtual void do_oop(oop* p) { | |
41 if (PSScavenge::should_scavenge(*p)) { | |
42 // We never card mark roots, maybe call a func without test? | |
43 PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); | |
44 } | |
45 } | |
46 }; | |
47 | |
48 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) { | |
49 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
50 | |
51 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); | |
52 PSScavengeRootsClosure roots_closure(pm); | |
53 | |
54 switch (_root_type) { | |
55 case universe: | |
56 Universe::oops_do(&roots_closure); | |
57 ReferenceProcessor::oops_do(&roots_closure); | |
58 break; | |
59 | |
60 case jni_handles: | |
61 JNIHandles::oops_do(&roots_closure); | |
62 break; | |
63 | |
64 case threads: | |
65 { | |
66 ResourceMark rm; | |
67 Threads::oops_do(&roots_closure); | |
68 } | |
69 break; | |
70 | |
71 case object_synchronizer: | |
72 ObjectSynchronizer::oops_do(&roots_closure); | |
73 break; | |
74 | |
75 case flat_profiler: | |
76 FlatProfiler::oops_do(&roots_closure); | |
77 break; | |
78 | |
79 case system_dictionary: | |
80 SystemDictionary::oops_do(&roots_closure); | |
81 break; | |
82 | |
83 case management: | |
84 Management::oops_do(&roots_closure); | |
85 break; | |
86 | |
87 case jvmti: | |
88 JvmtiExport::oops_do(&roots_closure); | |
89 break; | |
90 | |
91 default: | |
92 fatal("Unknown root type"); | |
93 } | |
94 | |
95 // Do the real work | |
96 pm->drain_stacks(false); | |
97 } | |
98 | |
99 // | |
100 // ThreadRootsTask | |
101 // | |
102 | |
103 void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) { | |
104 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
105 | |
106 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); | |
107 PSScavengeRootsClosure roots_closure(pm); | |
108 | |
109 if (_java_thread != NULL) | |
110 _java_thread->oops_do(&roots_closure); | |
111 | |
112 if (_vm_thread != NULL) | |
113 _vm_thread->oops_do(&roots_closure); | |
114 | |
115 // Do the real work | |
116 pm->drain_stacks(false); | |
117 } | |
118 | |
119 // | |
120 // StealTask | |
121 // | |
122 | |
123 StealTask::StealTask(ParallelTaskTerminator* t) : | |
124 _terminator(t) {} | |
125 | |
126 void StealTask::do_it(GCTaskManager* manager, uint which) { | |
127 assert(Universe::heap()->is_gc_active(), "called outside gc"); | |
128 | |
129 PSPromotionManager* pm = | |
130 PSPromotionManager::gc_thread_promotion_manager(which); | |
131 pm->drain_stacks(true); | |
132 guarantee(pm->stacks_empty(), | |
133 "stacks should be empty at this point"); | |
134 | |
135 int random_seed = 17; | |
136 if (pm->depth_first()) { | |
137 while(true) { | |
138 oop* p; | |
139 if (PSPromotionManager::steal_depth(which, &random_seed, p)) { | |
140 #if PS_PM_STATS | |
141 pm->increment_steals(p); | |
142 #endif // PS_PM_STATS | |
143 pm->process_popped_location_depth(p); | |
144 pm->drain_stacks_depth(true); | |
145 } else { | |
146 if (terminator()->offer_termination()) { | |
147 break; | |
148 } | |
149 } | |
150 } | |
151 } else { | |
152 while(true) { | |
153 oop obj; | |
154 if (PSPromotionManager::steal_breadth(which, &random_seed, obj)) { | |
155 #if PS_PM_STATS | |
156 pm->increment_steals(); | |
157 #endif // PS_PM_STATS | |
158 obj->copy_contents(pm); | |
159 pm->drain_stacks_breadth(true); | |
160 } else { | |
161 if (terminator()->offer_termination()) { | |
162 break; | |
163 } | |
164 } | |
165 } | |
166 } | |
167 guarantee(pm->stacks_empty(), | |
168 "stacks should be empty at this point"); | |
169 } | |
170 | |
171 // | |
172 // SerialOldToYoungRootsTask | |
173 // | |
174 | |
175 void SerialOldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) { | |
176 assert(_gen != NULL, "Sanity"); | |
177 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity"); | |
178 | |
179 { | |
180 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); | |
181 | |
182 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
183 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set(); | |
184 // FIX ME! Assert that card_table is the type we believe it to be. | |
185 | |
186 card_table->scavenge_contents(_gen->start_array(), | |
187 _gen->object_space(), | |
188 _gen_top, | |
189 pm); | |
190 | |
191 // Do the real work | |
192 pm->drain_stacks(false); | |
193 } | |
194 } | |
195 | |
196 // | |
197 // OldToYoungRootsTask | |
198 // | |
199 | |
200 void OldToYoungRootsTask::do_it(GCTaskManager* manager, uint which) { | |
201 assert(_gen != NULL, "Sanity"); | |
202 assert(_gen->object_space()->contains(_gen_top) || _gen_top == _gen->object_space()->top(), "Sanity"); | |
203 assert(_stripe_number < ParallelGCThreads, "Sanity"); | |
204 | |
205 { | |
206 PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); | |
207 | |
208 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | |
209 CardTableExtension* card_table = (CardTableExtension *)Universe::heap()->barrier_set(); | |
210 // FIX ME! Assert that card_table is the type we believe it to be. | |
211 | |
212 card_table->scavenge_contents_parallel(_gen->start_array(), | |
213 _gen->object_space(), | |
214 _gen_top, | |
215 pm, | |
216 _stripe_number); | |
217 | |
218 // Do the real work | |
219 pm->drain_stacks(false); | |
220 } | |
221 } |